git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-blame.el: Fix compilation warnings.

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 12, 2012, 16:26 UTC
Message-ID
<20120112162617.GA2479@burratino>
In-Reply-To
<2608010.fNV39qBMLu@descartes>

(+cc: Sergei, Kevin) Hi,

Rüdiger Sonderfeld wrote:
> From 4958c1b43d7a66654e15c92cbb878b38533d626e Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?R=C3=BCdiger=20Sonderfeld?= <ruediger@c-plusplus.de>
[...]
These lines should be left out [*].
Show 12 quoted lines
> Replace mapcar with mapc because accumulation of the results was not
> needed. (git-blame-cleanup)
>
> Replace two occurrences of (save-excursion (set-buffer buf) ...)
> with (with-current-buffer buf ...). (git-blame-filter and
> git-blame-create-overlay)
>
> Replace goto-line with (goto-char (point-min)) (forward-line (1-
> start-line)). According to the documentation of goto-line it should
> not be called from elisp code. (git-blame-create-overlay)
>
> Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
I assume this was prompted by warning messages like this one:
	In git-blame-cleanup:
	git-blame.el:306:6:Warning: `mapcar' called for effect; use `mapc' or `dolist' instead

Looks reasonable to my very much untrained eyes, and it's consistent with the hints Kevin gave at [1].

Thanks, Jonathan

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=63;bug=611931 [*] The "From " line and following lines are for your mailer and can be omited unless they differ from the mail header when reading your patch into an email body. See the DISCUSSION sections of git-format-patch(1) and git-am(1) for more on this.

(patch left unsnipped for Sergei and Kevin's convenience)
Show 41 quoted lines
> ---
>  contrib/emacs/git-blame.el |   10 ++++------
>  1 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
> index d351cfb..2e53fc6 100644
> --- a/contrib/emacs/git-blame.el
> +++ b/contrib/emacs/git-blame.el
> @@ -304,7 +304,7 @@ See also function `git-blame-mode'."
>  
>  (defun git-blame-cleanup ()
>    "Remove all blame properties"
> -    (mapcar 'delete-overlay git-blame-overlays)
> +    (mapc 'delete-overlay git-blame-overlays)
>      (setq git-blame-overlays nil)
>      (remove-git-blame-text-properties (point-min) (point-max)))
>  
> @@ -337,8 +337,7 @@ See also function `git-blame-mode'."
>  (defvar in-blame-filter nil)
>  
>  (defun git-blame-filter (proc str)
> -  (save-excursion
> -    (set-buffer (process-buffer proc))
> +  (with-current-buffer (process-buffer proc)
>      (goto-char (process-mark proc))
>      (insert-before-markers str)
>      (goto-char 0)
> @@ -385,11 +384,10 @@ See also function `git-blame-mode'."
>            info))))
>  
>  (defun git-blame-create-overlay (info start-line num-lines)
> -  (save-excursion
> -    (set-buffer git-blame-file)
> +  (with-current-buffer git-blame-file
>      (let ((inhibit-point-motion-hooks t)
>            (inhibit-modification-hooks t))
> -      (goto-line start-line)
> +      (goto-char (point-min)) (forward-line (1- start-line))
>        (let* ((start (point))
>               (end (progn (forward-line num-lines) (point)))
>               (ovl (make-overlay start end))
Previous: Rüdiger SonderfeldNext: Rüdiger Sonderfeld
Message 2 of 18 in “git-blame.el: Fix compilation warnings.”
  1. git-blame.el: Fix compilation warnings.Rüdiger Sonderfeld, Jan 12, 2012
  2. Jonathan NiederJan 12, 2012
  3. Rüdiger SonderfeldJan 12, 2012
  4. Sending patches with KMail (Re: [PATCH] git-blame.el: Fix compilation warnings.)Jonathan Nieder, Jan 13, 2012
  5. Junio C HamanoJan 14, 2012
  6. Jonathan NiederJan 14, 2012
  7. Jonathan NiederJan 14, 2012
  8. Junio C HamanoJan 15, 2012
  9. Rüdiger SonderfeldJan 14, 2012
  10. git-blame.el: use mapc instead of mapcarJonathan Nieder, Jun 10, 2012
  11. 1/3 git-blame.el: Do not use goto-line in lisp codeLawrence Mitchell, Jun 10, 2012
  12. 2/3 git-blame.el: Use with-current-buffer where appropriateLawrence Mitchell, Jun 10, 2012
  13. 3/3 git-blame.el: Do not use bare 0 to mean (point-min)Lawrence Mitchell, Jun 10, 2012
  14. Jonathan NiederJun 14, 2012
  15. Lawrence MitchellJun 14, 2012
  16. 1/3 git-blame.el: Do not use goto-line in lisp codeLawrence Mitchell, Jun 14, 2012
  17. 2/3 git-blame.el: Use with-current-buffer where appropriateLawrence Mitchell, Jun 14, 2012
  18. 3/3 git-blame.el: Do not use bare 0 to mean (point-min)Lawrence Mitchell, Jun 14, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.