]> git.eshelyaron.com Git - emacs.git/commitdiff
Put command line file names and mouse dragging onto 'file-name-history'
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Jul 2021 11:48:10 +0000 (13:48 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Jul 2021 11:48:10 +0000 (13:48 +0200)
* lisp/dnd.el (dnd-open-local-file): Add file to history.
* lisp/files.el (file-name-history--add): New function (bug#12915).

* lisp/startup.el (command-line-1): Add file to history.

etc/NEWS
lisp/dnd.el
lisp/files.el
lisp/startup.el

index 7bf42330b9ddc1e8624b8e7a658929aca93e411e..922b2ab6eb374a0f758beb9fd2d9299c988e1c40 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -91,6 +91,10 @@ proper pty support that Emacs needs.
 \f
 * Startup Changes in Emacs 28.1
 
+---
+** File names given on the command line will now be pushed onto
+'file-name-history'.
+
 ---
 ** In GTK builds, Emacs now supports startup notification.
 This means that Emacs won't steal keyboard focus upon startup
@@ -335,6 +339,10 @@ by dragging the tab lines of their topmost windows with the mouse.
 \f
 * Editing Changes in Emacs 28.1
 
+---
+** Dragging a file to Emacs will now also push the name of the file
+onto 'file-name-history'.
+
 +++
 ** A prefix arg now causes 'delete-other-frames' to only iconify frames.
 
index 7319a27d190551c400959e45438ceb6865a4a3a1..e641b2843a9ed9b145351a73995a78cefb37dac2 100644 (file)
@@ -180,6 +180,7 @@ An alternative for systems that do not support unc file names is
          (if dnd-open-file-other-window
              (find-file-other-window f)
            (find-file f))
+          (file-name-history--add f)
          'private)
       (error "Can not read %s" uri))))
 
index 59077cd266af08982d27b165ca07d3cb56ef04d2..c265f33550f287957ff262b16fa96705c0175280 100644 (file)
@@ -1702,6 +1702,10 @@ rather than FUN itself, to `minibuffer-setup-hook'."
   (list (read-file-name prompt nil default-directory mustmatch)
        t))
 
+(defun file-name-history--add (file)
+  "Add FILE to `file-name-history'."
+  (add-to-history 'file-name-history (abbreviate-file-name file)))
+
 (defun find-file (filename &optional wildcards)
   "Edit file FILENAME.
 Switch to a buffer visiting file FILENAME,
index 456c01efd1341cd8aa05845e191997ac96c92e59..f337f7c6bcfe0d68620a2bc9ee70ea249b740c18 100644 (file)
@@ -2391,6 +2391,7 @@ nil default-directory" name)
                                  (command-line-normalize-file-name name)
                                  dir))
                           (buf (find-file-noselect file)))
+                      (file-name-history--add file)
                      (setq displayable-buffers (cons buf displayable-buffers))
                       ;; Set the file buffer to the current buffer so
                       ;; that it will be used with "--eval" and