[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e02576c: Put command line file names and mouse dragging onto 'fil

From: Lars Ingebrigtsen
Subject: master e02576c: Put command line file names and mouse dragging onto 'file-name-history'
Date: Tue, 20 Jul 2021 07:48:19 -0400 (EDT)

branch: master
commit e02576c7eb75f35e5cc4fa5aa213f0838e2bd168
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Put command line file names and mouse dragging onto 'file-name-history'
    * 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        | 8 ++++++++
 lisp/dnd.el     | 1 +
 lisp/files.el   | 4 ++++
 lisp/startup.el | 1 +
 4 files changed, 14 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 7bf4233..922b2ab 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -92,6 +92,10 @@ proper pty support that Emacs needs.
 * Startup Changes in Emacs 28.1
+** File names given on the command line will now be pushed onto
 ** In GTK builds, Emacs now supports startup notification.
 This means that Emacs won't steal keyboard focus upon startup
 (when started via the Desktop) if the user is typing into another
@@ -335,6 +339,10 @@ by dragging the tab lines of their topmost windows with 
the mouse.
 * 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.
diff --git a/lisp/dnd.el b/lisp/dnd.el
index 7319a27..e641b28 100644
--- a/lisp/dnd.el
+++ b/lisp/dnd.el
@@ -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)
       (error "Can not read %s" uri))))
diff --git a/lisp/files.el b/lisp/files.el
index 59077cd..c265f33 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1702,6 +1702,10 @@ rather than FUN itself, to `minibuffer-setup-hook'."
   (list (read-file-name prompt nil default-directory mustmatch)
+(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,
diff --git a/lisp/startup.el b/lisp/startup.el
index 456c01e..f337f7c 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2391,6 +2391,7 @@ nil default-directory" name)
                                  (command-line-normalize-file-name name)
                           (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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]