backline
backline copied to clipboard
Adding the same behavior to Org mode
Hi. Thank you for this package. I've been using it for years and have just come up with an adaption of this to Org mode
;; Make Org headlines respect the heading backgrounds.
(advice-add #'org-fold-core-region :around #'cae-org-fold-region-a)
(defun cae-org-fold-region-a (oldfun from to flag &optional spec-or-alias)
(let ((shift-fold-p (and (eq to (point-max)) (not (eq from to)) flag)))
(when shift-fold-p
(setq to (1- to)))
(funcall oldfun from to flag spec-or-alias)
(remove-overlays from (1+ to) 'cae-org-fold-heading t)
(when flag
(let ((o (make-overlay to (1+ to) nil 'front-advance)))
(overlay-put o 'evaporate t)
(overlay-put o 'cae-org-fold-heading t)
(overlay-put o 'face (save-excursion (goto-char from) (face-at-point)))
(when shift-fold-p
(overlay-put o 'display "\n"))))))
It has the same issues with nested headings as this package does but it's better than having no workaround at all.
I've been using it for years and have just come up with an adaption of this to Org mode
And I have planned to adapt it for Org for years :grinning:. This looks simple enough, I'll give it a try, once I find the time.
I've been using it for years and have just come up with an adaption of this to Org mode
And I have planned to adapt it for Org for years 😀. This looks simple enough, I'll give it a try, once I find the time.
A fix was recently merged into Org fold for this! It doesn't seem to work perfectly either with nested headings but it's something.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=793cdbea68ae9f6eb4270315df6ff3419c3d8c20
Good to hear! And hoping this will be improved in the future.
I'll give it a try, once I find the time.
Obviously this hasn't happened yet. Busy busy. Still plan to look at it sometime, and the implementation in Org too.
Good to hear! And hoping this will be improved in the future.
I'll give it a try, once I find the time.
Obviously this hasn't happened yet. Busy busy. Still plan to look at it sometime, and the implementation in Org too.
Hi Tarsius. They pushed another commit: https://list.orgmode.org/orgmode/[email protected]/T/#u https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5d186b499dde97f59a91dc11f4c4a15113d29f4d
And now it seems to actually work:
The only way I can see to make it better is by coercing the last character into a newline and leaving it unfolded if the fold goes to the end of the buffer. That would fix the last fold highlight not extending.
The next thing left I think is to modify outline.el to utilize org-fold-core, according to our discussions in the original report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65896GNU.
Doesn't seem to work for me.
Doesn't seem to work for me.
Are you on the latest version of Org mode (not the one built into Emacs)?
From Emacs -Q you can do:
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'org)
(require 'org)
(load-theme 'leuven t)
(dolist (face '(org-level-1 org-level-2 org-level-3 org-level-4 org-level-5
org-level-6 org-level-7 org-level-8))
(set-face-attribute face nil :extend t))
(setq org-fontify-whole-heading-line t)
(scratch-buffer)
(org-mode)
Then start typing headlines.
I've used this simpler setup:
(add-to-list 'load-path "~/.config/emacs/lib/org/lisp")
(setq org-fontify-whole-heading-line t)
(require 'org)
(load-theme 'leuven t)
(with-current-buffer (get-buffer-create "*demo*")
(org-mode)
(erase-buffer)
(save-excursion
(insert "* foo\n** bar\ntest\n** baz\ntest\n\n"))
(pop-to-buffer (current-buffer)))
I'm not calling set-face-attributes because org-mode takes care of that. I double checked that the faces are extended and that I am using the latest Org.
I use TAB (org-cycle). Are you maybe using another command for which it works?
I've used this simpler setup:
(add-to-list 'load-path "~/.config/emacs/lib/org/lisp") (setq org-fontify-whole-heading-line t) (require 'org) (load-theme 'leuven t) (with-current-buffer (get-buffer-create "*demo*") (org-mode) (erase-buffer) (save-excursion (insert "* foo\n** bar\ntest\n** baz\ntest\n\n")) (pop-to-buffer (current-buffer)))I'm not calling
set-face-attributesbecauseorg-modetakes care of that. I double checked that the faces are extended and that I am using the latest Org.I use
TAB(org-cycle). Are you maybe using another command for which it works?
Either you are not using the latest version of Org, which is 9.7, or you're experiencing issues after the latest fix https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=2da622cad. I am using org-cycle as well. That patch has broken it.
EDIT: Just made a bug report: https://lists.gnu.org/archive/html/emacs-orgmode/2024-03/msg00055.html.
I've used this simpler setup:
(add-to-list 'load-path "~/.config/emacs/lib/org/lisp") (setq org-fontify-whole-heading-line t) (require 'org) (load-theme 'leuven t) (with-current-buffer (get-buffer-create "*demo*") (org-mode) (erase-buffer) (save-excursion (insert "* foo\n** bar\ntest\n** baz\ntest\n\n")) (pop-to-buffer (current-buffer)))I'm not calling
set-face-attributesbecauseorg-modetakes care of that. I double checked that the faces are extended and that I am using the latest Org.I use
TAB(org-cycle). Are you maybe using another command for which it works?
Ihor Radchenko made another fix in https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=1151c614b and it seems to be better now, though there are still some extra backgrounds sometimes in the body texts of the headings so we will need to implement tests eventually and I will keep submitting more bug reports with failing examples.
you're experiencing issues after the latest fix
Yes, I made sure to use the very latest version; which backfired.
Ihor Radchenko made another fix
With that it's becoming usable.
there are still some extra backgrounds sometimes in the body texts
Bodies that end with tables seem to be a problem (maybe only if they are inside a #+results: block).