bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#12915: bug#3909: 23.1.50; Drag drop events in command history?


From: Juri Linkov
Subject: bug#12915: bug#3909: 23.1.50; Drag drop events in command history?
Date: Mon, 19 Jul 2021 18:24:08 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> 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) …)





reply via email to

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