GNU bug report logs - #3909
23.1.50; Drag drop events in command history?

Previous Next

Package: emacs;

Reported by: Sridhar Boovaraghavan <sridhar_ml <at> yahoo.com>

Date: Thu, 23 Jul 2009 20:10:05 UTC

Severity: wishlist

Merged with 12915

Found in version 24.2.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #24 received at 3909 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Glenn Morris <rgm <at> gnu.org>, 12915 <at> debbugs.gnu.org, 3909 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: bug#12915: bug#3909: 23.1.50; Drag drop events in command history?
Date: Mon, 19 Jul 2021 18:24:08 +0300
>>> 1) To add an optional parameter to `find-file' to make it push the
>>> filename onto `file-name-history'.  Then we could adjust callers
>>> according to taste: I think drag and drop and command line arguments
>>> should land on the history.
>>
>> @@ -2391,6 +2391,7 @@ command-line-1
>>  				  (command-line-normalize-file-name name)
>>  				  dir))
>>  			   (buf (find-file-noselect file)))
>> +		      (add-to-history 'file-name-history (abbreviate-file-name file))
>
> I thought it might be nice to have these "extra" additions to
> `file-name-history' in one central place (in case we decide to make it
> optional).

`find-file' can't be such central place, because there are many other
file-reading commands like find-file-other-window, find-file-other-frame, …

Long ago I tried:

  (defun add-file-name-to-history ()
    "Add the name of the file just opened to the history."
    (when (and buffer-file-name (not buffer-read-only))
      (add-to-history 'file-name-history buffer-file-name)))
  (add-hook 'find-file-hook 'add-file-name-to-history)
  (add-hook 'first-change-hook 'add-file-name-to-history)

But it clutters up the history.  Maybe a new defcustom e.g.
`add-file-name-commands' could help with such options
as a list of command names to selectively add their args to the history,
or a regexp of command names.

> But I guess we could just have a function like
> `add-to-file-name-history' if we wanted to future-proof that?

This is not specific to the file history, the same requests were about
e.g. describe-function, describe-variable, …  So also tried:

  (define-advice describe-function (:before (function))
    "Add function name to the history."
    (when (and function (symbolp function))
      (add-to-history 'minibuffer-history (symbol-name function))))

  (define-advice describe-variable (:before (variable &optional _buffer _frame))
    "Add variable name to the history."
    (when (and variable (symbolp variable))
      (add-to-history 'minibuffer-history (symbol-name variable))))

  (define-advice describe-symbol (:before (symbol &optional _buffer _frame))
    "Add symbol name to the history."
    (when (and symbol (symbolp symbol))
      (add-to-history 'minibuffer-history (symbol-name symbol))))

But still too much clutter.  Maybe a more general defcustom is needed
that will accept a list of 3 parameters: command name, its argument number,
and a history variable, e.g. '((find-file-other-window 1 file-name-history) …)




This bug report was last modified 3 years and 303 days ago.

Previous Next


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