An interesting question. I store all my dotfiles in the repository and
have a bunch of symlinks scattered all over the filesystem so this is
a known problem to me.
First, a half-solution:
(defalias 'yes-or-no-p 'y-or-n-p)
Now instead of typing a full yes
+ Enter you can just
type a single y or n letter in all situations
where yes-or-no
is asked in Emacs
.
Now, a real solution:
(defun vc-mode-hook ()
(message buffer-file-name)
(when
(and
(file-exists-p (buffer-file-name))
(stringp buffer-file-name)
(or (string-equal "/home/ja/.fluxbox/keys" buffer-file-name)
(string-equal "<PATH_TO_ANOTHER_FILE>" buffer-file-name))
(setq-local vc-follow-symlinks t)
)))
(add-hook 'find-file-hook 'vc-mode-hook)
Here we create a new hook that is called every time find-file
is
called, for example with C-x
C-f or e in Dired
. It first checks
if a visited file really exists on the filesystem using
file-exists-p
because it doesn't make sense to run it on files that
haven't been created yet. Next it checks if a file name is known using
stringp
- it will return t
when a regular file is opened but nil
in a Dired
buffer for example. And finally it checks if the file
name is equal to one of strings provided using string-equal
. If it
is, it locally sets vc-follow-symlinks
to t
. You can add as many
string-equal
lines as you wish. In the example above I added
/home/ja/.fluxbox/keys
and an placeholder for an another file name
in the next line.
nil
is essentially as if you answered "no" to the original question, andt
is as if you answered "yes" to the original question. Thet
behavior seems more natural to me. I'm curious wherenil
would be preferable since I can't immediately think of such a case. – Pavier