GNU bug report logs - #18175
files.el: use mapc in (mapcar 'switch-to-buffer ...)

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Sat, 2 Aug 2014 21:56:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 25.1

Done: Ivan Shmakov <ivan <at> siamics.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ivan Shmakov <ivan <at> siamics.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#18175: closed (files.el: use mapc in (mapcar 'switch-to-buffer
 ...) )
Date: Fri, 23 Jan 2015 15:28:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 23 Jan 2015 15:27:19 +0000
with message-id <87a919o6ug.fsf <at> violet.siamics.net>
and subject line Re: bug#18175: files.el: use mapc in (mapcar 'switch-to-buffer ...)
has caused the debbugs.gnu.org bug report #18175,
regarding files.el: use mapc in (mapcar 'switch-to-buffer ...) 
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
18175: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18175
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ivan Shmakov <ivan <at> siamics.net>
To: submit <at> debbugs.gnu.org
Subject: files.el: use mapc in (mapcar 'switch-to-buffer ...) 
Date: Sat, 02 Aug 2014 21:55:39 +0000
[Message part 3 (text/plain, inline)]
Package:  emacs
Severity: wishlist

	Given that switch-to-buffer returns its argument, /and/ given
	that mapc returns the sequence it’s given, I suggest that the
	(mapcar 'switch-to-buffer LIST) forms in lisp/files.el be
	replaced with (mapc 'switch-to-buffer LIST), – if only to avoid
	the unnecessary consing when the list is effectively copied in
	the mapcar case.

	The lists mapcar is applied to in such cases are returned from
	find-file-noselect, and so, as it seems, are “fresh” ones
	anyway.

	A possible patch is MIMEd.

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
[Message part 4 (text/x-diff, inline)]
diff --git a/lisp/files.el b/lisp/files.el
index 9272e98..e604ce7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1428,7 +1428,7 @@ automatically choosing a major mode, use \\[find-file-literally]."
                         (confirm-nonexistent-file-or-buffer)))
   (let ((value (find-file-noselect filename nil nil wildcards)))
     (if (listp value)
-	(mapcar 'switch-to-buffer (nreverse value))
+	(mapc 'switch-to-buffer (nreverse value))
       (switch-to-buffer value))))
 
 (defun find-file-other-window (filename &optional wildcards)
@@ -1451,7 +1451,7 @@ expand wildcards (if any) and visit multiple files."
 	(progn
 	  (setq value (nreverse value))
 	  (cons (switch-to-buffer-other-window (car value))
-		(mapcar 'switch-to-buffer (cdr value))))
+		(mapc 'switch-to-buffer (cdr value))))
       (switch-to-buffer-other-window value))))
 
 (defun find-file-other-frame (filename &optional wildcards)
@@ -1474,7 +1474,7 @@ expand wildcards (if any) and visit multiple files."
 	(progn
 	  (setq value (nreverse value))
 	  (cons (switch-to-buffer-other-frame (car value))
-		(mapcar 'switch-to-buffer (cdr value))))
+		(mapc 'switch-to-buffer (cdr value))))
       (switch-to-buffer-other-frame value))))
 
 (defun find-file-existing (filename)
[Message part 5 (message/rfc822, inline)]
From: Ivan Shmakov <ivan <at> siamics.net>
To: 18175-done <at> debbugs.gnu.org
Subject: Re: bug#18175: files.el: use mapc in (mapcar 'switch-to-buffer ...)
Date: Fri, 23 Jan 2015 15:27:19 +0000
Version: 25.1

>>>>> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

[…]

 >> However, I believe that the last two hunks of the one another
 >> variant of the diff (MIMEd) actually make the intent to return the
 >> reverse of the list returned by find-file-noselect /clearer,/ –
 >> although at the expense of adding one extra LoC in each case.

 > Agreed, and neither relies on the return value of `mapc', so those
 > two hunks are indeed good.  Please install them.

	Done; closing.

commit 3e824b05af3a75768a61001fad68e2340af810eb
CommitDate: 2015-01-17 19:33:08 +0000

    Avoid mapcar in two cases in files.el.
    
    * lisp/files.el (find-file-other-window, find-file-other-frame):
    Use mapc instead of mapcar.
    
    Fixes: debbugs:18175

-- 
FSF associate member #7257  np. Chemical Wedding – Bruce Dickinson  230E 334A


This bug report was last modified 10 years and 179 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.