branch: elpa/git-commit
commit 027bae37aef0e3f5a6e1192fa727c315eea9de66
Author: Eyal Soha <eyals...@gmail.com>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    git-commit-setup: Fix auto-mode-alist for remote files
    
    The filename added to `auto-mode-alist' must be stripped of the remote
    part, if any,  because that is what `set-auto-mode--apply-alist') does
    when it matches filenames.
    
    Fixes #4987.
---
 lisp/git-commit.el | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index b11141a31c..61e71999c5 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -534,10 +534,17 @@ Used as the local value of `header-line-format', in 
buffer using
       (hack-dir-local-variables)
       (hack-local-variables-apply)))
   (when git-commit-major-mode
-    (let ((auto-mode-alist (list (cons (concat "\\`"
-                                               (regexp-quote buffer-file-name)
-                                               "\\'")
-                                       git-commit-major-mode)))
+    (let ((auto-mode-alist
+           ;; `set-auto-mode--apply-alist' removes the remote part from
+           ;; the file-name before looking it up in `auto-mode-alist'.
+           ;; For our temporary entry to be found, we have to modify the
+           ;; file-name the same way.
+           (list (cons (concat "\\`"
+                               (regexp-quote
+                                (or (file-remote-p buffer-file-name 'localname)
+                                    buffer-file-name))
+                               "\\'")
+                       git-commit-major-mode)))
           ;; The major-mode hook might want to consult these minor
           ;; modes, while the minor-mode hooks might want to consider
           ;; the major mode.

Reply via email to