Subject: bug#16542: 24.3.50; When finding a file via a bookmark, that file is not part of file-name-history

From: Drew Adams <[email-masked]>
Date: Mon, 27 Jan 2014 09:31:29 -0800 (PST)

> I suggest we build a list of Emacs Elisp commands that are
> candidates for adding a file name to file-name-history:
> - bookmark-jump
> - bookmark-jump-other-window
> - dired-find-file
> - dired-find-file-other-window
> come to my mind.  Thanks for adding others.

I suggest taking this to emacs-devel.

> Then a new option find-file-history can contain 'bookmark 'dired
> and the likes to control whether the related features should add
> the file name to `file-name-history'.

I'd sooner see this:

1. A user option such as what you describe, but with nil meaning
   "go for it generally: let the command decide", a non-nil list as
   you mention meaning "do not let these commands decide", and any
   other non-nil value meaning "do not let any command decide".
   IOW, something like this:

(defcustom add-to-file-history-only-if-input ()
  "Which commands to disallow adding non-input file names to the history.
When a file name is read in the minibuffer, the name you enter is
typically added to `file-name-history'.  Some commands may optionally
add additional file names to this minibuffer history.

If the option value is not a list then do not let any commands add a
file name to the history unless you enter that name as minibuffer
input.

Otherwise, the value is a list of commands to disallow adding a name
you did not enter.  (If the value is nil, no commands are disallowed;
they can all add file names that you do not enter.)"
  :type
  '(choice
    (const  :tag "Let no command add a file name I do not enter" t)
    (repeat :tag "Commands that cannot add file names I do not enter"
     (restricted-sexp
      :tag "Command that cannot add unentered file names to history"
      ;; Use `symbolp' instead of `commandp', in case the
      ;; library defining the command is not yet loaded.
      :match-alternatives (symbolp) :value ignore)))
  :group 'files :group 'minibuffer)

2. If a given command is not excluded by the option (see #1) then it
   can, if it wants, add another file name (e.g. a visited file) to
   `file-name-history'.

   If a command wants to offer the possibility of such inclusion, it
   first tests the option value to see if the user allows that.

(There is also the question of whether to do something similar for
other minibuffer histories, besides `file-name-history'.  But we 
can probably forget about that, for now.)