]> git.cworth.org Git - notmuch/commitdiff
emacs: Switch mode before pop-to-buffer master
authorAurelien Rouene <aurelien@rouene.fr>
Thu, 5 Mar 2026 22:33:55 +0000 (23:33 +0100)
committerDavid Bremner <david@tethera.net>
Sat, 14 Mar 2026 22:47:01 +0000 (07:47 +0900)
When showing an email using notmuch-show-mode, set the mode
"notmuch-show-mode" before using "pop-to-buffer-same-window", to be
able to match on the major-mode with an entry in "display-buffer-alist".

Using the major mode is the the only mean to set display rules,
because the buffer title is set to the title of the email and is not fixed.

Signed-off-by: Aurelien Rouene <aurelien@rouene.fr>
emacs/notmuch-show.el

index 9547c6e616dc12fe9838de55127c4ded21e02f25..eeaa93a590f6c88bd15f335eaed0c7cbe0947ead 100644 (file)
@@ -1400,15 +1400,17 @@ function is used.
 Returns the buffer containing the messages, or NIL if no messages
 matched."
   (interactive "sNotmuch show: \nP")
-  (let ((buffer-name (generate-new-buffer-name
-                     (or buffer-name
-                         (concat "*notmuch-" thread-id "*"))))
-       (mm-inline-override-types (notmuch--inline-override-types)))
-
-    (pop-to-buffer-same-window (get-buffer-create buffer-name))
+  (let* ((buffer-name (generate-new-buffer-name
+                      (or buffer-name
+                          (concat "*notmuch-" thread-id "*"))))
+        (buffer (get-buffer-create buffer-name))
+        (mm-inline-override-types (notmuch--inline-override-types)))
+
+    (with-current-buffer buffer
+      (notmuch-show-mode))
+    (pop-to-buffer-same-window buffer)
     ;; No need to track undo information for this buffer.
     (setq buffer-undo-list t)
-    (notmuch-show-mode)
     ;; Set various buffer local variables to their appropriate initial
     ;; state. Do this after enabling `notmuch-show-mode' so that they
     ;; aren't wiped out.