Ihor Radchenko <yanta...@posteo.net> writes:

>> The reason seems that org-agenda-get-restriction-and-command calls
>> delete-other-window; however, this is not something user observes and
>> expects as effect of those commands.
>
> Sure, but what can we do in order to both fix this and also not break
> the existing behaviour?

The simplest solution seems to bind (ignore-window-parameters t) inside
the save-window-excursion in `org-agenda-get-restriction-and-command`,
see below. But I do not know what all can be broken, or whether
something cleaner is possible.

Best regards,

Tomas

--- /tmp/org-agenda.orig        2023-01-06 19:43:03.528884719 +0100
+++ /tmp/org-agenda.el  2023-01-06 19:41:23.493330904 +0100
@@ -3112,13 +3112,14 @@
           c entry key type match prefixes rmheader header-end custom1 desc
           line lines left right n n1)
       (save-window-excursion
-       (delete-other-windows)
-       (org-switch-to-buffer-other-window " *Agenda Commands*")
-       (erase-buffer)
-       (insert (eval-when-compile
-                 (let ((header
-                        (copy-sequence
-                         "Press key for an agenda command:
+        (let ((ignore-window-parameters t))
+          (delete-other-windows)
+          (org-switch-to-buffer-other-window " *Agenda Commands*")
+          (erase-buffer)
+          (insert (eval-when-compile
+                    (let ((header
+                           (copy-sequence
+                            "Press key for an agenda command:
 --------------------------------        <   Buffer, subtree/region restriction
 a   Agenda for current week or day      >   Remove restriction
 t   List of all TODO entries            e   Export agenda views
@@ -3128,14 +3129,14 @@
 ?   Find :FLAGGED: entries              C   Configure custom agenda commands
 *   Toggle sticky agenda views          #   List stuck projects (!=configure)
 "))
-                       (start 0))
-                   (while (string-match
-                           "\\(^\\|   \\|(\\)\\(\\S-\\)\\( \\|=\\)"
-                           header start)
-                     (setq start (match-end 0))
-                     (add-text-properties (match-beginning 2) (match-end 2)
-                                          '(face bold) header))
-                   header)))
+                          (start 0))
+                      (while (string-match
+                              "\\(^\\|   \\|(\\)\\(\\S-\\)\\( \\|=\\)"
+                              header start)
+                        (setq start (match-end 0))
+                        (add-text-properties (match-beginning 2) (match-end 2)
+                                             '(face bold) header))
+                      header))))
        (setq header-end (point-marker))
        (while t
          (setq custom1 custom)

Reply via email to