{"thread":{"id":"670","subject":"Re: [cogito] paged output for cg-diff","startedAt":"2005-05-20T13:17:05Z","lastAt":"2005-05-29T14:01:27Z","messageCount":3,"participants":["Michal Rokos","Junio C Hamano","Petr Baudis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"3604","messageId":"200505201517.05995.michal@rokos.info","threadId":"670","inReplyTo":null,"subject":"Re: [cogito] paged output for cg-diff","fromName":"Michal Rokos","fromEmail":"michal@rokos.info","sentAt":"2005-05-20T13:17:05Z","receivedAt":"2005-05-20T13:17:05Z","isPatch":false,"sender":{"key":"michal@rokos.info","avatar":null},"body":"Hello,\n\nJunio is right, following is sufficent. Tested with 'more' too.\n\n Michal\n\nPS: I'm off the list, so please CC me.\n\nSigned-off-by: Michal Rokos <michal@rokos.info>\nIdea-from: Junio C Hamano <junkio@cox.net>\n\nIndex: cg-Xlib\n===================================================================\n--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-Xlib  (mode:100755)\n+++ uncommitted/cg-Xlib  (mode:100755)\n@@ -91,3 +91,8 @@\n\n export BROKEN_MKTEMP=1\n del=$($(which mktemp) -t 2>/dev/null) && { rm $del; export BROKEN_MKTEMP=; }\n+\n+PAGER () {\n+       ${PAGER:-less} ${PAGER_FLAGS:--R}\n+}\n+\nIndex: cg-diff\n===================================================================\n--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-diff  (mode:100755)\n+++ uncommitted/cg-diff  (mode:100755)\n@@ -71,7 +71,7 @@\n        # FIXME: Update ret based on what did we match. And take \"$@\"\n        # to account after all.\n        ret=\n-       git-diff-cache -r -z $tree | xargs -0 ${COGITO_LIB}cg-Xdiffdo \"$tree\" uncommitted \"$filter\"\n+       git-diff-cache -r -z $tree | xargs -0 ${COGITO_LIB}cg-Xdiffdo \"$tree\" uncommitted \"$filter\" | PAGER\n\n        [ \"$filter\" ] && rm $filter\n\n@@ -85,7 +85,7 @@\n\n [ \"$id1\" = \"$id2\" ] && die \"trying to diff $id1 against itself\"\n\n-git-diff-tree -r -z $id1 $id2 | xargs -0 ${COGITO_LIB}cg-Xdiffdo $id1 $id2 \"$filter\"\n+git-diff-tree -r -z $id1 $id2 | xargs -0 ${COGITO_LIB}cg-Xdiffdo $id1 $id2 \"$filter\" | PAGER\n\n [ \"$filter\" ] && rm $filter\n exit 0\nIndex: cg-log\n===================================================================\n--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-log  (mode:100755)\n+++ uncommitted/cg-log  (mode:100755)\n@@ -181,4 +181,4 @@\n\n                done\n        echo\n-done | ${PAGER:-less} ${PAGER_FLAGS:--R}\n+done | PAGER\n"},{"id":"3606","messageId":"7vu0kyuhtq.fsf@assigned-by-dhcp.cox.net","threadId":"670","inReplyTo":"200505201517.05995.michal@rokos.info","subject":"Re: [cogito] paged output for cg-diff","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-20T13:50:57Z","receivedAt":"2005-05-20T13:50:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"MR\" == Michal Rokos <michal@rokos.info> writes:\n\nMR> Junio is right, following is sufficent. Tested with 'more' too.\nMR> Idea-from: Junio C Hamano <junkio@cox.net>\n\nI appreciate the credit, but that is probably not needed in this\ncase, since this is quite commonly used pattern.  I've seen many\npeople do just this:\n\n          command | ${PAGER:-less}\n\nAnd if you think about it, you would realize that the above is\ngood enough, and probably is a lot better than what you are\ndoing.\n\nYour PAGER shell function gives \"-R\" indiscriminately when\n$PAGER_FLAGS is not set (or set to empty, which is even worse\nbecause you are not giving the user to override this _bad_\nchoice) without even checking if the $PAGER is something that\nunderstands \"-R\" (namely, \"less\").  I do not think users with\ntheir PAGER set to \"more\" or \"cat\" (I do the latter when I am\nworking in Emacs) would appreciate that behaviour.\n\nOn the other hand, if your user is a \"less\" user, and if the\nuser wants it to honor ANSI \"color\" escape sequences, it would\nbe more helpful to the user if you educate/encourage the user to\nhave \"LESS=R\" in the environment and make that in effect\neverywhere less is used not just in Cogito.  Giving that support\nsilently just in Cogito at the first thought may seem to be more\nhelpful but in reality it is not.\n\nSo I would suggest to use the above form without defining your\nown PAGER shell function, and add a tip for \"less\" users to have\n\"LESS=R\" in their environment somewhere in the documentation.\n\n"},{"id":"4168","messageId":"20050529140127.GI1036@pasky.ji.cz","threadId":"670","inReplyTo":"7vu0kyuhtq.fsf@assigned-by-dhcp.cox.net","subject":"Re: [cogito] paged output for cg-diff","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-29T14:01:27Z","receivedAt":"2005-05-29T14:01:27Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, May 20, 2005 at 03:50:57PM CEST, I got a letter\nwhere Junio C Hamano <junkio@cox.net> told me that...\n> On the other hand, if your user is a \"less\" user, and if the\n> user wants it to honor ANSI \"color\" escape sequences, it would\n> be more helpful to the user if you educate/encourage the user to\n> have \"LESS=R\" in the environment and make that in effect\n> everywhere less is used not just in Cogito.  Giving that support\n> silently just in Cogito at the first thought may seem to be more\n> helpful but in reality it is not.\n> \n> So I would suggest to use the above form without defining your\n> own PAGER shell function, and add a tip for \"less\" users to have\n> \"LESS=R\" in their environment somewhere in the documentation.\n\nUsing the $LESS variable didn't occur to me and I like the idea. :-)\nI think the most reasonable thing for Cogito will be to set LESS=R$LESS\nif the user passed -c to the given command.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"}]}