[BUG] org dates, radio links, and special keywords override heading backgrounds [9.7 (9.7-??-902dacb @ /home/st/.config/emacs/.local/straight/build-30.0.50/org/)]

2024-03-03 Thread StrawberryTea


Hello. Currently, if you have a heading background, and you have a date,
radio link, or special keyword, the background is overridden. I have
attached a patch that fixes this issue by using the `prepend' property
instead of the `t' property. Here is also a minimal example to reproduce
the issue:

(defvar bootstrap-version) ; bootstrapping straight.el
(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)
(insert "<<>>\n* [2020-09-11 Fri] Headline 1\n
* COMMENT Headline 2")

If you would like to demo how the patch looks in emacs -Q, you can add
this defun to the above code:

(defun org-set-font-lock-defaults ()
  "Set font lock defaults for the current buffer."
  (let ((org-font-lock-extra-keywords
 (list
  ;; Call the hook
  '(org-font-lock-hook)
  ;; Headlines
  `(,(if org-fontify-whole-heading-line
 "^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)"
   "^\\(\\**\\)\\(\\* \\)\\(.*\\)")
(1 (org-get-level-face 1))
(2 (org-get-level-face 2))
(3 (org-get-level-face 3)))
  ;; Table lines
  '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)\n?"
(0 'org-table-row t)
(1 'org-table t))
  ;; Table internals
  '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))
  '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
  '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
  '("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
  ;; Properties
  (list org-property-re
'(1 'org-special-keyword t)
'(3 'org-property-value t))
  ;; Drawers
  '(org-fontify-drawers)
  ;; Link related fontification.
  '(org-activate-links)
  (when (memq 'tag org-highlight-links) '(org-activate-tags (1 'org-tag 
prepend)))
  (when (memq 'radio org-highlight-links) '(org-activate-target-links (1 
'org-link prepend)))
  (when (memq 'date org-highlight-links) '(org-activate-dates (0 'org-date 
prepend)))
  (when (memq 'footnote org-highlight-links) '(org-activate-footnote-links))
  ;; Targets.
  (list org-radio-target-regexp '(0 'org-target t))
  (list org-target-regexp '(0 'org-target t))
  ;; Diary sexps.
  '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
  ;; Macro
  '(org-fontify-macros)
  ;; TODO keyword
  (list (format org-heading-keyword-regexp-format
org-todo-regexp)
'(2 (org-get-todo-face 2) prepend))
  ;; TODO
  (when org-fontify-todo-headline
(list (format org-heading-keyword-regexp-format
  (concat
   "\\(?:"
   (mapconcat 'regexp-quote org-not-done-keywords "\\|")
   "\\)"))
  '(2 'org-headline-todo prepend)))
  ;; DONE
  (when org-fontify-done-headline
(list (format org-heading-keyword-regexp-format
  (concat
   "\\(?:"
   (mapconcat 'regexp-quote org-done-keywords "\\|")
   "\\)"))
  '(2 'org-headline-done prepend)))
  ;; Priorities
  '(org-font-lock-add-priority-faces)
  ;; Tags
  '(org-font-lock-add-tag-faces)
  ;; Tags groups
  (when (and org-group-tags org-tag-groups-alist)
(list (concat org-outline-regexp-bol ".+\\(:"
  (regexp-opt (mapcar 'car org-tag-groups-alist))
  ":\\).*$")
  '(1 'org-tag-group prepend)))
  ;; Special keywords
  (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
  (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
  (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
  (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
  ;; Emphasis
  (when org-fontify-emphasized-text '(org-do-emphasis-faces))
  ;; Checkboxes
  `(,org-list-full-item-re 3 'org-checkbox prepend lax)
  (when (cdr (assq 'checkbox org-list-automatic-rules))
'("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
  (0 (org-get-checkbox-statistics-face) prepend)))
  ;; Description list items
  '("\\(?:^[ \t]*[-+]\\|^[ \t]+[*]\\)[ \t]+\\(.*?[ \t]+::\\)\\([ 
\t]+\\|$\\)"
1 'org-list-dt prepend)
  ;; Inline export snippets
  '("\\(@@\\)\\([a-z-]+:\\).

Re: [PATCH] org-babel-demarcate-block: split using element API

2024-03-03 Thread gerard . vermeulen




On 03.03.2024 14:08, Ihor Radchenko wrote:

gerard.vermeu...@posteo.net writes:


I have reduced my version of `org-babel-demarcate-block' to a minimal
function to locate the bug stemming from edit-prep signaling an
user-error or not.  In case edit-prep signals an user-error the call
chain `org-indent-block', `org-indent-region', `org-element-at-point'
triggers an infinite list of warnings (major mode is Python when run
on the test block).


Have you tried the latest main?


Yes (just tried again), the minimal function still triggers the 
"infinite" list of warnings
"Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org 
buffer # (python-mode)"

It is coming from the last org-indent-block call even though the message
just before tells that the mode is derived from org-mode.

Your changes of last thursday helped me to narrow the problem down to 
this call.


Regards -- Gerard



Re: [PATCH] org-agenda.el: Fix org-agenda-write to avoid duplicates

2024-03-03 Thread Ihor Radchenko
Anand Deopurkar  writes:

> Subject: [PATCH] org-agenda.el: Fix org-agenda-write to avoid duplicates
>
> * lisp/org-agenda.el (org-agenda-write): Make sure headlines are not
> duplicated when writing to an `org' file, even if they are repeated in
> the agenda view.
>
> For example, a headline may appear multiple times in the agenda
> view (for example, if it has multiple time stamps).  But
> org-agenda-write should write it only once to the output `org' file.

Thanks for the patch!
Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=8ac99c33f

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Extra trailing backgrounds leftover after unfolding org headlines [9.7 (9.7-??-902dacb @ /home/st/.config/emacs/.local/straight/build-30.0.50/org/)]

2024-03-03 Thread Ihor Radchenko
StrawberryTea  writes:

> I've noticed that when I unfold an org headline, a trailing background
> is sometimes left behind at the end of the body text.
>
> Here is a minimal example to reproduce the issue from emacs -Q:
> ...

Thanks for reporting!
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=2da622cad


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] "\fC" macro in ox-man.el [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.2/lisp/org/)]

2024-03-03 Thread Ihor Radchenko
Xiyue Deng  writes:

> (This was first reported to Emacs at
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69483)
>
> "mu4e"[1] (a popular Emacs mail client) uses Org to generate its
> manpages.  However, the generated output contains macros that are not
> understood by groff.  After some debugging, Jeremy traced this back to
> the macro "\fC" used in ox-man.el[2].  Git history shows that this may
> have been there since the beginning.  We tried to find a documentation
> for the "\fC" macro but has not been able to find one.  Jeremy suggests
> that "C" may be an old alias for Courier, and if that's the case it
> should be changed to "\f[CR]".  Would be great if Org people can
> confirm.

This is not an unknown problem. AFAIU, the \fC macro is widely used for
troff, although it is not supported by groff. Check out the ongoing
discussion at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1049968#15

They suggest the following instead of \fC:

   The best solution known to me is to use an extension to the man(7)
   language.  It first appeared in Ninth Edition Unix (1986) and was
   adopted by a groff release in 2009.  That is the `EX`/`EE` macro pair,
   which sets a monospaced display.  (In other words, filling is disabled
   and a monospaced font selected if necessary.)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] org-babel-demarcate-block: split using element API

2024-03-03 Thread Ihor Radchenko
gerard.vermeu...@posteo.net writes:

> I have reduced my version of `org-babel-demarcate-block' to a minimal
> function to locate the bug stemming from edit-prep signaling an
> user-error or not.  In case edit-prep signals an user-error the call
> chain `org-indent-block', `org-indent-region', `org-element-at-point'
> triggers an infinite list of warnings (major mode is Python when run
> on the test block).

Have you tried the latest main?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[PATCH] org-agenda.el: Fix org-agenda-write to avoid duplicates

2024-03-03 Thread Anand Deopurkar
>From a269ee1d657ea11f998d294169cd9a88618409fb Mon Sep 17 00:00:00 2001
From: Anand Deopurkar 
Date: Sun, 3 Mar 2024 16:38:43 +1100
Subject: [PATCH] org-agenda.el: Fix org-agenda-write to avoid duplicates

* lisp/org-agenda.el (org-agenda-write): Make sure headlines are not
duplicated when writing to an `org' file, even if they are repeated in
the agenda view.

For example, a headline may appear multiple times in the agenda
view (for example, if it has multiple time stamps).  But
org-agenda-write should write it only once to the output `org' file.

TINYCHANGE
---
 lisp/org-agenda.el | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 8cb3496ca..798ef1a10 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3641,11 +3641,12 @@ the agenda to write."
 		  (goto-char p)
 		  (setq m (get-text-property (point) 'org-hd-marker))
 		  (when m
-		(push (with-current-buffer (marker-buffer m)
-			(goto-char m)
-			(org-copy-subtree 1 nil t t)
-			org-subtree-clip)
-			  content)))
+		(cl-pushnew (with-current-buffer (marker-buffer m)
+			  (goto-char m)
+			  (org-copy-subtree 1 nil t t)
+			  org-subtree-clip)
+			content
+:test #'equal)))
 		(find-file file)
 		(erase-buffer)
 		(dolist (s content) (org-paste-subtree 1 s))
-- 
2.43.0