org-sticky-header icon indicating copy to clipboard operation
org-sticky-header copied to clipboard

Error during redisplay if org-sticky-header-always-show-header is nil

Open kings2u opened this issue 2 years ago • 2 comments

My messages buffer was constantly filling up with redisplay errors like this:

Error during redisplay: (eval (progn (setq org-sticky-header-stickyline (propertize (org-sticky-header--fetch-stickyline) 'keymap org-sticky-header-keymap)) (list (propertize " " 'display '((space :align-to 0))) 'org-sticky-header-stickyline))) signaled (wrong-type-argument stringp nil) [5 times]

https://github.com/alphapapa/org-sticky-header/issues/19#issuecomment-684128927 led me to a solution. I too had org-sticky-header-always-show-header set to nil, which caused org-sticky-header--fetch-stickyline to sometimes return nil instead of an empty string.

The below seems to solve it:

(defun org-sticky-header--fetch-stickyline ()
  "Return string of Org heading or outline path for display in header line."
  (org-with-wide-buffer
   (goto-char (window-start))
   (if (org-before-first-heading-p)
       ""
     ;; No non-header lines above top displayed header
     (if (or org-sticky-header-always-show-header
             (not (org-at-heading-p)))
         ;; Header should be shown
         (progn 
           (when (fboundp 'org-inlinetask-in-task-p)
             ;; Skip inline tasks
             (while (and (org-back-to-heading)
                         (org-inlinetask-in-task-p))
               (forward-line -1)))
           (cond
            ;; TODO: Update minimum Emacs version and use `pcase'.
            ((null org-sticky-header-full-path)
             (concat (org-sticky-header--get-prefix)
                     (org-sticky-header--heading-string)))
            ((eq org-sticky-header-full-path 'full)
             (concat (org-sticky-header--get-prefix)
                     (mapconcat 'identity
                                (nreverse
                                 (save-excursion
                                   (cl-loop collect (org-sticky-header--heading-string)
                                            while (org-up-heading-safe))))
                                org-sticky-header-outline-path-separator)))
            ((eq org-sticky-header-full-path 'reversed)
             (let ((s (concat
                       (org-sticky-header--get-prefix)
                       (mapconcat 'identity
                                  (save-excursion
                                    (cl-loop collect (org-sticky-header--heading-string)
                                             while (org-up-heading-safe)))
                                  org-sticky-header-outline-path-reversed-separator))))
               (if (> (string-width s) (window-width))
                   (concat (substring s 0 (- (window-width) 2))
                           "..")
                 s)))
            (t "")))
       ""))))

kings2u avatar Nov 06 '23 05:11 kings2u

Hi,

Thanks for reporting this bug. Please try this commit and let me know if it fixes it for you: https://github.com/alphapapa/org-sticky-header/commit/d0304316690b28469530bf92c8a893cfac94fb44

alphapapa avatar Nov 16 '23 04:11 alphapapa

That fixes it for me! Sorry for the delay in responding.

kings2u avatar Dec 20 '23 05:12 kings2u

Hi @alphapapa, I've been seeing this issue too, and the linked commit fixes it for me. Would appreciate it if you could merge the fix!

bcc32 avatar Mar 05 '25 19:03 bcc32

BTW I have installed this patch locally at my site and it works correctly. If you could merge it when you get the chance, that would be great.

bcc32 avatar Oct 30 '25 17:10 bcc32