Re: Displaying outline-heading-alist and outline-regexp in a dedicated buffer

Jean Louis <[email protected]> Mon, 13 Jul 2026 17:31:27 +0300
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
* uzibalqa <[email protected]> [2026-07-13 13:31]:
> 
> On Monday, July 13th, 2026 at 6:00 PM, Jean Louis <[email protected]> wrote:
> 
> > * Heime <[email protected]> [2026-07-10 04:57]:
> > > How may I print the values of outline-heading-alist and outline-regexp
> > > in a dedicated buffer?
> > 
> > (defun my-print-outline-variables ()
> >   "Display outline-heading-alist and outline-regexp in a dedicated buffer."
> >   (interactive)
> >   (let ((buf (get-buffer-create "*Outline Variables*")))
> >     (with-current-buffer buf
> >       (erase-buffer)
> >       (insert (format "Outline Variables\n")
> >               (format "=================\n\n")
> >               (format "outline-regexp:\n  %s\n\n"
> >                       (prin1-to-string outline-regexp))
> >               (format "outline-heading-alist:\n  %s\n"
> >                       (prin1-to-string outline-heading-alist))))
> >     (display-buffer buf)))
> > 
> > --
> > Jean Louis
>  
> The difficulty is that outline-heading-alist and outline-regexp 
> are buffer local variables.  This means that the values are obtained
> from current buffer buf rather than the buffer from where the command
> was invoked.

(defun my-print-outline-variables ()
  "Display outline-heading-alist and outline-regexp from current buffer."
  (interactive)
  (let ((current-buf (current-buffer))
        (buf-name (buffer-name (current-buffer)))
        (regexp-value outline-regexp)
        (alist-value outline-heading-alist))
    (with-current-buffer (get-buffer-create "*Outline Variables*")
      (erase-buffer)
      (insert (format "Buffer: %s\n" buf-name)
              (format "========" (make-string (length buf-name) ?=)) ; FIXED: Use make-string
              (format "\n\n")
              (format "outline-regexp:\n  %s\n\n"
                      (prin1-to-string regexp-value))
              (format "outline-heading-alist:\n  %s\n"
                      (prin1-to-string alist-value)))
      (display-buffer (current-buffer)))))

-- 
Jean Louis