Re: New package `outline-occur'

Juri Linkov <[email protected]>
Newsgroups gmane.emacs.devel
Organization LINKOV.NET
Message-ID <[email protected]>
>> But still we need a better way for a command to override the
>> default behavior (popup or not) using some let-bound variable.
>
> You can let-bind `display-buffer-base-action`.
> We've discussed this a few times in the past already,
> since `display-buffer-base-action` is also a custom var
> and thus it's best not to let-bind it.

display-buffer-base-action customizes only an action
whereas we need both condition and action parts like in
display-buffer-alist to be able to match a category
in the condition part.  Therefore we need a new variable, e.g.
display-buffer-base-alist.

By analogy with completion category options, the new variable
display-buffer-base-alist will correspond to
completion-category-defaults, and the existing option
display-buffer-alist corresponds to
completion-category-overrides for user customization.

Then a command could let-bind it by changing default settings
only for one category like:

(defun occur-outline (regexp &optional nlines region)
  (interactive (occur-read-primary-args))
  (let ((display-buffer-base-alist
         (append `(((and (category . occur)
                         ;; optional:
                         (this-command . occur-outline))
                    nil
                    (post-command-select-window . t)))
                 display-buffer-base-alist)))
    (occur-1 regexp nlines (list (current-buffer)))))

PS: this assumes the following change as well:

diff --git a/lisp/replace.el b/lisp/replace.el
index e7407869ca2..be8b4d1baff 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2062,7 +2062,7 @@ occur-1
 	  (setq occur-revert-arguments (list regexp nlines bufs))
           (if (= count 0)
               (kill-buffer occur-buf)
-            (display-buffer occur-buf)
+            (display-buffer occur-buf '(nil (category . occur)))
             (when occur--final-pos
               (set-window-point
                (get-buffer-window occur-buf 'all-frames)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.