{"thread":{"id":"7417","subject":"[PATCH 1/2] git-blame.el: separate git-blame-mode to ease maintenance","startedAt":"2007-03-26T21:00:54Z","lastAt":"2007-03-28T08:47:18Z","messageCount":4,"participants":["Xavier Maillard","David Kågedal"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"38074","messageId":"200703262100.l2QL0svB012536@localhost.localdomain","threadId":"7417","inReplyTo":null,"subject":"[PATCH 1/2] git-blame.el: separate git-blame-mode to ease maintenance","fromName":"Xavier Maillard","fromEmail":"zedek@gnu.org","sentAt":"2007-03-26T21:00:54Z","receivedAt":"2007-03-26T21:00:54Z","isPatch":true,"sender":{"key":"zedek@gnu.org","avatar":null},"body":"\ngit-blame-mode has been splitted into git-blame-mode-on and\ngit-blame-mode-off; it now conditionnaly calls one of them depending\nof how we call it. Code is now easier to maintain and to understand.\n\nFixed `git-reblame' function: interactive form was at the wrong\nplace.\n\nString displayed on the mode line is now configurable through\n`git-blame-mode-line-string` (default to \" blame\").\n\nSigned-off-by: Xavier Maillard <zedek@gnu.org>\n---\n contrib/emacs/git-blame.el |   55 +++++++++++++++++++++++++++++--------------\n 1 files changed, 37 insertions(+), 18 deletions(-)\n\ndiff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el\nindex 64ad50b..bd87a86 100644\n--- a/contrib/emacs/git-blame.el\n+++ b/contrib/emacs/git-blame.el\n@@ -127,39 +127,58 @@\n \n (defvar git-blame-mode nil)\n (make-variable-buffer-local 'git-blame-mode)\n-(unless (assq 'git-blame-mode minor-mode-alist)\n-  (setq minor-mode-alist\n-\t(cons (list 'git-blame-mode \" blame\")\n-\t      minor-mode-alist)))\n+\n+(defvar git-blame-mode-line-string \" blame\"\n+  \"String to display on the mode line when git-blame is active.\")\n+\n+(or (assq 'git-blame-mode minor-mode-alist)\n+    (setq minor-mode-alist\n+\t  (cons '(git-blame-mode git-blame-mode-line-string) minor-mode-alist)))\n \n ;;;###autoload\n (defun git-blame-mode (&optional arg)\n-  \"Minor mode for displaying Git blame\"\n+  \"Toggle minor mode for displaying Git blame\n+\n+With prefix ARG, turn the mode on if ARG is positive.\"\n   (interactive \"P\")\n-  (if arg\n-      (setq git-blame-mode (eq arg 1))\n-    (setq git-blame-mode (not git-blame-mode)))\n+  (cond\n+   ((null arg)\n+    (if git-blame-mode (git-blame-mode-off) (git-blame-mode-on)))\n+   ((> (prefix-numeric-value arg) 0) (git-blame-mode-on))\n+   (t (git-blame-mode-off))))\n+\n+(defun git-blame-mode-on ()\n+  \"Turn on git-blame mode.\n+\n+See also function `git-blame-mode'.\"\n   (make-local-variable 'git-blame-colors)\n   (if git-blame-autoupdate\n       (add-hook 'after-change-functions 'git-blame-after-change nil t)\n     (remove-hook 'after-change-functions 'git-blame-after-change t))\n   (git-blame-cleanup)\n-  (if git-blame-mode\n-      (progn\n-        (let ((bgmode (cdr (assoc 'background-mode (frame-parameters)))))\n-          (if (eq bgmode 'dark)\n-              (setq git-blame-colors git-blame-dark-colors)\n-            (setq git-blame-colors git-blame-light-colors)))\n-        (setq git-blame-cache (make-hash-table :test 'equal))\n-        (git-blame-run))\n-    (cancel-timer git-blame-idle-timer)))\n+  (let ((bgmode (cdr (assoc 'background-mode (frame-parameters)))))\n+    (if (eq bgmode 'dark)\n+\t(setq git-blame-colors git-blame-dark-colors)\n+      (setq git-blame-colors git-blame-light-colors)))\n+  (setq git-blame-cache (make-hash-table :test 'equal))\n+  (setq git-blame-mode t)\n+  (git-blame-run))\n+\n+(defun git-blame-mode-off ()\n+  \"Turn off git-blame mode.\n+\n+See also function `git-blame-mode'.\"\n+  (git-blame-cleanup)\n+  (if git-blame-idle-timer (cancel-timer git-blame-idle-timer))\n+  (setq git-blame-mode nil))\n \n ;;;###autoload\n (defun git-reblame ()\n   \"Recalculate all blame information in the current buffer\"\n+  (interactive)\n   (unless git-blame-mode\n     (error \"git-blame is not active\"))\n-  (interactive)\n+  \n   (git-blame-cleanup)\n   (git-blame-run))\n \n-- \n1.5.0.5\n"},{"id":"38119","messageId":"87fy7rrsi2.fsf@morpheus.local","threadId":"7417","inReplyTo":"200703262100.l2QL0svB012536@localhost.localdomain","subject":"Re: [PATCH 1/2] git-blame.el: separate git-blame-mode to ease maintenance","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-03-27T08:38:13Z","receivedAt":"2007-03-27T08:38:13Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Xavier Maillard <zedek@gnu.org> writes:\n\n> git-blame-mode has been splitted into git-blame-mode-on and\n> git-blame-mode-off; it now conditionnaly calls one of them depending\n> of how we call it. Code is now easier to maintain and to understand.\n>\n> Fixed `git-reblame' function: interactive form was at the wrong\n> place.\n>\n> String displayed on the mode line is now configurable through\n> `git-blame-mode-line-string` (default to \" blame\").\n\nWhy do you feel the need for this?  I don't remember seeing any other\nminor mode that does this.\n\nOther than that, I think it is an improvement.\n\n> Signed-off-by: Xavier Maillard <zedek@gnu.org>\n> ---\n>  contrib/emacs/git-blame.el |   55 +++++++++++++++++++++++++++++--------------\n>  1 files changed, 37 insertions(+), 18 deletions(-)\n>\n> diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el\n> index 64ad50b..bd87a86 100644\n> --- a/contrib/emacs/git-blame.el\n> +++ b/contrib/emacs/git-blame.el\n> @@ -127,39 +127,58 @@\n>  \n>  (defvar git-blame-mode nil)\n>  (make-variable-buffer-local 'git-blame-mode)\n> -(unless (assq 'git-blame-mode minor-mode-alist)\n> -  (setq minor-mode-alist\n> -\t(cons (list 'git-blame-mode \" blame\")\n> -\t      minor-mode-alist)))\n> +\n> +(defvar git-blame-mode-line-string \" blame\"\n> +  \"String to display on the mode line when git-blame is active.\")\n> +\n> +(or (assq 'git-blame-mode minor-mode-alist)\n> +    (setq minor-mode-alist\n> +\t  (cons '(git-blame-mode git-blame-mode-line-string) minor-mode-alist)))\n>  \n>  ;;;###autoload\n>  (defun git-blame-mode (&optional arg)\n> -  \"Minor mode for displaying Git blame\"\n> +  \"Toggle minor mode for displaying Git blame\n> +\n> +With prefix ARG, turn the mode on if ARG is positive.\"\n>    (interactive \"P\")\n> -  (if arg\n> -      (setq git-blame-mode (eq arg 1))\n> -    (setq git-blame-mode (not git-blame-mode)))\n> +  (cond\n> +   ((null arg)\n> +    (if git-blame-mode (git-blame-mode-off) (git-blame-mode-on)))\n> +   ((> (prefix-numeric-value arg) 0) (git-blame-mode-on))\n> +   (t (git-blame-mode-off))))\n> +\n> +(defun git-blame-mode-on ()\n> +  \"Turn on git-blame mode.\n> +\n> +See also function `git-blame-mode'.\"\n>    (make-local-variable 'git-blame-colors)\n>    (if git-blame-autoupdate\n>        (add-hook 'after-change-functions 'git-blame-after-change nil t)\n>      (remove-hook 'after-change-functions 'git-blame-after-change t))\n>    (git-blame-cleanup)\n> -  (if git-blame-mode\n> -      (progn\n> -        (let ((bgmode (cdr (assoc 'background-mode (frame-parameters)))))\n> -          (if (eq bgmode 'dark)\n> -              (setq git-blame-colors git-blame-dark-colors)\n> -            (setq git-blame-colors git-blame-light-colors)))\n> -        (setq git-blame-cache (make-hash-table :test 'equal))\n> -        (git-blame-run))\n> -    (cancel-timer git-blame-idle-timer)))\n> +  (let ((bgmode (cdr (assoc 'background-mode (frame-parameters)))))\n> +    (if (eq bgmode 'dark)\n> +\t(setq git-blame-colors git-blame-dark-colors)\n> +      (setq git-blame-colors git-blame-light-colors)))\n> +  (setq git-blame-cache (make-hash-table :test 'equal))\n> +  (setq git-blame-mode t)\n> +  (git-blame-run))\n> +\n> +(defun git-blame-mode-off ()\n> +  \"Turn off git-blame mode.\n> +\n> +See also function `git-blame-mode'.\"\n> +  (git-blame-cleanup)\n> +  (if git-blame-idle-timer (cancel-timer git-blame-idle-timer))\n> +  (setq git-blame-mode nil))\n>  \n>  ;;;###autoload\n>  (defun git-reblame ()\n>    \"Recalculate all blame information in the current buffer\"\n> +  (interactive)\n>    (unless git-blame-mode\n>      (error \"git-blame is not active\"))\n> -  (interactive)\n> +  \n>    (git-blame-cleanup)\n>    (git-blame-run))\n\n-- \nDavid Kågedal\n"},{"id":"38158","messageId":"200703271456.l2REumU4007939@localhost.localdomain","threadId":"7417","inReplyTo":"87fy7rrsi2.fsf@morpheus.local","subject":"Re: [PATCH 1/2] git-blame.el: separate git-blame-mode to ease maintenance","fromName":"Xavier Maillard","fromEmail":"zedek@gnu.org","sentAt":"2007-03-27T14:56:48Z","receivedAt":"2007-03-27T14:56:48Z","isPatch":true,"sender":{"key":"zedek@gnu.org","avatar":null},"body":"Hi,\n\n   > String displayed on the mode line is now configurable through\n   > `git-blame-mode-line-string` (default to \" blame\").\n\n   Why do you feel the need for this?  I don't remember seeing any other\n   minor mode that does this.\n\nBecause, I like when I can hide mode line strings for certains\nminor modes or even just shorten it. Here for example, I do not\nfeel the need to display \"Blame\" in the mode line since\ngit-blame.el is easily identifiable.\n\nXavier\n"},{"id":"38240","messageId":"87d52t4uw9.fsf@morpheus.local","threadId":"7417","inReplyTo":"200703271456.l2REumU4007939@localhost.localdomain","subject":"Re: [PATCH 1/2] git-blame.el: separate git-blame-mode to ease maintenance","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-03-28T08:47:18Z","receivedAt":"2007-03-28T08:47:18Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Xavier Maillard <zedek@gnu.org> writes:\n\n> Hi,\n>\n>    > String displayed on the mode line is now configurable through\n>    > `git-blame-mode-line-string` (default to \" blame\").\n>\n>    Why do you feel the need for this?  I don't remember seeing any other\n>    minor mode that does this.\n>\n> Because, I like when I can hide mode line strings for certains\n> minor modes or even just shorten it. Here for example, I do not\n> feel the need to display \"Blame\" in the mode line since\n> git-blame.el is easily identifiable.\n\nOk.  I guess it won't do any harm :-)\n\n-- \nDavid Kågedal\n"}]}