From: Juri Linkov <juri@linkov.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 39190@debbugs.gnu.org, Felician Nemeth <felician.nemeth@gmail.com>
Subject: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)
Date: Tue, 28 Jan 2020 02:01:44 +0200 [thread overview]
Message-ID: <87imkwfnyv.fsf@mail.linkov.net> (raw)
In-Reply-To: <jwvmuadosb3.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 24 Jan 2020 09:18:06 -0500")
[-- Attachment #1: Type: text/plain, Size: 441 bytes --]
> Passing it down as an arg is indeed problematic.
> Maybe we should just add yet-another buffer-<foo>-filename and change
> the corresponding places to so that instead of consulting
>
> buffer-file-name
>
> they consult
>
> (or buffer-file-name buffer-<foo>-filename)
>
> Maybe this could also be used for things like `vc-revision-other-window`.
This requires more testing, but at least such patch
basically would look like this:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: buffer-file-name-for-mode.patch --]
[-- Type: text/x-diff, Size: 3838 bytes --]
diff --git a/lisp/files.el b/lisp/files.el
index 683f4a8ce7..e2721f43fc 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3080,6 +3080,8 @@ magic-mode-regexp-match-limit
"Upper limit on `magic-mode-alist' regexp matches.
Also applies to `magic-fallback-mode-alist'.")
+(defvar-local buffer-file-name-for-mode nil)
+
(defun set-auto-mode (&optional keep-mode-if-same)
"Select major mode appropriate for current buffer.
@@ -3197,11 +3199,10 @@ set-auto-mode
(set-auto-mode-0 done keep-mode-if-same)))
;; Next compare the filename against the entries in auto-mode-alist.
(unless done
- (if buffer-file-name
- (let ((name buffer-file-name)
- (remote-id (file-remote-p buffer-file-name))
- (case-insensitive-p (file-name-case-insensitive-p
- buffer-file-name)))
+ (if (or buffer-file-name buffer-file-name-for-mode)
+ (let* ((name (or buffer-file-name buffer-file-name-for-mode))
+ (remote-id (file-remote-p name))
+ (case-insensitive-p (file-name-case-insensitive-p name)))
;; Remove backup-suffixes from file name.
(setq name (file-name-sans-versions name))
;; Remove remote file name identification.
@@ -3459,6 +3460,8 @@ hack-local-variables-confirm
(let ((name (cond (dir-name)
(buffer-file-name
(file-name-nondirectory buffer-file-name))
+ (buffer-file-name-for-mode
+ (file-name-nondirectory buffer-file-name-for-mode))
((concat "buffer " (buffer-name)))))
(offer-save (and (eq enable-local-variables t)
unsafe-vars))
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index a6be04e313..0c2b985956 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -482,7 +482,7 @@ mm-display-inline-fontify
;; aren't a problem any more. So we could probably get rid of this
;; setting now, but it seems harmless and potentially still useful.
(set (make-local-variable 'font-lock-mode-hook) nil)
- (setq buffer-file-name (mm-handle-filename handle))
+ (setq buffer-file-name-for-mode (mm-handle-filename handle))
(with-demoted-errors
(if mode
(save-window-excursion
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 1a34456340..4290eeb66a 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1391,7 +1391,7 @@ xref--collect-matches
(insert-file-contents file nil 0 200)
;; Can't (setq-local delay-mode-hooks t) because of
;; bug#23272, but the performance penalty seems minimal.
- (let ((buffer-file-name file)
+ (let ((buffer-file-name-for-mode file)
(inhibit-message t)
message-log-max)
(ignore-errors
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 2dbab80208..cff0a5a103 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2718,7 +2718,7 @@ diff-syntax-fontify-props
;; temp buffer.
(cl-assert (null buffer-file-name))
(let ((enable-local-variables :safe) ;; to find `mode:'
- (buffer-file-name file))
+ (buffer-file-name-for-mode file))
(set-auto-mode)
;; FIXME: Is this really worth the trouble?
(when (and (fboundp 'generic-mode-find-file-hook)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index f64b6c0631..79f49ab68b 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2097,7 +2099,7 @@ vc-find-revision-no-save
(if buffer
;; For non-interactive, skip any questions
(let ((enable-local-variables :safe) ;; to find `mode:'
- (buffer-file-name file))
+ (buffer-file-name-for-mode file))
(ignore-errors (set-auto-mode)))
(normal-mode))
(set-buffer-modified-p nil)
next prev parent reply other threads:[~2020-01-28 0:01 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-19 11:14 bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props) Felician Nemeth
2020-01-20 22:56 ` Juri Linkov
2020-01-20 23:34 ` Stefan Monnier
2020-01-24 0:13 ` Juri Linkov
2020-01-24 14:18 ` Stefan Monnier
2020-01-28 0:01 ` Juri Linkov [this message]
2020-01-28 1:30 ` Stefan Monnier
2020-01-28 3:32 ` Eli Zaretskii
2020-01-28 13:58 ` Stefan Monnier
2020-01-28 14:54 ` Dmitry Gutov
2020-01-28 22:53 ` Juri Linkov
2020-01-28 17:54 ` Eli Zaretskii
2020-01-28 20:12 ` Stefan Monnier
2020-01-28 20:23 ` Eli Zaretskii
2020-01-28 23:17 ` Stefan Monnier
2020-01-29 17:13 ` Eli Zaretskii
2020-01-29 21:33 ` Stefan Monnier
2020-01-30 14:17 ` Eli Zaretskii
2020-01-30 14:34 ` Stefan Monnier
2020-01-30 22:50 ` Juri Linkov
2020-01-30 23:09 ` Stefan Monnier
2020-01-30 23:31 ` Dmitry Gutov
2020-01-26 19:34 ` Felician Nemeth
2020-01-28 0:05 ` Juri Linkov
2020-01-28 17:18 ` Felician Nemeth
2020-01-29 23:07 ` Juri Linkov
2020-01-30 19:48 ` Felician Nemeth
2020-01-30 22:45 ` Juri Linkov
2020-02-02 9:42 ` Felician Nemeth
2020-02-02 13:50 ` Stefan Monnier
2020-02-02 23:41 ` Juri Linkov
2020-02-03 13:14 ` Dmitry Gutov
2020-02-03 22:44 ` Juri Linkov
2020-02-04 13:08 ` Dmitry Gutov
2020-02-03 22:45 ` Juri Linkov
2020-02-04 13:36 ` Stefan Monnier
2020-02-04 23:20 ` Juri Linkov
2020-02-05 22:39 ` Juri Linkov
2020-02-09 16:06 ` Felician Nemeth
2020-02-18 0:06 ` Juri Linkov
2020-02-18 13:33 ` Stefan Monnier
2020-02-18 22:53 ` Juri Linkov
2020-02-18 23:07 ` Stefan Monnier
2020-02-18 23:31 ` Stefan Monnier
2020-02-19 0:49 ` Juri Linkov
2020-02-19 13:20 ` Stefan Monnier
2020-02-20 0:58 ` Juri Linkov
2020-03-24 21:37 ` Juri Linkov
2020-03-24 22:29 ` Stefan Monnier
2020-03-25 20:39 ` Juri Linkov
2020-03-25 21:13 ` Stefan Monnier
2020-03-25 21:48 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imkwfnyv.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=39190@debbugs.gnu.org \
--cc=felician.nemeth@gmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.