Org mode version 9.7-pre (9.7-pre-n/a-gb0c3c9); Infinite loop in org-update-statistics-cookies when org-hierarchical-todo-statistics nil

2024-03-10 Thread No Wayman



(elpaca-test
 :interactive t
 :init
 (elpaca org
   (setq org-hierarchical-todo-statistics nil)
   (with-current-buffer (get-buffer-create "*org-bug*")
 (insert "* TODO test [/]\n")
 (insert "** TODO Loop Infinitely")
 (goto-char (point-min))
 (re-search-forward "/" nil t)
 (org-mode)
 (switch-to-buffer (current-buffer)

1. toggle-debug-on-quit
2. With point on the statistics cookie in the first headline, 
invoke org-update-statistics-cookies twice. 
3. Observer an infinite loop.




Re: [Bug] org-in-src-block-p returns t when not in source block

2023-11-27 Thread No Wayman

Ihor Radchenko  writes:


point on trailing blank line: FAIL


Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6d7c7917a


Confirmed on my end by adding `:packages* org` to the previous 
test:


Yodel[1] Report 2023-11-27 15:34:45
===

STDOUT
==

INFO Scraping files for loaddefs... 
  INFO Scraping files for loaddefs...done

  GEN  ../elpaca-autoloads.el
Cloning into '/tmp/yodel-yCfbwq/elpaca/repos/elpaca'...
Your branch is up to date with 'origin/master'.
Checking /tmp/yodel-yCfbwq/elpaca/repos/elpaca...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-info.el...

Compiling /tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-log.el...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-manager.el...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-menu-elpa.el...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-menu-melpa.el...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-menu-org.el...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-process.el...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-test.el...

Compiling /tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca-ui.el...
Compiling /tmp/yodel-yCfbwq/elpaca/repos/elpaca/elpaca.el...
Checking /tmp/yodel-yCfbwq/elpaca/repos/elpaca/doc...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/doc/early-init.el...

Compiling /tmp/yodel-yCfbwq/elpaca/repos/elpaca/doc/init.el...
Checking /tmp/yodel-yCfbwq/elpaca/repos/elpaca/extensions...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/extensions/elpaca-use-package.el...

Checking /tmp/yodel-yCfbwq/elpaca/repos/elpaca/images...
Checking /tmp/yodel-yCfbwq/elpaca/repos/elpaca/test...
Compiling 
/tmp/yodel-yCfbwq/elpaca/repos/elpaca/test/elpaca-test.el...

Done (Total of 11 files compiled, 3 skipped in 4 directories)



Downloading MELPA recipes...
Downloading MELPA recipes...100%
Downloading NonGNU-devel ELPA...
Downloading GNU-devel ELPA...
Downloading NonGNU ELPA...
Downloading GNU ELPA...
Org mode version 9.7-pre (9.7-pre-n/a-g6d7c79
 @ /tmp/yodel-yCfbwq/elpaca/builds/org/)
(org-in-source-block-p ’inside)
point on preceding blank line: PASS
point on begin_src: PASS
point between begin_src end_src: PASS
point on end_src (non-blank line after): PASS
point on end_src (blank line after): PASS
point on end_src (no line after): PASS
point on trailing blank line: PASS


Environment
===

- emacs version: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, 
 GTK+ Version 3.24.38, cairo version 1.18.0)

of 2023-11-16
- system type: gnu/linux

Packages


- elpaca 
 https://github.com/progfolio/elpaca/commit/86a562c0a7c0a009803172eb0ed55fdaf17c4559
- org 
 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6d7c7917a0294bb71c3294119984207b1d9b0385


[1] https://www.github.com/progfolio/yodel



Thanks again.



Re: [Bug] org-in-src-block-p returns t when not in source block

2023-11-27 Thread No Wayman


[Apologies for the duplicate message, Ihor. mu4e recently changed it's default
reply behavior without my noticing]

Ihor Radchenko  writes:

> This is very different from LAX argument in `org-at-timestamp-p' -
> timestamp-like text may not be proper syntactically correct Org markup
> element, but is still considered by agenda for historical and practical
> reasons.

Fair enough.
 
> What about the attached patch?

That is much clearer. Thank you.

> If you want to check if point is inside source block code, use INSIDE
> argument.

Using the INSIDE argument still appears to fail in some cases:

Yodel[1] Report 2023-11-27 14:55:05
===

--8<---cut here---start->8---
(yodel
  :post*
  (require 'org)
  (org-version nil 'full 'message)
  (message "(org-in-source-block-p 'inside)")
  (yodel-file "before.org" :point "|"
:with* "|\n#+begin_src text\ntest\n#+end_src\n"
:then* (message "point on preceding blank line: %s"
 (if (org-in-src-block-p 'inside) "FAIL" "PASS")))
  (yodel-file "begin.org" :point "|"
:with* "\n#+begin|_src text\ntest\n#+end_src\n"
:then* (message "point on begin_src: %s"
 (if (org-in-src-block-p 'inside) "FAIL" "PASS")))
  (yodel-file "in.org" :point "|"
:with* "\n#+begin_src text\nte|st\n#+end_src\n"
:then* (message "point between begin_src end_src: %s"
 (if (org-in-src-block-p 'inside) "PASS" "FAIL")))
  (yodel-file "end-non-blank.org" :point "|"
:with* "\n#+begin_src text\ntest\n#+end|_src\ntest"
:then* (message "point on end_src (non-blank line after): %s"
 (if (org-in-src-block-p 'inside) "FAIL" "PASS")))
  (yodel-file "end.org" :point "|"
:with* "\n#+begin_src text\ntest\n#+end|_src\n"
:then* (message "point on end_src (blank line after): %s"
 (if (org-in-src-block-p 'inside) "FAIL" "PASS")))
  (yodel-file "end-eobp.org" :point "|"
:with* "\n#+begin_src text\ntest\n#+end|_src"
:then* (message "point on end_src (no line after): %s"
 (if (org-in-src-block-p 'inside) "FAIL" "PASS")))
  (yodel-file "after.org" :point "|"
:with* "\n#+begin_src text\ntest\n#+end_src\n|"
:then* (message "point on trailing blank line: %s"
(if (org-in-src-block-p 'inside) "FAIL" "PASS"
--8<---cut here---end--->8---

STDOUT
==

> Org mode version 9.6.11 (release_9.6.11 @ /usr/share/emacs/30.0.50/lisp/org/)
> (org-in-source-block-p ’inside)
> point on preceding blank line: PASS
> point on begin_src: PASS
> point between begin_src end_src: PASS
> point on end_src (non-blank line after): PASS
> point on end_src (blank line after): PASS
> point on end_src (no line after): FAIL
> point on trailing blank line: FAIL

Environment
===

- emacs version: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.38, cairo version 1.18.0)
 of 2023-11-16
- system type: gnu/linux

[1] https://www.github.com/progfolio/yodel



[Bug] org-in-src-block-p returns t when not in source block

2023-11-27 Thread No Wayman



When on an empty line before a source block, org-in-src-block-p 
correctly returns nil.

However, when on an empty line after a source block, it returns t.
This is reproducible on my end with both the built-in version of 
Org and 9.7-pre. 


Yodel[1] Report 2023-11-27 10:42:54
===

--8<---cut here---start->8---
(yodel
 :post*
 (require 'org)
 (org-version nil 'full 'message)
 (yodel-file
   :point "|"
   :with* "#+begin_src text\n#+end_src\n|"
   :then* (message "org-in-src-block-p below: %s" 
   (org-in-src-block-p)))

 (yodel-file
   :point "|"
   :with* "|\n#+begin_src text\n#+end_src"
   :then* (message "org-in-src-block-p above: %s" 
   (org-in-src-block-p

--8<---cut here---end--->8---

STDOUT
==

Org mode version 9.6.11 (release_9.6.11 @ 
/usr/share/emacs/30.0.50/lisp/org/)

org-in-src-block-p below: t
org-in-src-block-p above: nil


Environment
===

- emacs version: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, 
 GTK+ Version 3.24.38, cairo version 1.18.0)

of 2023-11-16
- system type: gnu/linux

[1] https://www.github.com/progfolio/yodel



Org mode version 9.7-pre (9.7-pre-n/a-g2030c1 @ /home/n/.emacs.d/elpaca/builds/org/); org--get-expected-indentation: useless cond clause

2023-09-09 Thread No Wayman



When compiling Org, I get the following warning:

In org--get-expected-indentation:
org.el:19192:8: Warning: Useless clause following default ‘cond’ 
clause


I looked at the source and confirmed it is not a false positive.
The following code is unreachable due to the (t ...) cond clause 
before it:


 ;; Finally, no indentation is needed, fall back to 0.
 (t (current-indentation))

Package: Org mode version 9.7-pre (9.7-pre-n/a-g2030c1 @ 
/home/n/.emacs.d/elpaca/builds/org/)




Re: Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH] refactor org-babel-lilypond-compile-lilyfile

2023-09-05 Thread No Wayman


Ihor Radchenko  writes:


Thanks!


You're welcome.

It looks like ob-lilypond/ly-compile-lilyfile test is relying on 
this
optional second argument. So, after applying your patch, make 
test is

failing.


I've amended the test using cl-letf.
I also bound the variables which may generate output files to nil 
to prevent generating any output files if the test is run 
interactively.

See attached.


>From 94a97e1581c28a5330ddaf6664e1bc00516be807 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 24 Aug 2023 09:32:27 -0400
Subject: [PATCH] lisp/ob-lilypond.el: refactor
 org-babel-lilypond-compile-lilyfile

* ob-lilypond.el (org-babel-lilypond-compile-lilyfile):
Correct compilation message.
Remove superfluous local variables.
Remove unused ad-hoc debugging TEST parameter.

* test-ob-lilypond.el (ob-lilypond/ly-compile-lilyfile):
Locally bind variables which may generate output files.
Refactor to account for removed TEST parameter.
---
 etc/ORG-NEWS |  3 +++
 lisp/ob-lilypond.el  | 35 +---
 testing/lisp/test-ob-lilypond.el | 31 
 3 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 842d3fe4d..c40e1be82 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -304,6 +304,9 @@ setting the ~STYLE~ property for each sub-task.
 
 The change is breaking when ~org-use-property-inheritance~ is set to ~t~.
 
+*** ~org-babel-lilypond-compile-lilyfile~ ignores optional second argument
+
+The =TEST= parameter is better served by Emacs debugging tools.
 ** New and changed options
 *** ~org-export-smart-quotes-alist~ is now a custom option
 
diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 8b2bd231f..c2dba36aa 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -247,27 +247,20 @@ org-babel-lilypond-execute-tangled-ly
 	(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
 	(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)
 
-(defun org-babel-lilypond-compile-lilyfile (file-name  test)
-  "Compile lilypond file and check for compile errors.
-FILE-NAME is full path to lilypond (.ly) file."
-  (message "Compiling LilyPond...")
-  (let ((arg-1 org-babel-lilypond-ly-command) ;program
-;; (arg-2 nil);infile
-(arg-3 "*lilypond*")   ;buffer
-	(arg-4 t)  ;display
-	(arg-5 (if org-babel-lilypond-gen-png  "--png"  "")) ;
-	(arg-6 (if org-babel-lilypond-gen-html "--html" ""))
-(arg-7 (if org-babel-lilypond-gen-pdf "--pdf" ""))
-(arg-8 (if org-babel-lilypond-use-eps  "-dbackend=eps" ""))
-(arg-9 (if org-babel-lilypond-gen-svg  "-dbackend=svg" ""))
-(arg-10 (concat "--output=" (file-name-sans-extension file-name)))
-(arg-11 file-name))
-(if test
-`(,arg-1 ,nil ,arg-3 ,arg-4 ,arg-5 ,arg-6 ;; arg-2
- ,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
-  (call-process
-   arg-1 nil arg-3 arg-4 arg-5 arg-6 ;; arg-2
-   arg-7 arg-8 arg-9 arg-10 arg-11
+;;Ignoring second arg for pre Org 9.7 compatibility
+(defun org-babel-lilypond-compile-lilyfile (filename  _)
+  "Compile Lilypond FILENAME and check for compile errors."
+  (message "Compiling %s..." filename)
+  (let ((args (delq nil (list
+ (and org-babel-lilypond-gen-png  "--png")
+ (and org-babel-lilypond-gen-html "--html")
+ (and org-babel-lilypond-gen-pdf  "--pdf")
+ (and org-babel-lilypond-use-eps  "-dbackend=eps")
+ (and org-babel-lilypond-gen-svg  "-dbackend=svg")
+ (concat "--output=" (file-name-sans-extension filename))
+ filename
+(apply #'call-process org-babel-lilypond-ly-command nil
+   "*lilypond*" 'display args)))
 
 (defun org-babel-lilypond-check-for-compile-error (file-name  test)
   "Check for compile error.
diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el
index b829b8a10..5f439793b 100644
--- a/testing/lisp/test-ob-lilypond.el
+++ b/testing/lisp/test-ob-lilypond.el
@@ -46,19 +46,24 @@ ob-lilypond/org-babel-prep-session:lilypond
   :type 'error)
 
 (ert-deftest ob-lilypond/ly-compile-lilyfile ()
-  (should (equal
-   `(,org-babel-lilypond-ly-command;program
- nil;infile
- "*lilypond*"   ;buffer
- t  ;display
- ,(if org-babel-lilypond-gen-png  "--png"  "") ;
- ,(if org-babel-lilypond-gen-html "--html" "")
- ,(if org-babel-lilypond-gen-pdf "--pdf" "")
- ,(if org-babel-lilypond-use-eps  "-dbackend=eps" "")
- ,(if org-babel-lilypond-gen-svg  "-dbackend=svg" "")
- "--output=test-file"
- "test-file.ly")
-   

Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH] ob-lilypond.el: fix docstring typos

2023-09-03 Thread No Wayman


See attached.

>From 9b21849b9b7d9f36f57241e80d005535f07b788c Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sun, 3 Sep 2023 15:41:51 -0400
Subject: [PATCH] ob-lilypond.el: Fix docstring typos

---
 lisp/ob-lilypond.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index b6ee91f58..ca4005d71 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -145,7 +145,7 @@ org-babel-expand-body:lilypond
 body))
 
 (defun org-babel-execute:lilypond (body params)
-  "Execute lilypond src blcok according to arragne mode.
+  "Execute LilyPond src block according to arrange mode.
 See `org-babel-execute-src-block' for BODY and PARAMS.
 When in arrange mode, tangle all blocks and process the result.
 Otherwise, execute block according to header settings."
-- 
2.42.0



Re: Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH] refactor org-babel-lilypond-compile-lilyfile

2023-09-03 Thread No Wayman


Ihor Radchenko  writes:

- Removes the optional TEST parameter, which is unused and 
better 
  served through debugging tools.  


This is technically a breaking change. So, we (1) need to 
mention it in
ORG-NEWS; (2) may consider (file-name  _) function 
definition

to be 100% sure that no existing code will be broken.


I've added the NEWS entry and updated the signature to ignore the 
second, optional parameter.

See attached.


>From ace59bb72e8fdd6f01033d327de221cfdd9090fe Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 24 Aug 2023 09:32:27 -0400
Subject: [PATCH] lisp/ob-lilypond.el: refactor
 org-babel-lilypond-compile-lilyfile

* ob-lilypond.el (org-babel-lilypond-compile-lilyfile):
Correct compilation message.
Remove superfluous local variables.
Remove unused ad-hoc debugging TEST parameter.
---
 etc/ORG-NEWS|  3 +++
 lisp/ob-lilypond.el | 35 ++-
 2 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 842d3fe4d..c40e1be82 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -304,6 +304,9 @@ setting the ~STYLE~ property for each sub-task.
 
 The change is breaking when ~org-use-property-inheritance~ is set to ~t~.
 
+*** ~org-babel-lilypond-compile-lilyfile~ ignores optional second argument
+
+The =TEST= parameter is better served by Emacs debugging tools.
 ** New and changed options
 *** ~org-export-smart-quotes-alist~ is now a custom option
 
diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 8b2bd231f..c2dba36aa 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -247,27 +247,20 @@ org-babel-lilypond-execute-tangled-ly
 	(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
 	(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)
 
-(defun org-babel-lilypond-compile-lilyfile (file-name  test)
-  "Compile lilypond file and check for compile errors.
-FILE-NAME is full path to lilypond (.ly) file."
-  (message "Compiling LilyPond...")
-  (let ((arg-1 org-babel-lilypond-ly-command) ;program
-;; (arg-2 nil);infile
-(arg-3 "*lilypond*")   ;buffer
-	(arg-4 t)  ;display
-	(arg-5 (if org-babel-lilypond-gen-png  "--png"  "")) ;
-	(arg-6 (if org-babel-lilypond-gen-html "--html" ""))
-(arg-7 (if org-babel-lilypond-gen-pdf "--pdf" ""))
-(arg-8 (if org-babel-lilypond-use-eps  "-dbackend=eps" ""))
-(arg-9 (if org-babel-lilypond-gen-svg  "-dbackend=svg" ""))
-(arg-10 (concat "--output=" (file-name-sans-extension file-name)))
-(arg-11 file-name))
-(if test
-`(,arg-1 ,nil ,arg-3 ,arg-4 ,arg-5 ,arg-6 ;; arg-2
- ,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
-  (call-process
-   arg-1 nil arg-3 arg-4 arg-5 arg-6 ;; arg-2
-   arg-7 arg-8 arg-9 arg-10 arg-11
+;;Ignoring second arg for pre Org 9.7 compatibility
+(defun org-babel-lilypond-compile-lilyfile (filename  _)
+  "Compile Lilypond FILENAME and check for compile errors."
+  (message "Compiling %s..." filename)
+  (let ((args (delq nil (list
+ (and org-babel-lilypond-gen-png  "--png")
+ (and org-babel-lilypond-gen-html "--html")
+ (and org-babel-lilypond-gen-pdf  "--pdf")
+ (and org-babel-lilypond-use-eps  "-dbackend=eps")
+ (and org-babel-lilypond-gen-svg  "-dbackend=svg")
+ (concat "--output=" (file-name-sans-extension filename))
+ filename
+(apply #'call-process org-babel-lilypond-ly-command nil
+   "*lilypond*" 'display args)))
 
 (defun org-babel-lilypond-check-for-compile-error (file-name  test)
   "Check for compile error.
-- 
2.42.0



Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH] refactor org-babel-lilypond-compile-lilyfile

2023-08-24 Thread No Wayman


The attached patch:

- Improves the compilation message. (The target is the file, not 
 LilyPond itself).
- Refactors the body of the function to remove the many 
 nondescript arg-n local variables.
- Removes the optional TEST parameter, which is unused and better 
 served through debugging tools.  



>From 5765891b9de22260454d2cee8365c14841d0d744 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 24 Aug 2023 09:32:27 -0400
Subject: [PATCH] lisp/ob-lilypond.el: refactor
 org-babel-lilypond-compile-lilyfile

* ob-lilypond.el (org-babel-lilypond-compile-lilyfile):
Correct compilation message.
Remove superfluous local variables.
Remove unused ad-hoc debugging TEST parameter.
---
 lisp/ob-lilypond.el | 32 +---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 8b2bd231f..92cd59685 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -247,27 +247,21 @@ org-babel-lilypond-execute-tangled-ly
 	(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
 	(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)
 
-(defun org-babel-lilypond-compile-lilyfile (file-name  test)
+(defun org-babel-lilypond-compile-lilyfile (file-name)
   "Compile lilypond file and check for compile errors.
 FILE-NAME is full path to lilypond (.ly) file."
-  (message "Compiling LilyPond...")
-  (let ((arg-1 org-babel-lilypond-ly-command) ;program
-;; (arg-2 nil);infile
-(arg-3 "*lilypond*")   ;buffer
-	(arg-4 t)  ;display
-	(arg-5 (if org-babel-lilypond-gen-png  "--png"  "")) ;
-	(arg-6 (if org-babel-lilypond-gen-html "--html" ""))
-(arg-7 (if org-babel-lilypond-gen-pdf "--pdf" ""))
-(arg-8 (if org-babel-lilypond-use-eps  "-dbackend=eps" ""))
-(arg-9 (if org-babel-lilypond-gen-svg  "-dbackend=svg" ""))
-(arg-10 (concat "--output=" (file-name-sans-extension file-name)))
-(arg-11 file-name))
-(if test
-`(,arg-1 ,nil ,arg-3 ,arg-4 ,arg-5 ,arg-6 ;; arg-2
- ,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
-  (call-process
-   arg-1 nil arg-3 arg-4 arg-5 arg-6 ;; arg-2
-   arg-7 arg-8 arg-9 arg-10 arg-11
+  (message "Compiling %s..." file-name)
+  (let ((args
+ (delq nil (list
+(and org-babel-lilypond-gen-png  "--png")
+(and org-babel-lilypond-gen-html "--html")
+(and org-babel-lilypond-gen-pdf  "--pdf")
+(and org-babel-lilypond-use-eps  "-dbackend=eps")
+(and org-babel-lilypond-gen-svg  "-dbackend=svg")
+(concat "--output=" (file-name-sans-extension file-name))
+file-name
+(apply #'call-process org-babel-lilypond-ly-command nil
+   "*lilypond*" 'display args)))
 
 (defun org-babel-lilypond-check-for-compile-error (file-name  test)
   "Check for compile error.
-- 
2.41.0



Re: Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH]: fix ob-lilypond docstrings

2023-08-24 Thread No Wayman


Ihor Radchenko  writes:


No Wayman  writes:


The attached patch satisfies all but two checkdoc warnings.
I left those two for someone more familiar with the package.


Thanks!


Subject: [PATCH] * lisp/ob-lilypond.el: satisfy checkdoc


_S_atisfy.


(org-babel-lilypond-compile-post-tangle): fix docstring
(org-babel-lilypond-display-pdf-post-tangle): fix docstring
(org-babel-lilypond-play-midi-post-tangle): fix docstring
(org-babel-execute:lilypond): fix docstring
(org-babel-lilypond-tangle): fix docstring
(org-babel-lilypond-process-basic): fix docstring
(org-babel-lilypond-parse-line-num): fix docstring
(org-babel-lilypond-set-header-args): fix docstring


It is enough to say "Fix docstring" just for the last line and 
leave all

other : ... empty.


Fixed in attached patch.


 (defun org-babel-lilypond-set-header-args (mode)
-  "Set org-babel-default-header-args:lilypond
-dependent on ORG-BABEL-LILYPOND-ARRANGE-MODE."
+  "Set lilypond babel header args from 
ORG-BABEL-LILYPOND-ARRANGE-MODE."


What is ORG-BABEL-LILYPOND-ARRANGE-MODE?


Looks like it's a variable that would be better served by a 
minor-mode.


#+begin_src emacs-lisp
(defvar org-babel-lilypond-arrange-mode nil
 "Non-nil turns Arrange mode on.
In Arrange mode the following settings are altered from default:
:tangle yes,:noweb yes
:results silent :comments yes.
In addition lilypond block execution causes tangling of all 
lilypond

blocks.")
#+end_src

A minor mode would also obviate the need for 
`org-babel-lilypond-toggle-arrange-mode'.

Let's do that in a separate patch.

>From 2acc8e219011040d76e0faa0a6f642ace480f2df Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 24 Aug 2023 08:20:22 -0400
Subject: [PATCH] * lisp/ob-lilypond.el: Satisfy checkdoc

(org-babel-lilypond-compile-post-tangle):
(org-babel-lilypond-display-pdf-post-tangle):
(org-babel-lilypond-play-midi-post-tangle):
(org-babel-execute:lilypond):
(org-babel-lilypond-tangle):
(org-babel-lilypond-process-basic):
(org-babel-lilypond-parse-line-num):
(org-babel-lilypond-set-header-args):
Fix docstring
---
 lisp/ob-lilypond.el | 37 -
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 8b2bd231f..b6ee91f58 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -58,23 +58,13 @@ ob-lilypond-header-args
 See `org-babel-lilypond-set-header-args'.")
 
 (defvar org-babel-lilypond-compile-post-tangle t
-  "Following the org-babel-tangle (C-c C-v t) command,
-org-babel-lilypond-compile-post-tangle determines whether ob-lilypond should
-automatically attempt to compile the resultant tangled file.
-If the value is nil, no automated compilation takes place.
-Default value is t.")
+  "When non-nil, compile tangled file after `org-babel-tangle'.")
 
 (defvar org-babel-lilypond-display-pdf-post-tangle t
-  "Following a successful LilyPond compilation
-org-babel-lilypond-display-pdf-post-tangle determines whether to automate the
-drawing / redrawing of the resultant pdf.  If the value is nil,
-the pdf is not automatically redrawn.  Default value is t.")
+  "When non-nil, display pdf after successful LilyPond compilation.")
 
 (defvar org-babel-lilypond-play-midi-post-tangle t
-  "Following a successful LilyPond compilation
-org-babel-lilypond-play-midi-post-tangle determines whether to automate the
-playing of the resultant midi file.  If the value is nil,
-the midi file is not automatically played.  Default value is t")
+  "When non-nil, play midi file after successful LilyPond compilation.")
 
 (defvar org-babel-lilypond-ly-command ""
   "Command to execute lilypond on your system.
@@ -155,20 +145,17 @@ org-babel-expand-body:lilypond
 body))
 
 (defun org-babel-execute:lilypond (body params)
-  "This function is called by `org-babel-execute-src-block'.
-Depending on whether we are in arrange mode either:
-1. Attempt to execute lilypond block according to header settings
-  (This is the default basic mode)
-2. Tangle all lilypond blocks and process the result (arrange mode)"
+  "Execute lilypond src blcok according to arragne mode.
+See `org-babel-execute-src-block' for BODY and PARAMS.
+When in arrange mode, tangle all blocks and process the result.
+Otherwise, execute block according to header settings."
   (org-babel-lilypond-set-header-args org-babel-lilypond-arrange-mode)
   (if org-babel-lilypond-arrange-mode
   (org-babel-lilypond-tangle)
 (org-babel-lilypond-process-basic body params)))
 
 (defun org-babel-lilypond-tangle ()
-  "ob-lilypond specific tangle, attempts to invoke
-=ly-execute-tangled-ly= if tangle is successful.  Also passes
-specific arguments to =org-babel-tangle=."
+  "Tangle lilypond blocks, then `org-babel-liypond-execute-tangled-ly'."
   (interactive)
   (if (org-babel-tangle

Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH]: fix ob-lilypond docstrings

2023-08-24 Thread No Wayman


The attached patch satisfies all but two checkdoc warnings.
I left those two for someone more familiar with the package.

>From ecd5fe22458db64d86650a1a7a1e697d9ccff020 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 24 Aug 2023 08:20:22 -0400
Subject: [PATCH] * lisp/ob-lilypond.el: satisfy checkdoc

(org-babel-lilypond-compile-post-tangle): fix docstring
(org-babel-lilypond-display-pdf-post-tangle): fix docstring
(org-babel-lilypond-play-midi-post-tangle): fix docstring
(org-babel-execute:lilypond): fix docstring
(org-babel-lilypond-tangle): fix docstring
(org-babel-lilypond-process-basic): fix docstring
(org-babel-lilypond-parse-line-num): fix docstring
(org-babel-lilypond-set-header-args): fix docstring
---
 lisp/ob-lilypond.el | 37 -
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 8b2bd231f..47ad0a25d 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -58,23 +58,13 @@ ob-lilypond-header-args
 See `org-babel-lilypond-set-header-args'.")
 
 (defvar org-babel-lilypond-compile-post-tangle t
-  "Following the org-babel-tangle (C-c C-v t) command,
-org-babel-lilypond-compile-post-tangle determines whether ob-lilypond should
-automatically attempt to compile the resultant tangled file.
-If the value is nil, no automated compilation takes place.
-Default value is t.")
+  "When non-nil, compile tangled file after `org-babel-tangle'.")
 
 (defvar org-babel-lilypond-display-pdf-post-tangle t
-  "Following a successful LilyPond compilation
-org-babel-lilypond-display-pdf-post-tangle determines whether to automate the
-drawing / redrawing of the resultant pdf.  If the value is nil,
-the pdf is not automatically redrawn.  Default value is t.")
+  "When non-nil, display pdf after successful LilyPond compilation.")
 
 (defvar org-babel-lilypond-play-midi-post-tangle t
-  "Following a successful LilyPond compilation
-org-babel-lilypond-play-midi-post-tangle determines whether to automate the
-playing of the resultant midi file.  If the value is nil,
-the midi file is not automatically played.  Default value is t")
+  "When non-nil, play midi file after successful LilyPond compilation.")
 
 (defvar org-babel-lilypond-ly-command ""
   "Command to execute lilypond on your system.
@@ -155,20 +145,17 @@ org-babel-expand-body:lilypond
 body))
 
 (defun org-babel-execute:lilypond (body params)
-  "This function is called by `org-babel-execute-src-block'.
-Depending on whether we are in arrange mode either:
-1. Attempt to execute lilypond block according to header settings
-  (This is the default basic mode)
-2. Tangle all lilypond blocks and process the result (arrange mode)"
+  "Execute lilypond src blcok according to arragne mode.
+See `org-babel-execute-src-block' for BODY and PARAMS.
+When in arrange mode, tangle all blocks and process the result.
+Otherwise, execute block according to header settings."
   (org-babel-lilypond-set-header-args org-babel-lilypond-arrange-mode)
   (if org-babel-lilypond-arrange-mode
   (org-babel-lilypond-tangle)
 (org-babel-lilypond-process-basic body params)))
 
 (defun org-babel-lilypond-tangle ()
-  "ob-lilypond specific tangle, attempts to invoke
-=ly-execute-tangled-ly= if tangle is successful.  Also passes
-specific arguments to =org-babel-tangle=."
+  "Tangle lilypond blocks, then `org-babel-liypond-execute-tangled-ly'."
   (interactive)
   (if (org-babel-tangle nil "yes" "lilypond")
   (org-babel-lilypond-execute-tangled-ly) nil))
@@ -190,7 +177,8 @@ org-babel-lilypond-paper-settings
 They are needed for mixing music and text in basic-mode.")
 
 (defun org-babel-lilypond-process-basic (body params)
-  "Execute a lilypond block in basic mode."
+  "Execute a lilypond block in basic mode.
+See `org-babel-execute-src-block' for BODY and PARAMS."
   (let* ((out-file (cdr (assq :file params)))
  (file-type (file-name-extension out-file))
 	 (cmdline (or (cdr (assq :cmdline params))
@@ -308,7 +296,7 @@ org-babel-lilypond-mark-error-line
   (goto-char temp
 
 (defun org-babel-lilypond-parse-line-num ( buffer)
-  "Extract error line number."
+  "Extract error line number in BUFFER or `current-buffer'."
   (when buffer (set-buffer buffer))
   (let ((start
  (and (search-backward ":" nil t)
@@ -441,8 +429,7 @@ org-babel-lilypond-get-header-args
  ob-lilypond-header-args)))
 
 (defun org-babel-lilypond-set-header-args (mode)
-  "Set org-babel-default-header-args:lilypond
-dependent on ORG-BABEL-LILYPOND-ARRANGE-MODE."
+  "Set lilypond babel header args from ORG-BABEL-LILYPOND-ARRANGE-MODE."
   (setq org-babel-default-header-args:lilypond
 (org-babel-lilypond-get-header-args mode)))
 
-- 
2.41.0



Re: [Pre-PATCH v2] Add the capability to specify lexical scope in tangled files (was: Add new :lexical header argument)

2023-07-14 Thread No Wayman




From: Ihor Radchenko 
I am not sure if I like this approach.
I have 2 problems with the patch:



1. Previous users of :lexical header arg might be surprised.
   Though it is an OK breaking change since people who used 
   :lexical
   argument and expected it to be ignored in the tangled file 
   probably

   did something wrong.


Previous related discussion:

https://list.orgmode.org/87o89184h1@gmail.com/

I, and others, have been surprised to find that the tangled file 
does not have lexical binding enabled when :lexical blocks are 
tangled.




Re: [PATCH] org-capture.el: Allow `(here)' as a template

2023-06-23 Thread No Wayman



Ihor Radchenko  writes:


No Wayman  writes:


No Wayman  writes:

Evaluating the following source blocking an org mode buffer 
with 
no backing file:


Interesting. I'm only able to reproduce it some of the time.
I'll look into it more when I have time, but it may have been 
an 
artifact of my Emacs session.


I saw
Was it the same for you?


Yes, that's the same error. (Sorry, looks like an intermediate 
message of mine got dropped)


Hmm. plain entry type actually works, except the above error, 
which is

likely Emacs bug.


Could be.






Re: [PATCH] org-capture.el: Allow `(here)' as a template

2023-06-22 Thread No Wayman



No Wayman  writes:

Evaluating the following source blocking an org mode buffer with 
no backing file:


Interesting. I'm only able to reproduce it some of the time.
I'll look into it more when I have time, but it may have been an 
artifact of my Emacs session.


I was able to trigger an error when capturing from non-Org 
buffer, but
that's expected - org-capture is not designed for such 
scenarios.


This seems unnecessarily restrictive considering there is a 
"plain" entry type, but that's another issue/design consideration.




Re: [PATCH] org-capture.el: Allow `(here)' as a template

2023-06-22 Thread No Wayman



`org-capture-store-last-position' will signal an error if a 
template with a target of (here) is invoked from a buffer which is 
not backed by a file.





Re: Can a post-capture hook know which capture template I used?

2023-04-14 Thread No Wayman



https://www.github.com/progfolio/doct may be helpful here



Re: [POLL] Naming of "export features"

2023-02-23 Thread No Wayman



Timothy  writes:

I hadn’t thought of applying the term “enrichment”. That or 
adaptation could be
a good fit. I think I like the sound of “enriching the export”, 
and I could
probably also be sold on “export adaptation” / “adaptive 
export”.


Both are horribly abstract in my opinion.
If the aim is to sound overly technical and vague, we should take 
a page from web design and call it "progressive export 
enhancements". /s




Re: [POLL] Naming of "export features"

2023-02-23 Thread No Wayman




Ihor Radchenko  writes:

I am looking at the concept again, and I feel that we may be 
missing
some flexibility here. I do not like the fact that each feature 
can only

have a simple implementation within specific backend.


Agreed


What I have in mind is an ability to parametrize the transcoders


This seems like a step in the right direction.



Re: [POLL] Naming of "export features"

2023-02-23 Thread No Wayman



And to add:

https://books.google.com/ngrams/graph?content=adaption%2Cadaptation%2Ccontext%2Cenhancement%2Cenrichment%2Cfeature_start=1800_end=2019=en-2019=3

It appears context is king.
All that aside, I think Ihor's proposal sidesteps the whole issue 
while addressing the complexity of the implementation.




Re: [POLL] Naming of "export features"

2023-02-23 Thread No Wayman



⁃ Providing capabilities via snippets can be framed as akin to 
dynamically

  gaining a feature.


I understand some snippets may be used to, for example, include a 
latex package.
However, it's not a requirement that a snippet "add a 
feature/capability" to a document.
What that snippet does depends entirely on the context of the 
export (a latex snippet will not "do" anything if inserted in an 
HTML doc).
What if I want to add some metadata or a string like "Hi, Mom" in 
the preamble of the document? Would it be reasonable to say the 
document has had the "secret mom greeting" capability added, or is 
that an overly complicated way of framing it?

Is the snippet required to have a side-effect on the document?

On the obverse, the snippets are always being added depending on 
the context of the export.
`ox-contextual-snippets` is a much more concrete name than any of 
the others proposed.


Both components are crucial to the overall system, however if 
anything I view
the latter as more important and so am not a fan of describing 
this system as

“export contexts”.


How is the latter more important if it depends on the former?

As I mentioned off list, I think naming is only part of the 
problem.

The design and API are currently over-engineered.
That should be discussed before worrying about the name.








Re: [PATCH] Introduce "export features"

2023-02-11 Thread No Wayman



often we include content in export templates that is only 
relevant in

particular situations.

“export features” allow for the specification of qualities of 
the org buffer
being exported that imply certain “features”, and how those 
features may be

implemented in a particular export.


now `\usepackage{svg}' is automatically added when exporting a 
buffer that

includes SVG images.



┌
│ (org-export-update-features 'beamer
│   (beamer-metropolis
│:condition (string-match-p \"metropolis$\" (plist-get info 
:beamer-theme))

│:snippet my-org-beamer-metropolis-tweaks
│:order 3))
└


As discussed on the Doom Emacs Discord, I strongly suggest 
renaming to avoid overloading the term "feature".
To me, your description indicates sinppets are inserted 
contextually.
Org has a similar notion of contexts with 
`org-capture-templates-contexts'.
A similar name would be better as it does not overload the term 
"feature", which already has a different meaning in elisp.

e.g. org-export-backend-contexts



Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-20 Thread No Wayman



Ihor Radchenko  writes:


No Wayman  writes:

Feel free to take this the patch as a base to do whatever you 
please with it.


Then, I am thinking about a simple approach that will not 
involve

internet connection. See the attached.


I think that's the best solution. I landed on something similar 
for Elpaca (and will likely suggest the same for straight.el).


Note that you, in fact, can fetch the latest tags from remote 
into

shallow clone. See
https://stackoverflow.com/questions/66349002/get-latest-tag-git-describe-tags-when-repo-is-cloned-with-depth-1


Seems more complicated than it's worth at this point.


   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval 
   "(require 'lisp-mnt)" \
 --visit lisp/org.el --eval '(princ (lm-header 
 "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* 
--abbrev=6 HEAD)
+  GITVERSION ?= $(shell git describe --match release\* 
--abbrev=6 HEAD 2>/dev/null || echo  "release_N/A-N/A-$(shell 
git log --format=%h HEAD^..HEAD)")


Why not use ORGVERSION here? Is the metadata in org.el's version 
header not updated when a commit is tagged as a release?





Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-19 Thread No Wayman



Ihor Radchenko  writes:


No Wayman  writes:


No Wayman  writes:


The attached patch should take care of that.


Thanks!

I played a bit more with the patch and noticed that remote tag 
lookup is

not performed prior to _any_ make command.
For example, there is a noticeable delay on my network when 
running

something as simple as make clean.

Maybe it would be better to download the tags instead of running
ls-remote every time? I also imagine that ls-remote might pull 
newer

tags compared to the actual clone.

An alternative could be postponing git ls-remote call to when 
the actual

targets using GITVERSION are being called.


Feel free to take this the patch as a base to do whatever you 
please with it.
I've run out of free time to iterate on it. 





Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-18 Thread No Wayman


No Wayman  writes:


The attached patch should take care of that.


Sorry. Had trailing whitespace in that version. 
Attached here without trailing whitespace.


>From 85990610ca7572f5a6ff7604d957efdf00747094 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Mon, 16 Jan 2023 14:00:41 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..be79a127 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,20 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
 --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+COMMIT := $(shell git rev-parse --short=6 HEAD)
+TAG:= $(lastword $(REMOTETAGS))
+ifneq ($(TAG),)
+  TAGPREFIX  := $(subst refs/tags/,,$(TAG))
+  GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT), $(TAGPREFIX))
+else
+  GITVERSION ?= $(ORGVERSION)-n/a-g$(COMMIT)
+endif
+  else
+GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
+  GITVERSION ?= N/A
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0



Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-18 Thread No Wayman


Ihor Radchenko  writes:


No Wayman  writes:


Ihor Radchenko  writes:

What we should not have is "make autoloads" failing without 
internet.


The attached patch should take care of that.
If the ls-remote errors, GITVERSION will be set to N/A as when 
it 
is generally unavailable. 


I just tried your patch running make without internet. I got the
following Org version:

Subject: [BUG] test [9.6.1 ( @ /tmp/org-mode/lisp/)]

As you can see, the last commit number is not listed even though 
I can

see it via git log.



The attached patch should take care of that.

>From 872ba4bf04313692758bcb3d8622c16bbd407101 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Mon, 16 Jan 2023 14:00:41 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..ca6d8c42 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,20 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
 --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+COMMIT := $(shell git rev-parse --short=6 HEAD)
+TAG:= $(lastword $(REMOTETAGS))
+ifneq ($(TAG),)
+  TAGPREFIX  := $(subst refs/tags/,,$(TAG))
+  GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT), $(TAGPREFIX)) 
+else
+  GITVERSION ?= $(ORGVERSION)-n/a-g$(COMMIT)
+endif
+  else
+GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
+  GITVERSION ?= N/A
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0



Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-16 Thread No Wayman


Ihor Radchenko  writes:

What we should not have is "make autoloads" failing without 
internet.


The attached patch should take care of that.
If the ls-remote errors, GITVERSION will be set to N/A as when it 
is generally unavailable. 

>From 4ce8b2dfc2cf2ca1507aa14be15f5212eb1de229 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Mon, 16 Jan 2023 14:00:41 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..9a62cbd4 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,15 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
 --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+COMMIT := $(shell git rev-parse --short=6 HEAD)
+TAGPREFIX  := $(subst refs/tags/,,$(lastword $(REMOTETAGS)))
+GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX))
+  else
+GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
+  GITVERSION ?= N/A
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0



Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-15 Thread No Wayman


No Wayman  writes:

Sorry, wrong commit value in the previous patch.
Fixed the patch attached here.

>From a4cd70e17455894aec5d15d97eb41b56769e5cde Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sun, 15 Jan 2023 15:44:45 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..20d375aa 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,14 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
 --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+COMMIT := $(shell git rev-parse --short=6 HEAD)
+TAGPREFIX  := $(subst refs/tags/,,$(lastword $(REMOTETAGS)))
+GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX))
+  else
+GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0



[PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]

2023-01-15 Thread No Wayman


In order to properly generate org-version.el, the current build in 
mk/targets.mk requires a query of the repo's tags. Shallow clones 
do not have tags and so org-version will be generated as "N/A". In 
the attached patch, support for generating org-version.el from 
shallow clones is added. It is done by querying the upstream 
remote via git ls-remote and parsing the output. In this case, a 
more well formed org-version string will be generated. However, it 
will be missing the "commits since last tag" information. e.g.


"release_9.6.1-n/a-gabc123"

>From 28c596320f48e4606f8eaf69fdc1c83fb084749e Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sun, 15 Jan 2023 14:55:11 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa91..300fc8e0b 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,14 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
 --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+COMMIT := $(shell echo $(firstword $(REMOTETAGS)) | cut -c 1-6)
+TAGPREFIX  := $(subst refs/tags/,,$(lastword $(REMOTETAGS)))
+GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX))
+  else
+GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0



Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.36, cairo version 1.17.6)

of 2023-01-08
Package: Org mode version 9.6.1 (release_9.6.1-137-gecb62e @ 
/home/n/.emacs.d/elpaca/builds/org/)


Re: [PATCH] DOCT integration: template specific hooks [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-10-06 Thread No Wayman



I've addressed your comments in the attached patch.
I based it off the most recent patch in the thread.
The main difference is that the hook properties accept a single 
nullary function or list of nullary functions.


>From 90f0c68e1149512b51230fd44ad728b38e5f088e Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 27 Sep 2022 05:44:33 -0400
Subject: [PATCH] org-capture: Add template hook properties

* lisp/org-capture.el (org-capture-templates): Document template hook properties.
(org-capture-finalize): Execute :prepare/:before/:after-finalize functions.
(org-capture-place-template): Execute :hook functions.

* doc/org-manual.org Document template hook properties.

* etc/ORG-NEWS: Add news entry for template hook properties.

* testing/lisp/test-org-capture.el: Add tests for template hook properties.
---
 doc/org-manual.org   | 20 +++
 etc/ORG-NEWS |  6 +
 lisp/org-capture.el  | 32 
 testing/lisp/test-org-capture.el | 43 
 4 files changed, 101 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ab8a295e5..6a857529c 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7838,6 +7838,26 @@ Now lets look at the elements of a template definition.  Each entry in
   - ~:refile-targets :: Temporarily set ~org-refile-targets~ to the
 value of this property.
 
+  - ~:hook~ ::
+
+A nullary function or list of nullary functions run before ~org-capture-mode-hook~
+when the template is selected.
+
+ - ~:prepare-finalize~ ::
+
+A nullary function or list of nullary functions run before ~org-capture-prepare-finalize-hook~
+when the template is selected.
+
+ - ~:before-finalize~ ::
+
+A nullary function or list of nullary functions run before ~org-capture-before-finalize-hook~
+when the template is selected.
+
+ - ~:after-finalize~ ::
+
+A nullary function or list of nullary functions run before ~org-capture-after-finalize-hook~
+when the template is selected.
+
  Template expansion
 :PROPERTIES:
 :DESCRIPTION: Filling in information about time and context.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index cab64317f..1a482c3c7 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -657,6 +657,12 @@ When exiting capture mode via ~org-capture-refile~, the variable
 ~org-refile-targets~ will be temporarily bound to the value of this
 template option.
 
+*** Add Capture template hook properties
+
+Capture templates can now attach template specific hooks via the following properties:
+~:hook~, ~:prepare-finalize~, ~:before-finalize~, ~:after-finalize~.
+These nullary functions run prior to their global counterparts for the selected template.
+
 *** New startup options =#+startup: showlevels=
 
 These startup options complement the existing =overview=, =content=,
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 428d0ac0e..4b6b51b39 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -297,6 +297,21 @@ properties are:
 
  :no-saveDo not save the target file after finishing the capture.
 
+ :hook   A nullary function or list of nullary functions run before
+ `org-capture-mode-hook' when the template is selected.
+
+ :prepare-finalize   A nullary function or list of nullary functions run before
+ `org-capture-prepare-finalize-hook'
+ when the template is selected.
+
+ :before-finalizeA nullary function or list of nullary functions run before
+ `org-capture-before-finalize-hook'
+ when the template is selected.
+
+ :after-finalize A nullary function or list of nullary functions run before
+ `org-capture-after-finalize-hook'
+ when the template is selected.
+
 The template defines the text to be inserted.  Often this is an
 Org mode entry (so the first line should start with a star) that
 will be filed as a child of the target headline.  It can also be
@@ -740,6 +755,17 @@ of the day at point (if any) or the current HH:MM time."
 	(format "* Template function %S not found" f)))
  (_ "* Invalid capture template"
 
+(defun org-capture--run-template-functions (keyword  local)
+  "Run funcitons associated with KEYWORD on template's plist.
+For valid values of KEYWORD see `org-capture-templates'.
+If LOCAL is non-nil use the buffer-local value of `org-capture-plist'."
+  ;; Used in place of `run-hooks' because these functions have no associated symbol.
+  ;; They are stored directly on `org-capture-plist'.
+  (let ((value (org-capture-get keyword local)))
+(if (functionp value)
+(funcall value)
+  (mapc #'funcall value
+
 (defun org-capture-finalize ( stay-with-capture)
   "Finalize the capture process.
 With prefix argument STAY-WITH-CAPTURE, jump to the location of the
@@ -751,6 +777,7 @@ captured item after finalizing."
 	   

[BUG] org-element: defsubst org-element--cache-active-p used before defined [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-09-27 Thread No Wayman



Byte compiling in a clean environment yields the following 
warning:


org-element.el:11:5682 Warning: defsubst 
‘org-element--cache-active-p’ was used before it was defined.


I'll leave a patch to whoever is maintaining this feature because 
it will involve hoisting several other variables to fix.




[BUG] [PATCH] Template elements: fix doc typo [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-09-27 Thread No Wayman


Attached patch adds closing mark up for code in definition list.

>From d2ac397ea9dc4265f38cab070dccbbb82c61148f Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 27 Sep 2022 20:27:07 -0400
Subject: [PATCH] doc/org-manual.org fix capture Template elements typo

---
 doc/org-manual.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ab8a295e5..d249f32d6 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7835,7 +7835,7 @@ Now lets look at the elements of a template definition.  Each entry in
 
 Do not save the target file after finishing the capture.
 
-  - ~:refile-targets :: Temporarily set ~org-refile-targets~ to the
+  - ~:refile-targets~ :: Temporarily set ~org-refile-targets~ to the
 value of this property.
 
  Template expansion
-- 
2.37.3



Re: [PATCH] DOCT integration: template specific hooks [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-09-27 Thread No Wayman


On second thought, I'd prefer the keywords to allow a single 
function or a list of functions.
This prevents breakage with current DOCT syntax and is cleaner 
IMO. e.g.


#+begin_srce emacs-lisp :lexical t
(let ((org-capture-templates
  '(("t" "test" plain (file "/tmp/test.org") "test %?"
 :hook (lambda () (insert "PASS"))
 (org-capture nil "t"))
#+end_src

See attached patch.

>From 780194a5af6a8a6c7fbb602e834dcbec78016070 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 27 Sep 2022 05:44:33 -0400
Subject: [PATCH] org-capture: Add template hook properties

* lisp/org-capture.el (org-capture-templates): Document template hook properties.
(org-capture-finalize): execute :prepare/:before/:after-finalize functions.
(org-capture-place-template): execute :hook functions.

* doc/org-manual.org Document template hook properties.
---
 doc/org-manual.org  | 20 
 lisp/org-capture.el | 29 +
 2 files changed, 49 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ab8a295e5..c1321f6cd 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7838,6 +7838,26 @@ Now lets look at the elements of a template definition.  Each entry in
   - ~:refile-targets :: Temporarily set ~org-refile-targets~ to the
 value of this property.
 
+  - ~:hook~ ::
+
+A function or list of functions run before `org-capture-mode-hook'
+when the template is selected.
+
+ - ~:prepare-finalize~ ::
+
+A function or list of functions run before `org-capture-prepare-finalize-hook'
+when the template is selected.
+
+ - ~:before-finalize~ ::
+
+A function or list of functions run before `org-capture-before-finalize-hook'
+when the template is selected.
+
+ - ~:after-finalize~ ::
+
+A function or list of functions run before `org-capture-after-finalize-hook'
+when the template is selected.
+
  Template expansion
 :PROPERTIES:
 :DESCRIPTION: Filling in information about time and context.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 428d0ac0e..e5528a849 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -297,6 +297,21 @@ properties are:
 
  :no-saveDo not save the target file after finishing the capture.
 
+ :hook   A function or list of functions run before
+ `org-capture-mode-hook' when the template is selected.
+
+ :prepare-finalize   A function or list of functions run before
+ `org-capture-prepare-finalize-hook'
+ when the template is selected.
+
+ :before-finalizeA function or list of functions run before
+ `org-capture-before-finalize-hook'
+ when the template is selected.
+
+ :after-finalize A function or list of functions run before
+ `org-capture-after-finalize-hook'
+ when the template is selected.
+
 The template defines the text to be inserted.  Often this is an
 Org mode entry (so the first line should start with a star) that
 will be filed as a child of the target headline.  It can also be
@@ -740,6 +755,14 @@ of the day at point (if any) or the current HH:MM time."
 	(format "* Template function %S not found" f)))
  (_ "* Invalid capture template"
 
+(defun org-capture--run-template-functions (keyword  local)
+  "Run template's KEYWORD functions.
+If LOCAL is non-nil use the buffer-local value of `org-capture-plist'."
+  (let ((value (org-capture-get keyword local)))
+(if (functionp value)
+(funcall value)
+  (mapc #'funcall value
+
 (defun org-capture-finalize ( stay-with-capture)
   "Finalize the capture process.
 With prefix argument STAY-WITH-CAPTURE, jump to the location of the
@@ -751,6 +774,7 @@ captured item after finalizing."
 	   (buffer-base-buffer (current-buffer)))
 (error "This does not seem to be a capture buffer for Org mode"))
 
+  (org-capture--run-template-functions :prepare-finalize t)
   (run-hooks 'org-capture-prepare-finalize-hook)
 
   ;; Update `org-capture-plist' with the buffer-local value.  Since
@@ -823,6 +847,7 @@ captured item after finalizing."
   ;; the indirect buffer has been killed.
   (org-capture-store-last-position)
 
+  (org-capture--run-template-functions :before-finalize t)
   ;; Run the hook
   (run-hooks 'org-capture-before-finalize-hook))
 
@@ -871,6 +896,9 @@ captured item after finalizing."
   ;; Restore the window configuration before capture
   (set-window-configuration return-wconf))
 
+;; Do not use the local arg to `org-capture-get' here.
+;; The buffer-local value has been stored on `org-capture-plist'.
+(org-capture--run-template-functions :after-finalize)
 (run-hooks 'org-capture-after-finalize-hook)
 ;; Special cases
 (cond
@@ -1147,6 +1175,7 @@ may have been stored before."
 (`item (org-capture-place-item))
 (`checkitem (org-capture-place-item)))
   

Re: [PATCH] DOCT integration: template specific hooks [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-09-27 Thread No Wayman


Attached is a revision which fixes a typo in a comment.
>From af1d14439d6ada284b5f9b8f17a3da2a172808f1 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 27 Sep 2022 05:44:33 -0400
Subject: [PATCH] org-capture: Add template hook properties

* lisp/org-capture.el (org-capture-templates): Document template hook properties.
(org-capture-finalize): execute :prepare/:before/:after-finalize functions.
(org-capture-place-template): execute :hook functions.

* doc/org-manual.org Document template hook properties.
---
 doc/org-manual.org  | 20 
 lisp/org-capture.el | 21 +
 2 files changed, 41 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ab8a295e5..ed2322949 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7838,6 +7838,26 @@ Now lets look at the elements of a template definition.  Each entry in
   - ~:refile-targets :: Temporarily set ~org-refile-targets~ to the
 value of this property.
 
+  - ~:hook~ ::
+
+A list of functions run before `org-capture-mode-hook'
+when the template is selected.
+
+ - ~:prepare-finalize~ ::
+
+A list of functions run before `org-capture-prepare-finalize-hook'
+when the template is selected.
+
+ - ~:before-finalize~ ::
+
+A list of functions run before `org-capture-before-finalize-hook'
+when the template is selected.
+
+ - ~:after-finalize~ ::
+
+A list of functions run before `org-capture-after-finalize-hook'
+when the template is selected.
+
  Template expansion
 :PROPERTIES:
 :DESCRIPTION: Filling in information about time and context.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 428d0ac0e..2004c91fa 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -297,6 +297,21 @@ properties are:
 
  :no-saveDo not save the target file after finishing the capture.
 
+ :hook   A list of functions run before
+ `org-capture-mode-hook' when the template is selected.
+
+ :prepare-finalize   A list of functions run before
+ `org-capture-prepare-finalize-hook'
+ when the template is selected.
+
+ :before-finalizeA list of functions run before
+ `org-capture-before-finalize-hook'
+ when the template is selected.
+
+ :after-finalize A list of functions run before
+ `org-capture-after-finalize-hook'
+ when the template is selected.
+
 The template defines the text to be inserted.  Often this is an
 Org mode entry (so the first line should start with a star) that
 will be filed as a child of the target headline.  It can also be
@@ -751,6 +766,7 @@ captured item after finalizing."
 	   (buffer-base-buffer (current-buffer)))
 (error "This does not seem to be a capture buffer for Org mode"))
 
+  (mapc #'funcall (org-capture-get :prepare-finalize t))
   (run-hooks 'org-capture-prepare-finalize-hook)
 
   ;; Update `org-capture-plist' with the buffer-local value.  Since
@@ -823,6 +839,7 @@ captured item after finalizing."
   ;; the indirect buffer has been killed.
   (org-capture-store-last-position)
 
+  (mapc #'funcall (org-capture-get :before-finalize t))
   ;; Run the hook
   (run-hooks 'org-capture-before-finalize-hook))
 
@@ -871,6 +888,9 @@ captured item after finalizing."
   ;; Restore the window configuration before capture
   (set-window-configuration return-wconf))
 
+;; Do not use the local arg to `org-capture-get' here.
+;; The buffer-local value has been stored on `org-capture-plist'.
+(mapc #'funcall (org-capture-get :after-finalize))
 (run-hooks 'org-capture-after-finalize-hook)
 ;; Special cases
 (cond
@@ -1147,6 +1167,7 @@ may have been stored before."
 (`item (org-capture-place-item))
 (`checkitem (org-capture-place-item)))
   (setq-local org-capture-current-plist org-capture-plist)
+  (mapc #'funcall (org-capture-get :hook t))
   (org-capture-mode 1))
 
 (defun org-capture-place-entry ()
-- 
2.37.3



Re: [PATCH] DOCT integration: template specific hooks [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-09-27 Thread No Wayman


No Wayman  writes:

The attached patch is the first step toward integrating DOCT[1] 
syntax into Org mode.
It adds property options to org-capture-templates which make it 
easier to run template-specific hooks.
The current approach for running such hooks involves adding to 
the 
desired global hook variable and filtering by the template's 
keys.

e.g.

#+begin_src emacs-lisp :lexical t
(defun +example-template-hook ()
  (when (eq (org-capture-get :key t) "e")
(message "hook run")))

(add-hook 'org-capture-mode-hook #'+example-template-hook)

(let ((org-capture-templates '("e" "example" (file "") "")))
  (org-capture nil "e"))
#+end_src


The hook has to be maintained separately from the template 
declaration.
The criteria to determine the selected template is baked into 
the 
hook function.
This is fragile (change the binding for the template and you 
must 
update the hook function),

mixes concerns, and makes templates harder to share.

Contrast the above with the following syntax enabled by the 
attached patch: 


#+begin_src emacs-lisp :lexical t
(let ((org-capture-templates
   '(("t" "test" plain (file "/tmp/test.org")
  "test %?"
  :hook ((lambda () (insert "mode-hook\n")))
  :before-finalize ((lambda () (insert 
  "before-finalize\n")))
  ;; Only a message because this happens outside the 
  context

  ;; of the capture buffer.
  :after-finalize ((lambda () (message 
  "after-finalize")))
  :prepare-finalize ((lambda () (insert 
  "prepare-finalize\n")))

  (org-capture nil "t"))
#+end_src

These template-specific hook functions run prior to their global 
counterparts.


Ihor, an implementation note: I have not used `run-hooks' with 
these because they have no associated symbol.

The functions are lists stored directly on `org-capture-plist'.

[1]: https://github.com/progfolio/doct


And, of course, the patch...

>From 790e8c517ba933025e50302e9c990ccf9265b55c Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 27 Sep 2022 05:44:33 -0400
Subject: [PATCH] org-capture: Add template hook properties

* lisp/org-capture.el (org-capture-templates): Document template hook properties.
(org-capture-finalize): execute :prepare/:before/:after-finalize functions.
(org-capture-place-template): execute :hook functions.

* doc/org-manual.org Document template hook properties.
---
 doc/org-manual.org  | 20 
 lisp/org-capture.el | 21 +
 2 files changed, 41 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ab8a295e5..ed2322949 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7838,6 +7838,26 @@ Now lets look at the elements of a template definition.  Each entry in
   - ~:refile-targets :: Temporarily set ~org-refile-targets~ to the
 value of this property.
 
+  - ~:hook~ ::
+
+A list of functions run before `org-capture-mode-hook'
+when the template is selected.
+
+ - ~:prepare-finalize~ ::
+
+A list of functions run before `org-capture-prepare-finalize-hook'
+when the template is selected.
+
+ - ~:before-finalize~ ::
+
+A list of functions run before `org-capture-before-finalize-hook'
+when the template is selected.
+
+ - ~:after-finalize~ ::
+
+A list of functions run before `org-capture-after-finalize-hook'
+when the template is selected.
+
  Template expansion
 :PROPERTIES:
 :DESCRIPTION: Filling in information about time and context.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 428d0ac0e..af1502ede 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -297,6 +297,21 @@ properties are:
 
  :no-saveDo not save the target file after finishing the capture.
 
+ :hook   A list of functions run before
+ `org-capture-mode-hook' when the template is selected.
+
+ :prepare-finalize   A list of functions run before
+ `org-capture-prepare-finalize-hook'
+ when the template is selected.
+
+ :before-finalizeA list of functions run before
+ `org-capture-before-finalize-hook'
+ when the template is selected.
+
+ :after-finalize A list of functions run before
+ `org-capture-after-finalize-hook'
+ when the template is selected.
+
 The template defines the text to be inserted.  Often this is an
 Org mode entry (so the first line should start with a star) that
 will be filed as a child of the target headline.  It can also be
@@ -751,6 +766,7 @@ captured item after finalizing."
 	   (buffer-base-buffer (current-buffer)))
 (error "This does not seem to be a capture buffer for Org mode"))
 
+  (mapc #'funcall (org-capture-get :pre

[PATCH] DOCT integration: template specific hooks [9.5.5 (9.5.5-g003cc7 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-09-27 Thread No Wayman
The attached patch is the first step toward integrating DOCT[1] 
syntax into Org mode.
It adds property options to org-capture-templates which make it 
easier to run template-specific hooks.
The current approach for running such hooks involves adding to the 
desired global hook variable and filtering by the template's keys.

e.g.

#+begin_src emacs-lisp :lexical t
(defun +example-template-hook ()
 (when (eq (org-capture-get :key t) "e")
   (message "hook run")))

(add-hook 'org-capture-mode-hook #'+example-template-hook)

(let ((org-capture-templates '("e" "example" (file "") "")))
 (org-capture nil "e"))
#+end_src

The hook has to be maintained separately from the template 
declaration.
The criteria to determine the selected template is baked into the 
hook function.
This is fragile (change the binding for the template and you must 
update the hook function),

mixes concerns, and makes templates harder to share.

Contrast the above with the following syntax enabled by the 
attached patch: 


#+begin_src emacs-lisp :lexical t
(let ((org-capture-templates
  '(("t" "test" plain (file "/tmp/test.org")
 "test %?"
 :hook ((lambda () (insert "mode-hook\n")))
 :before-finalize ((lambda () (insert 
 "before-finalize\n")))
 ;; Only a message because this happens outside the 
 context

 ;; of the capture buffer.
 :after-finalize ((lambda () (message "after-finalize")))
 :prepare-finalize ((lambda () (insert 
 "prepare-finalize\n")))

 (org-capture nil "t"))
#+end_src

These template-specific hook functions run prior to their global 
counterparts.


Ihor, an implementation note: I have not used `run-hooks' with 
these because they have no associated symbol.

The functions are lists stored directly on `org-capture-plist'.

[1]: https://github.com/progfolio/doct



[PATCH] ob-core.el: Fix docstring single quotes [9.6 (9.6-gc66bdb @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-07-13 Thread No Wayman


Emacs 29's byte compiler warns about single quotes in docstring 
examples.



Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.34, cairo version 1.17.6)

of 2022-06-28
Package: Org mode version 9.6 (9.6-gc66bdb @ 
/home/n/.emacs.d/elpaca/builds/org/)


>From 6bf0e44615d174281452df57260b0ff591539ffb Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 14 Jul 2022 00:37:26 -0400
Subject: [PATCH] * lisp/ob-core.el: Fix docstring quote usage

(org-babel-default-header-args): escape syntactic single quote in docstring
(org-babel-result-to-file): escape syntactic single quote in docstring
---
 lisp/ob-core.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f1a98b7d0..ac9af5d24 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -487,7 +487,7 @@ evaluates to a string.
 A closure is evaluated when the source block is being
 evaluated (e.g. during execution or export), with point at the
 source block.  It is not possible to use an arbitrary function
-symbol (e.g. 'some-func), since org uses lexical binding.  To
+symbol (e.g. \\='some-func), since org uses lexical binding.  To
 achieve the same functionality, call the function within a
 closure (e.g. (lambda () (some-func))).
 
@@ -514,7 +514,7 @@ functionality is also supported for default header arguments by
 providing the header argument multiple times in the alist.  For
 example:
 
-'((:var . \"foo=\\\"bar\\\"\")
+\\='((:var . \"foo=\\\"bar\\\"\")
   (:var . \"bar=\\\"foo\\\"\"))")
 
 (put 'org-babel-default-header-args 'safe-local-variable
@@ -2627,7 +2627,7 @@ in the buffer."
 If the `default-directory' is different from the containing
 file's directory then expand relative links.
 
-If the optional TYPE is passed as 'attachment` and the path is a
+If the optional TYPE is passed as \\='attachment and the path is a
 descendant of the DEFAULT-DIRECTORY, the generated link will be
 specified as an an \"attachment:\" style link."
   (when (stringp result)
-- 
2.37.0



Re: [BUG] [PATCH] Ensure org-babel-temporary-stable-directory bound-and-true [9.6 (9.6-g713598 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-07-05 Thread No Wayman


Sorry, that symbol should not be quoted in the patch. 
Amended attached.


>From 87c400fa8cb3ffa9b4fcf1f958feab4506194a81 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 5 Jul 2022 19:03:44 -0400
Subject: [PATCH] lisp/ob-core.el: fix file-exists-p error

* ob-core.el (org-babel-remove-temporary-stable-directory):
Ensure org-babel-temporary-stable-directory is non-nil before checking
if it is on disk. Otherwise an error is thrown during kill-emacs-hook.
---
 lisp/ob-core.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 6c379c12..a97c0eba 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3264,7 +3264,7 @@ constructed like the following: PREFIXDATAhashSUFFIX."
 
 (defun org-babel-remove-temporary-stable-directory ()
   "Remove `org-babel-temporary-stable-directory' and on Emacs shutdown."
-  (when (and (boundp 'org-babel-temporary-stable-directory)
+  (when (and (bound-and-true-p org-babel-temporary-stable-directory)
 	 (file-exists-p org-babel-temporary-stable-directory))
 (let ((org-babel-temporary-directory
org-babel-temporary-stable-directory))
-- 
2.37.0



[BUG] [PATCH] Ensure org-babel-temporary-stable-directory bound-and-true [9.6 (9.6-g713598 @ /home/n/.emacs.d/elpaca/builds/org/)]

2022-07-05 Thread No Wayman


Updated today and noticed an error when killing Emacs.
See attached.

>From fa822d45559267de6af31f9d34be4266af602d03 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 5 Jul 2022 19:03:44 -0400
Subject: [PATCH] lisp/ob-core.el: fix file-exists-p error

* ob-core.el (org-babel-remove-temporary-stable-directory):
Ensure org-babel-temporary-stable-directory is non-nil before checking
if it is on disk. Otherwise an error is thrown during kill-emacs-hook.
---
 lisp/ob-core.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 6c379c121..22175a911 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3264,7 +3264,7 @@ constructed like the following: PREFIXDATAhashSUFFIX."
 
 (defun org-babel-remove-temporary-stable-directory ()
   "Remove `org-babel-temporary-stable-directory' and on Emacs shutdown."
-  (when (and (boundp 'org-babel-temporary-stable-directory)
+  (when (and (bound-and-true-p 'org-babel-temporary-stable-directory)
 	 (file-exists-p org-babel-temporary-stable-directory))
 (let ((org-babel-temporary-directory
org-babel-temporary-stable-directory))
-- 
2.37.0



Re: [RFC] DOCT: Declarative Org Capture Templates (easier template syntax)

2022-03-23 Thread No Wayman



Nicolas Goaziou  writes:

The fact that we need a tool like "doct" to write templates in a 
compact
form may be a sign that the data type is not good enough. 
Actually it

sounds like a failure somehow.


Agreed. That's why I wrote doct in the first place.
As others have expressed, there's far too many elements required 
to ask the user to recall what position they fall in.
A plist is better in that the keys describe their values and can 
be specified in any order.
This also makes it easier for people to share templates, because 
they can actually tell what the template is intended to do by 
looking at it.


Another thing that is confusing about "capture templates" is that 
the words "template" and "entry" are overloaded in the 
documentation. From the docstring of org-capture-templates:



Templates for the creation of new entries.
Each entry is a list with the following items:


So org-capture-templates is a "list of entries which create new 
entries via templates"?
Confusing for me now, let alone the first time I tried to write my 
own templates.


doct also does more to check the validity of the template's form 
when it is defined.
I prioritized this because the worst time to figure out your 
template is malformed is when you go to capture something in the 
middle of another, unrelated task.


Should templates definition be more compact out of the box? 
Could the
data type be made more powerful to permit more complex templates 
without
relying on doct? IOW, can a tool such a doct be made transparent 
to the

user?


My initial idea for integrating doct with Org was to just provide 
a user option, e.g. org-capture-use-doct-syntax.
Then the only thing needed would be a conditional in 
org-capture-upgrade-templates which would delegate to doct when 
said user option is non-nil. 
That would allow those who are interested in using the feature to 
opt-in without breaking existing templates. Then as support for 
older syntax is dropped, (if ever? it looks like 
`org-capture-upgrade-templates' dates back to early 2017, and I 
think it makes sense to retain such a path) those features could 
be moved into org-capture.


I'm open to bringing doct's features into Org mode, but I'd prefer 
it not to be spread out over another two years.




Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)

2022-02-09 Thread No Wayman



Ihor Radchenko  writes:


No Wayman  writes:

I've implemented what you're proposing here (and much more) in 
a 
package you may find useful a couple years ago. I pitched 
adopting 
some of the ideas into org-mode proper and was willing to do 
the 
work. My proposal was met with enthusiastic silence:


https://www.github.com/progfolio/doct


I think Nicolas gave some reasonable comments, didn't he? He 
suggested
to incorporate some of the ideas into the existing Org mode 
code.


https://orgmode.org/list/87wo66t8i7@gmail.com

Best,
Ihor


I believe you're referring to:

https://list.orgmode.org/87y2qlgq33@nicolasgoaziou.fr/

He had some reasonable questions about the design, but said he 
only uses very basic capture templates, and could not comment 
beyond that on the design. The hope was that people who use more 
of org-capture's features would chime in. That didn't happen.


Of course doct's features could be added to org-capture in a 
piecemeal fashion, but I'm not too keen on contributing anything 
non-trivial to Org these days. Too much back and forth coupled 
with discussion that can stall due to lack of interest. 
e.g.


https://list.orgmode.org/87h7e6dluc@gmail.com/
https://list.orgmode.org/87tuit73ij@gmail.com/






Re: [PATCH] lisp/org-capture.el: Add hook & hook options to org-capture (Valentin Herrmann)

2022-02-08 Thread No Wayman



I've implemented what you're proposing here (and much more) in a 
package you may find useful a couple years ago. I pitched adopting 
some of the ideas into org-mode proper and was willing to do the 
work. My proposal was met with enthusiastic silence:


https://www.github.com/progfolio/doct


- :prependNormally newly captured information will 
be appended at
- the target location (last child, last 
table line,
- last list item...).  Setting this property 
will

- change that.
+ :prepend   Normally newly captured information 
will be appended at
+the target location (last child, last 
table line,
+last list item...).  Setting this 
property will

+change that.


Are the white space changes to unrelated properties necessary?
  

+(defcustom org-capture-before-view-hook nil
+  "Hook that is run right after the capture buffer is made 
current.

+The buffer is still narrowed."
+  :group 'org-capture
+  :version "28.1"
+  :type 'hook)
+


This functionality is already provided by `org-capture-mode-hook'. 
Instead of introducing another hook, that can be utilized. An 
illustration using doct's :hook keyword which runs functions 
during org-capture-mode-hook:


Yodel[1] Report 2022-02-08 14:16:58
===

--8<---cut here---start->8---
(yodel
 :save "org-capture-mode-hook-example"
 :packages*
 doct
 :post*
 (require 'org-capture)
 (require 'doct)
 (let ((org-capture-templates
   (doct
`("test"
  :keys "t"
  :file "/tmp/test.org"
  :template "* test"
  :immediate-finish t
  :hook (lambda nil
(message "%S narrowed?: %S"
 (current-buffer)
 (buffer-narrowed-p)))
   (org-capture nil "t")))
--8<---cut here---end--->8---

STDOUT
==

Loading 
/tmp/org-capture-mode-hook-example/straight-bootstrap-snippet.el 
(source)...

Clipboard pasted as level 1 subtree
# narrowed?: t


Environment
===

- emacs version: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, 
 GTK+ Version 3.24.31, cairo version 1.17.4)

of 2022-01-13
- system type: gnu/linux

Packages


- doct 
 https://github.com/progfolio/doct/commit/9ed9b8c7f7e2ea2d2fb739d65ae4626a1cf16b9f


[1] https://www.github.com/progfolio/yodel


+
+(run-hooks 'org-capture-before-view-hook)
+(if-let ((bvh (org-capture-get :before-view-hook)))
+(funcall bvh))


This pattern implies that functions added via template keywords 
will be run after the equivalent global hooks. That should be 
documented. This pattern could be improved by let-binding each 
hook and adding the templates functions. e.g.



(let ((org-capture-mode-hook
  (append org-capture-mode-hook (org-capture-get :hook t
 (run-hooks 'org-capture-mode-hook))


Note the use of the non-nil LOCAL argument in org-capture-get.
You want to ensure you're accessing the correct plist in the case 
of overlapping capture processes.


   ;; FIXME: This does not do the right thing, we need to remove 
   the

   ;; new stuff by hand it is easy: undo, then kill the buffer
-  (let ((org-note-abort t)
-   (org-capture-before-finalize-hook nil))
+  (let ((org-note-abort t))
 (org-capture-finalize)))
 
 (defun org-capture-goto-last-stored ()


Why was org-capture-before-finalize-hook bound to nil here and 
what is the reason for changing that?






Re: bug#53393: 29.0.50; org mode timestamp C-c C-c not updating day of week

2022-01-21 Thread No Wayman



It looks like the correction of the day name in timestamps is 
hardcoded in `org-ctrl-c-ctrl-c':


	((or `timestamp (and `planning (guard (org-at-timestamp-p 
'lax

 (org-timestamp-change 0 'day))



`org-clock-update-time-maybe' uses a regexp to match the start and 
end times and hands those off to `org-parse-time-string' which 
does not consider the day name.







Re: bug#53393: 29.0.50; org mode timestamp C-c C-c not updating day of week

2022-01-21 Thread No Wayman




From: "Bruce E. Robertson" 
Date: Tue, 18 Jan 2022 10:36:22 -0800


emacs -Q test.org
cursor to "CLOCK:" line, C-c C-c
total time updates but day of week does not change
contents of test.org
--
* heading
:LOGBOOK:
CLOCK: [2022-01-17 Tue 10:29]--[2022-01-19 Tue 10:29] => 48:00
:END:
--
typing C-c C-c does update total log time for line and recently 
did

update the day of the week but no long does


Confirmed:

Yodel[1] Report 2022-01-22 00:19:18
===

--8<---cut here---start->8---
(yodel
 :save "org-bug"
 :packages* org
 :post*
 (yodel-file "org-bug-test"
   :point "|"
   :with*
   "* heading"
   " :LOGBOOK:"
   " CLOCK: | [2022-01-17 Tue 10:29]--[2022-01-19 Tue 10:29]"
   " :END:" :then*
   (require 'org-clock)
   (org-clock-update-time-maybe)
   (print (buffer-string
--8<---cut here---end--->8---

STDOUT
==


Loading /tmp/org-bug/straight-bootstrap-snippet.el (source)...



"* heading
 :LOGBOOK:
 CLOCK:  [2022-01-17 Tue 10:29]--[2022-01-19 Tue 10:29] => 48:00
 :END:"


Environment
===

- emacs version: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, 
 GTK+ Version 3.24.31, cairo version 1.17.4)

of 2022-01-13
- system type: gnu/linux

Packages


- org 
 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=846226a202619866fe80667d13e9d5a105bd1eef


[1] https://www.github.com/progfolio/yodel



[BUG] org-element-cache-map calls native-comp-available-p without checking if it is bound first [9.5 (9.5-gf5faff @ /home/n/.emacs.d/straight/build/org/)]

2021-10-29 Thread No Wayman



See: 
https://www.reddit.com/r/emacs/comments/qil2qh/symbols_function_definition_is_void/



For context:


(and (symbolp func)
(native-comp-available-p)
(fboundp 'subr-native-elisp-p)


The check could be wrapped in a function to prevent this in the 
future. e.g.


(defun org-native-comp-available-p ()
  (and (fboundp 'native-comp-available-p) 
  (native-comp-available-p)))




Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]

2021-10-09 Thread No Wayman



Your analysis is correct. I looked into this a couple days ago.
See the following message for an explanation and a patch (testing 
appreciated):


https://list.orgmode.org/87zgrmc2rg@gmail.com/T/#m9888bc09d77d7bba70ba99671aca72446c4d41b9





Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]

2021-10-05 Thread No Wayman

Confirmed with the following, simpler, test case:

Yodel[1] Report 2021-10-05 22:07:33
===

--8<---cut here---start->8---
(yodel
 :user-dir "org-save-all-org-buffers"
 :packages* org
 :formatter yodel-format-as-mailing-list-message
 :post*
 (yodel-file "./test.org"
   :with*
   "#+startup: overview
* A
** B"
   :then*
   (require 'org-element)
   (defun +org-visible nil
 (org-element-interpret-data
  (org-element-parse-buffer nil 'visible-only)))
   (message "%s
%s" "Before `org-save-all-org-buffers':"
(+org-visible))
   (set-buffer-modified-p t)
   (org-save-all-org-buffers)
   (message "%s
%s" "After `org-save-all-org-buffers':"
(+org-visible
--8<---cut here---end--->8---

STDOUT
==

Loading 
/tmp/org-save-all-org-buffers/straight-bootstrap-snippet.el 
(source)...

Before `org-save-all-org-buffers':



#+startup: overview
* A
** B



Saving all Org buffers...



Saving all Org buffers... done
After `org-save-all-org-buffers':



#+startup: overview
* A


Environment
===

- emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, 
 X toolkit, cairo version 1.17.4, Xaw3d scroll bars)

of 2021-09-29
- system type: gnu/linux

Packages


- org 
 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=cc2490a7061955395c4f5a1a23a088044554a2f7


The behavior of `save-some-buffers' PRED argument changed 
recently:


https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a9ad3d477441feefa3bf6107d58281cb64e0e78a

If the PRED returns a function, that function is called.
Since `derived-mode-p' returns the symbol `org-mode', Org is being 
reloaded in modified buffers.
That's what is causing the visibility change. 
This could also have other undesirable behavior such as running 
the mode hook, resetting buffer-local variables, etc.


The attached patch ensures we're returning a boolean from the PRED 
function.

Tested with:

Yodel[1] Report 2021-10-05 22:07:33
===

--8<---cut here---start->8---
(yodel
 :user-dir "org-save-all-org-buffers.patch"
 :packages*
 (org :host github :repo "progfolio/org-mode" :branch 
 "fix/org-save-all-org-buffers")

 :formatter yodel-format-as-mailing-list-message
 :post*
 (yodel-file "./test.org"
   :with*
   "#+startup: overview
* A
** B"
   :then*
   (require 'org-element)
   (defun +org-visible nil
 (org-element-interpret-data
  (org-element-parse-buffer nil 'visible-only)))
   (message "%s
%s" "Before `org-save-all-org-buffers':"
(+org-visible))
   (set-buffer-modified-p t)
   (org-save-all-org-buffers)
   (message "%s
%s" "After `org-save-all-org-buffers':"
(+org-visible
--8<---cut here---end--->8---

STDOUT
==

Loading 
/tmp/org-save-all-org-buffers.patch/straight-bootstrap-snippet.el 
(source)...

Bootstrapping straight.el...
Bootstrapping straight.el...done
Rebuilding all packages due to build cache schema change
Looking for gnu-elpa-mirror recipe → Cloning melpa...
Looking for gnu-elpa-mirror recipe → Cloning melpa...done
Looking for emacsmirror-mirror recipe → Cloning 
gnu-elpa-mirror...
Looking for emacsmirror-mirror recipe → Cloning 
gnu-elpa-mirror...done

Looking for emacsmirror-mirror recipe → Cloning el-get...
Looking for emacsmirror-mirror recipe → Cloning el-get...done
Looking for straight recipe → Cloning emacsmirror-mirror...
Looking for straight recipe → Cloning emacsmirror-mirror...done
Building straight...
Building straight...done
Cloning org...
Cloning org...done
Building org...
Building org...done



Before `org-save-all-org-buffers':



#+startup: overview
* A
** B



Saving all Org buffers...



Saving all Org buffers... done
After `org-save-all-org-buffers':



#+startup: overview
* A
** B


Environment
===

- emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, 
 X toolkit, cairo version 1.17.4, Xaw3d scroll bars)

of 2021-09-29
- system type: gnu/linux

Packages


- org 
 https://github.com/progfolio/org-mode/commit/f1fc22f861ca9610ad4f1e1227660712b46337e4



[1] https://www.github.com/progfolio/yodel

>From f1fc22f861ca9610ad4f1e1227660712b46337e4 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 5 Oct 2021 21:07:01 -0400
Subject: [PATCH] lisp/org.el: (org-save-all-org-buffers): Prevent `org-mode'
 reload

* lisp/org.el: (org-save-all-org-buffers): Ensure `save-some-buffers' PRED returns boolean.

As of this upstream commit:

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a9ad3d477441feefa3bf6107d58281cb64e0e78a

`save-some-buffers' will call its PRED argument if it returns a function.
Since (derived-mode-p 'org-mode) returns the symbol org-mode,
and org-mode is a function, org-mode is reloaded in modified Org
buffers when calling `org-save-all-org-buffers'. Among other
undesirable behavior, this will cause the buffer's visibility to be
reset to 

[BUG] [PATCH] org-archive.el: Fix checkdoc warnings [9.5 (9.5-g477f05 @ /home/n/.emacs.d/straight/build/org/)]

2021-10-03 Thread No Wayman


See Attached.

>From e995d2ed668edd9f29e9a8aeaf39bb0eb039e856 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 30 Sep 2021 16:07:15 -0400
Subject: [PATCH] org-archive.el: Fix checkdoc warnings

* org-archive.el: Fix checkdoc warnings.
---
 lisp/org-archive.el | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 0943869a8..db8c02049 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -148,7 +148,7 @@ archive location, but not yet deleted from the original file.")
 
 ;;;###autoload
 (defun org-add-archive-files (files)
-  "Splice the archive files into the list of files.
+  "Splice the archive files into the list of FILES.
 This implies visiting all these files and finding out what the
 archive file is."
   (org-uniquify
@@ -580,8 +580,9 @@ don't move trees, but mark them with the ARCHIVE tag."
 ;;;###autoload
 (defun org-toggle-archive-tag ( find-done)
   "Toggle the archive tag for the current headline.
-With prefix ARG, check all children of current headline and offer tagging
-the children that do not contain any open TODO items."
+When called interactively with \\[universal-argument], or FIND-DONE is
+non-nil, check current headline's children and offer tagging for
+children which do not contain any open TODO items."
   (interactive "P")
   (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
   (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
-- 
2.33.0



[PATCH] org-attach: Fix checkdoc warnings

2021-10-02 Thread No Wayman


See attached.

>From 477f05274d2de75fc6d4761e6e6089f46e024f4e Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 30 Sep 2021 16:07:15 -0400
Subject: [PATCH] org-attach.el: Fix checkdoc warnings

* org-attach.el: Fix checkdoc warnings.
---
 lisp/org-attach.el | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 75db69c9c..e62432dca 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -123,8 +123,8 @@ lns   create a symbol link.  Note that this is not supported
 
 Enabling inheritance for `org-attach' implies two things.  First,
 that attachment links will look through all parent headings until
-it finds the linked attachment.  Second, that running org-attach
-inside a node without attachments will make org-attach operate on
+it finds the linked attachment.  Second, that running `org-attach'
+inside a node without attachments will make `org-attach' operate on
 the first parent heading it finds with an attachment.
 
 Selective means to respect the inheritance setting in
@@ -335,7 +335,7 @@ will be invoked to access the directory for the current entry.
 Note that this method returns the directory as declared by ID or
 DIR even if the directory doesn't exist in the filesystem.
 
-If CREATE-IF-NOT-EXIST-P is non-nil, `org-attach-dir-get-create'
+If CREATE-IF-NOT-EXISTS-P is non-nil, `org-attach-dir-get-create'
 is run.  If NO-FS-CHECK is non-nil, the function returns the path
 to the attachment even if it has not yet been initialized in the
 filesystem.
@@ -378,7 +378,7 @@ If the attachment by some reason cannot be created an error will be raised."
 	 ((or (eq org-attach-preferred-new-method 'dir) (eq answer ?2))
 	  (setq attach-dir (org-attach-set-directory)))
 	 ((eq org-attach-preferred-new-method 'nil)
-	  (error "No existing directory. DIR or ID property has to be explicitly created")
+	  (error "No existing directory.  DIR or ID property has to be explicitly created")
 (unless attach-dir
   (error "No attachment directory is associated with the current node"))
 (unless (file-directory-p attach-dir)
@@ -483,6 +483,7 @@ DIR-property exists (that is different from the unset one)."
   (org-attach-tag 'off))
 
 (defun org-attach-url (url)
+  "Attach URL."
   (interactive "MURL of the file to attach: \n")
   (let ((org-attach-method 'url))
 (org-attach-attach url)))
@@ -503,7 +504,7 @@ if it would overwrite an existing filename."
 
 (defun org-attach-attach (file  visit-dir method)
   "Move/copy/link FILE into the attachment directory of the current outline node.
-If VISIT-DIR is non-nil, visit the directory with dired.
+If VISIT-DIR is non-nil, visit the directory with `dired'.
 METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from
 `org-attach-method'."
   (interactive
@@ -574,27 +575,27 @@ The attachment is created as an Emacs buffer."
 (find-file (expand-file-name file attach-dir))
 (message "New attachment %s" file)))
 
-(defun org-attach-delete-one ( file)
-  "Delete a single attachment."
+(defun org-attach-delete-one ( attachment)
+  "Delete a single ATTACHMENT."
   (interactive)
   (let* ((attach-dir (org-attach-dir))
 	 (files (org-attach-file-list attach-dir))
-	 (file (or file
+	 (attachment (or attachment
 		   (completing-read
 		"Delete attachment: "
 		(mapcar (lambda (f)
 			  (list (file-name-nondirectory f)))
 			files)
-(setq file (expand-file-name file attach-dir))
-(unless (file-exists-p file)
-  (error "No such attachment: %s" file))
-(delete-file file)
+(setq attachment (expand-file-name attachment attach-dir))
+(unless (file-exists-p attachment)
+  (error "No such attachment: %s" attachment))
+(delete-file attachment)
 (run-hook-with-args 'org-attach-after-change-hook attach-dir)))
 
 (defun org-attach-delete-all ( force)
   "Delete all attachments from the current outline node.
 This actually deletes the entire attachment directory.
-A safer way is to open the directory in dired and delete from there.
+A safer way is to open the directory in `dired' and delete from there.
 
 With prefix argument FORCE, directory will be recursively deleted
 with no prompts."
@@ -629,12 +630,12 @@ empty attachment directories."
  t))
   (delete-directory attach-dir))
 
-(defun org-attach-file-list (dir)
-  "Return a list of files in the attachment directory.
+(defun org-attach-file-list (directory)
+  "Return a list of files in the attachment DIRECTORY.
 This ignores files ending in \"~\"."
   (delq nil
 	(mapcar (lambda (x) (if (string-match "^\\.\\.?\\'" x) nil x))
-		(directory-files dir nil "[^~]\\'"
+		(directory-files directory nil "[^~]\\'"
 
 (defun org-attach-reveal ()
   "Show the attachment directory of the current outline node.
@@ -645,7 +646,7 @@ exist yet.  Respects `org-attach-preferred-new-method'."
   (org-open-file 

Re: [BUG] [PATCH] org-src.el: Fix checkdoc warnings [9.5 (9.5-g59cb39 @ /home/n/.emacs.d/straight/build/org/)]

2021-10-02 Thread No Wayman


Bastien  writes:

Thanks -- it does not apply against the main branch, can you 
rebase

and resend it?


Certainly. See attached.

>From 4971ceb26a1fb138f4eeddc1a569b5c4dd3f1859 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 30 Sep 2021 16:07:15 -0400
Subject: [PATCH] org-src.el: Fix checkdoc warnings

* org-src.el: Fix checkdoc warnings.
---
 lisp/org-src.el | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 8d02cf434..23e196438 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -37,6 +37,7 @@
 (require 'org-compat)
 (require 'org-keys)
 
+(declare-function org--get-expected-indentation "org" (element contentsp))
 (declare-function org-mode "org" ())
 (declare-function org--get-expected-indentation "org" (element contentsp))
 (declare-function org-element-at-point "org-element" ())
@@ -240,8 +241,7 @@ green, respectability.
   :package-version '(Org . "9.0"))
 
 (defcustom org-src-tab-acts-natively t
-  "If non-nil, the effect of TAB in a code block is as if it were
-issued in the language major mode buffer."
+  "If non-nil, TAB uses the language's major-mode binding in code blocks."
   :type 'boolean
   :package-version '(Org . "9.4")
   :group 'org-babel)
@@ -304,7 +304,8 @@ is 0.")
 (put 'org-src--preserve-blank-line 'permanent-local t)
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
-  "Construct the buffer name for a source editing buffer."
+  "Construct the buffer name for a source editing buffer.
+Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
   (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
 
 (defun org-src--edit-buffer (beg end)
@@ -614,7 +615,7 @@ Leave point in edit buffer."
 ;;; Fontification of source blocks
 
 (defun org-src-font-lock-fontify-block (lang start end)
-  "Fontify code block.
+  "Fontify code block between START and END using LANG's syntax.
 This function is called by Emacs' automatic fontification, as long
 as `org-src-fontify-natively' is non-nil."
   (let ((lang-mode (org-src-get-lang-mode lang)))
@@ -760,7 +761,9 @@ See also `org-src-mode-hook'."
 ;;; Babel related functions
 
 (defun org-src-associate-babel-session (info)
-  "Associate edit buffer with comint session."
+  "Associate edit buffer with comint session.
+INFO should be a list simlar in format to the return value of
+`org-babel-get-src-block-info'."
   (interactive)
   (let ((session (cdr (assq :session (nth 2 info)
 (and session (not (string= session "none"))
@@ -770,6 +773,7 @@ See also `org-src-mode-hook'."
(and (fboundp f) (funcall f session))
 
 (defun org-src-babel-configure-edit-buffer ()
+  "Configure src editing buffer."
   (when org-src--babel-info
 (org-src-associate-babel-session org-src--babel-info)))
 
@@ -842,6 +846,7 @@ Raise an error when current buffer is not a source editing buffer."
   org-src--source-type)
 
 (defun org-src-switch-to-buffer (buffer context)
+  "Switch to BUFFER considering CONTEXT and `org-src-window-setup'."
   (pcase org-src-window-setup
 (`plain
  (when (eq context 'exit) (quit-restore-window))
@@ -1204,11 +1209,12 @@ the area in the Org mode buffer."
   (interactive)
   (let (org-src--allow-write-back) (org-edit-src-exit)))
 
-(defun org-edit-src-continue (e)
+(defun org-edit-src-continue (event)
   "Unconditionally return to buffer editing area under point.
-Throw an error if there is no such buffer."
+Throw an error if there is no such buffer.
+EVENT is passed to `mouse-set-point'."
   (interactive "e")
-  (mouse-set-point e)
+  (mouse-set-point event)
   (let ((buf (get-char-property (point) 'edit-buffer)))
 (if buf (org-src-switch-to-buffer buf 'continue)
   (user-error "No sub-editing buffer for area at point"
-- 
2.33.0



Re: [BUG] [PATCH] org-src.el: Fix checkdoc warnings [9.5 (9.5-g59cb39 @ /home/n/.emacs.d/straight/build/org/)]

2021-10-02 Thread No Wayman


Bastien  writes:


Hi,

No Wayman  writes:


The attached patch


I don't see a patch, can you resend it?


Apologies. Resent.

>From e5d1c6cc231363e20b378e082236af44ac717ccc Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 30 Sep 2021 16:07:15 -0400
Subject: [PATCH] org-src.el: Fix checkdoc warnings

* org-src.el: Fix checkdoc warnings.
---
 lisp/org-src.el | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 0e16e236b..8f1e68d90 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -37,6 +37,7 @@
 (require 'org-compat)
 (require 'org-keys)
 
+(declare-function org--get-expected-indentation "org" (element contentsp))
 (declare-function org-mode "org" ())
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-class "org-element" (datum  parent))
@@ -239,8 +240,7 @@ green, respectability.
   :package-version '(Org . "9.0"))
 
 (defcustom org-src-tab-acts-natively t
-  "If non-nil, the effect of TAB in a code block is as if it were
-issued in the language major mode buffer."
+  "If non-nil, TAB uses the language's major-mode binding in code blocks."
   :type 'boolean
   :package-version '(Org . "9.4")
   :group 'org-babel)
@@ -303,7 +303,8 @@ is 0.")
 (put 'org-src--preserve-blank-line 'permanent-local t)
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
-  "Construct the buffer name for a source editing buffer."
+  "Construct the buffer name for a source editing buffer.
+Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
   (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
 
 (defun org-src--edit-buffer (beg end)
@@ -613,7 +614,7 @@ Leave point in edit buffer."
 ;;; Fontification of source blocks
 
 (defun org-src-font-lock-fontify-block (lang start end)
-  "Fontify code block.
+  "Fontify code block between START and END using LANG's syntax.
 This function is called by Emacs' automatic fontification, as long
 as `org-src-fontify-natively' is non-nil."
   (let ((lang-mode (org-src-get-lang-mode lang)))
@@ -759,7 +760,9 @@ See also `org-src-mode-hook'."
 ;;; Babel related functions
 
 (defun org-src-associate-babel-session (info)
-  "Associate edit buffer with comint session."
+  "Associate edit buffer with comint session.
+INFO should be a list simlar in format to the return value of
+`org-babel-get-src-block-info'."
   (interactive)
   (let ((session (cdr (assq :session (nth 2 info)
 (and session (not (string= session "none"))
@@ -769,6 +772,7 @@ See also `org-src-mode-hook'."
(and (fboundp f) (funcall f session))
 
 (defun org-src-babel-configure-edit-buffer ()
+  "Configure src editing buffer."
   (when org-src--babel-info
 (org-src-associate-babel-session org-src--babel-info)))
 
@@ -841,6 +845,7 @@ Raise an error when current buffer is not a source editing buffer."
   org-src--source-type)
 
 (defun org-src-switch-to-buffer (buffer context)
+  "Switch to BUFFER considering CONTEXT and `org-src-window-setup'."
   (pcase org-src-window-setup
 (`plain
  (when (eq context 'exit) (quit-restore-window))
@@ -1203,11 +1208,12 @@ the area in the Org mode buffer."
   (interactive)
   (let (org-src--allow-write-back) (org-edit-src-exit)))
 
-(defun org-edit-src-continue (e)
+(defun org-edit-src-continue (event)
   "Unconditionally return to buffer editing area under point.
-Throw an error if there is no such buffer."
+Throw an error if there is no such buffer.
+EVENT is passed to `mouse-set-point'."
   (interactive "e")
-  (mouse-set-point e)
+  (mouse-set-point event)
   (let ((buf (get-char-property (point) 'edit-buffer)))
 (if buf (org-src-switch-to-buffer buf 'continue)
   (user-error "No sub-editing buffer for area at point"
-- 
2.33.0



Re: Visibility cycling with inline tasks 2

2021-10-01 Thread No Wayman



Ihor Radchenko  writes:

Your patch will fail with the following counterexample (when 
there is a

subheading containing an inlinetask inside current heading):


I wasn't really sure what the intended behavior is, but that makes 
sense.



I propose an alternative patch. See the attached.


Haven't installed it, but at a glance it stands to reason.



Re: Visibility cycling with inline tasks 2

2021-09-30 Thread No Wayman


I can confirm the issue you've outlined on latest 'main'.
To me it looks like the problem is in `org-inline-hide-tasks'.
I don't use inline tasks, so I'm not sure what the exact expected 
behavior is,
but that function uses a `while' during `org-cycle-hook' to 
iterate through all of the headings.
My intuition is that it's overshooting a boundary and toggling 
visibility on more than it should.


Does the attached patch behave more in line with what you expect? 

>From 04ed84c36a4cc04838b5b75e18858996af125f77 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 30 Sep 2021 23:31:50 -0400
Subject: [PATCH] org-inlinetask.el: Limit children visibility toggle to
 subtree

* org-inlinetask: (org-inlinetask-toggle-visibility): Limit toggling
to subtree.

Not sure if this is correct behavior or not. Just a suggestion.
---
 lisp/org-inlinetask.el | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el
index 3379a2e46..3bdc03ae4 100644
--- a/lisp/org-inlinetask.el
+++ b/lisp/org-inlinetask.el
@@ -334,11 +334,13 @@ This function is meant to be used in `org-cycle-hook'."
 	   (org-inlinetask-goto-end)
 (`children
  (save-excursion
-   (while
-	   (or (org-inlinetask-at-task-p)
-	   (and (outline-next-heading) (org-inlinetask-at-task-p)))
-	 (org-inlinetask-toggle-visibility)
-	 (org-inlinetask-goto-end))
+   (save-restriction
+ (org-narrow-to-subtree)
+ (while
+ (or (org-inlinetask-at-task-p)
+ (and (outline-next-heading) (org-inlinetask-at-task-p)))
+   (org-inlinetask-toggle-visibility)
+   (org-inlinetask-goto-end)))
 
 (defun org-inlinetask-remove-END-maybe ()
   "Remove an END line when present."
-- 
2.33.0



[BUG] [PATCH] org-src.el: Fix checkdoc warnings [9.5 (9.5-g59cb39 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-30 Thread No Wayman



The attached patch addresses org-src.el's checkdoc warnings spare 
the following (IMO spurious) warnings:


 >158 0 notee-f-cLisp symbol ‘split-window-below’ 
 >should appear in quotes


split-window-below is a value used in org-src-window-setup (along 
with split-window-right, other-window, other-frame), but these 
values do not necessarily map onto their functions. e.g. 
other-window displays via `switch-to-buffer-other-window'.


 >80050  notee-f-cKeycode C-c embedded in doc string. 
 >Use \\ & \\[function] instead


The embedded keycodes in `org-src-do-key-sequence-at-code-block' 
are just for the sake of example.




[BUG] [PATCH] org-id: Fix checkdoc warnings [9.5 (9.5-g9364b2 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-28 Thread No Wayman


See attached.

>From 7fbdca5dc81dfe0dd542ed0e2352d3334b16fd7f Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Mon, 27 Sep 2021 20:35:12 -0400
Subject: [PATCH] org-id: Fix checkdoc warnings

* org-id: Fix checkdoc warnings.
---
 lisp/org-id.el | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/org-id.el b/lisp/org-id.el
index 3725ff9e5..56783d108 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -419,15 +419,15 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
 	(substring rnd 18 20)
 	(substring rnd 20 32
 
-(defun org-id-int-to-b36-one-digit (i)
-  "Turn an integer between 0 and 61 into a single character 0..9, A..Z, a..z."
+(defun org-id-int-to-b36-one-digit (integer)
+  "Convert INTEGER between 0 and 61 into a single character 0..9, A..Z, a..z."
   (cond
-   ((< i 10) (+ ?0 i))
-   ((< i 36) (+ ?a i -10))
+   ((< integer 10) (+ ?0 integer))
+   ((< integer 36) (+ ?a integer -10))
(t (error "Larger that 35"
 
 (defun org-id-b36-to-int-one-digit (i)
-  "Turn a character 0..9, A..Z, a..z into a number 0..61.
+  "Convert character 0..9, A..Z, a..z into a number 0..61.
 The input I may be a character, or a single-letter string."
   (and (stringp i) (setq i (string-to-char i)))
   (cond
@@ -435,9 +435,11 @@ The input I may be a character, or a single-letter string."
((and (>= i ?a) (<= i ?z)) (+ (- i ?a) 10))
(t (error "Invalid b36 letter"
 
-(defun org-id-int-to-b36 (i  length)
-  "Convert an integer to a base-36 number represented as a string."
-  (let ((s ""))
+(defun org-id-int-to-b36 (integer  length)
+  "Convert an INTEGER to a base-36 number represented as a string.
+The returned string is padded with leading zeros to LENGTH if necessary."
+  (let ((s "")
+(i integer))
 (while (> i 0)
   (setq s (concat (char-to-string
 		   (org-id-int-to-b36-one-digit (mod i 36))) s)
@@ -447,11 +449,11 @@ The input I may be a character, or a single-letter string."
 	(setq s (concat (make-string (- length (length s)) ?0) s)))
 s))
 
-(defun org-id-b36-to-int (s)
-  "Convert a base-36 string into the corresponding integer."
+(defun org-id-b36-to-int (string)
+  "Convert a base-36 STRING into the corresponding integer."
   (let ((r 0))
 (mapc (lambda (i) (setq r (+ (* r 36) (org-id-b36-to-int-one-digit i
-	  s)
+	  string)
 r))
 
 (defun org-id-time-to-b36 ( time)
@@ -489,7 +491,8 @@ and TIME is a Lisp time value (HI LO USEC)."
 Store the relation between files and corresponding IDs.
 This will scan all agenda files, all associated archives, and all
 files currently mentioned in `org-id-locations'.
-When FILES is given, scan also these files."
+When FILES is given, scan also these files.
+If SILENT is non-nil, messages are suppressed."
   (interactive)
   (unless org-id-track-globally
 (error "Please turn on `org-id-track-globally' if you want to track IDs"))
@@ -610,7 +613,7 @@ When FILES is given, scan also these files."
   (add-hook 'kill-emacs-hook 'org-id-locations-save))
 
 (defun org-id-hash-to-alist (hash)
-  "Turn an org-id hash into an alist.
+  "Turn an org-id HASH into an alist.
 This is to be able to write it to a file."
   (let (res x)
 (maphash
@@ -622,7 +625,7 @@ This is to be able to write it to a file."
 res))
 
 (defun org-id-alist-to-hash (list)
-  "Turn an org-id location list into a hash table."
+  "Turn an org-id location LIST into a hash table."
   (let ((res (make-hash-table
 	  :test 'equal
 	  :size (apply '+ (mapcar 'length list
-- 
2.33.0



[PATCH] Fix org-capture checkdoc warnings [9.5 (9.5-g9364b2 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-27 Thread No Wayman


The attached patch addresses most of the checkdoc warnings for 
org-capture.

There are two remaining warnings (both the same):

Disambiguate org-capture-mode by preceding w/ 
function,command,variable,option or symbol.


I did not address these because checkdoc has recently been fixed 
to stop asking for disambiguation of mode names:


http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=79a9b50621ec22640358bd6b94b65d14d747c644

>From 7f2e0e0a8735dbc2f4e79f17400471585e14d193 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Mon, 27 Sep 2021 20:35:12 -0400
Subject: [PATCH] org-capture: Fix checkdoc warnings

* org-capture: Fix checkdoc warnings.
---
 lisp/org-capture.el | 71 +
 1 file changed, 39 insertions(+), 32 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index cbdb30c03..15c62e14f 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -306,13 +306,15 @@ be replaced with content and expanded:
   current template.
   %(sexp) Evaluate elisp `(sexp)' and replace it with the results.
   Only placeholders pre-existing within the template, or
-  introduced with %[pathname] are expanded this way.  Since this
-  happens after expanding non-interactive %-escapes, those can
-  be used to fill the expression.
-  %<...>  The result of format-time-string on the ... format specification.
-  %t  Time stamp, date only.  The time stamp is the current time,
-  except when called from agendas with `\\[org-agenda-capture]' or
-  with `org-capture-use-agenda-date' set.
+  introduced with %[pathname] are expanded this way.
+  Since this happens after expanding non-interactive
+  %-escapes, those can be used to fill the expression.
+  %<...>  The result of `format-time-string' on the ... format
+  specification.
+  %t  Time stamp, date only.  The time stamp is the current
+  time, except when called from agendas with
+  `\\[org-agenda-capture]' or with
+  `org-capture-use-agenda-date' set.
   %T  Time stamp as above, with date and time.
   %u, %U  Like the above, but inactive time stamps.
   %i  Initial content, copied from the active region.  If
@@ -328,7 +330,7 @@ be replaced with content and expanded:
   %k  Title of currently clocked task.
   %K  Link to currently clocked task.
   %n  User name (taken from the variable `user-full-name').
-  %f  File visited by current buffer when org-capture was called.
+  %f  File visited by current buffer when `org-capture' was called.
   %F  Full path of the file or directory visited by current buffer.
   %:keyword   Specific information for certain link types, see below.
   %^g Prompt for tags, with completion on tags in target file.
@@ -497,17 +499,17 @@ is copied to this variable, which is local in the indirect buffer.")
   "Local variable to store the value of the :clock-keep parameter.
 This is needed in case `org-capture-finalize' is called interactively.")
 
-(defun org-capture-put ( stuff)
-  "Add properties to the capture property list `org-capture-plist'."
-  (while stuff
+(defun org-capture-put ( elements)
+  "Add ELEMENTS to the capture property list `org-capture-plist'."
+  (while elements
 (setq org-capture-plist (plist-put org-capture-plist
-   (pop stuff) (pop stuff)
-(defun org-capture-get (prop  local)
-  "Get properties from the capture property list `org-capture-plist'.
+   (pop elements) (pop elements)
+(defun org-capture-get (property  local)
+  "Get PROPERTY from the capture property list `org-capture-plist'.
 When LOCAL is set, use the local variable `org-capture-current-plist',
 this is necessary after initialization of the capture process,
 to avoid conflicts with other active capture processes."
-  (plist-get (if local org-capture-current-plist org-capture-plist) prop))
+  (plist-get (if local org-capture-current-plist org-capture-plist) property))
 
 ;;; The minor mode
 
@@ -1119,7 +1121,7 @@ FILE is a generalized file location, as handled by
 
 (defun org-capture-place-template ( inhibit-wconf-store)
   "Insert the template at the target location, and display the buffer.
-When `inhibit-wconf-store', don't store the window configuration, as it
+When INHIBIT-WCONF-STORE is non-nil, don't store the window configuration, as it
 may have been stored before."
   (unless inhibit-wconf-store
 (org-capture-put :return-to-wconf (current-window-configuration)))
@@ -1414,21 +1416,21 @@ Of course, if exact position has been required, just put it there."
 	(org-capture--position-cursor beg end)
 
 (defun org-capture-mark-kill-region (beg end)
-  "Mark the region that will have to be killed when aborting capture."
+  "Mark region between BEG and END to be killed on aborted capture."
   

Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-27 Thread No Wayman



Bastien  writes:


Hi,

No Wayman  writes:

Instead of a defvar that we don't want the user to modify, why 
not

hardcoding the addition of the coma?  I'd prefer this.


`completing-read-multiple' is currently used in two spots to read 
tags:

`org-set-tags-command' and `org-capture-fill-template'.
To be clear, you would rather I hard code the same regexp and 
comment in those two locations rather than abstracting it into a 
defconst?


Any place in the manual that refers to tag separators, 
explicitly or
implicitly, I've not checked if there are some.  Also in the 
code

itself, as a comment, to explain why both "," and ":" should be
allowed


I don't see why we need to add anything to the manual.
We're not changing the syntax of tags.
We're utilizing the normal behavior of completing-read-multiple.
The manual states for `org-set-tags-command':

"By default Org mode uses the standard minibuffer completion 
facilities for entering tags."


The comma is standard when reading multiple items.
That seems to cover it to me.

Another solution I proposed was indicating the delimiters in the 
minibuffer prompt similar to what is currently done in 
`org-todo-list'.

e.g.

org-todo-list prompt:"Keyword (or KWD1|KWD2|...): "
org-set-tags-command prompt: "Tags ("," or ":" to delimit): "

The only argument I heard against that was from one person who 
thought it "wasted space".
I don't consider that a strong argument considering the length of 
the prompt for `org-todo-list'.



(avoid the keyboard-based argument, which is too subjective.)


If one can customize their keyboard layout, I don't see why we 
should be so rigid about a delimiter in a prompt.
It's a moot point, though, I've abandoned that proposal because it 
was apparently too controversial.







Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-27 Thread No Wayman



Bastien  writes:


Hi,

No Wayman  writes:


* org.el (org-tags-crm-separators): Defcustom controlling which
characters are used to delimit tags in commands which utilize
`completing-read-multiple'.


Why should we allow anything else than ":" for separating tags 
in

commands which utilize completing-read-multiple?

I surely miss something obvious.


The patch you are viewing is outdated.
This is the latest patch on offer:

https://list.orgmode.org/87bl4rce4j@gmail.com/2-0001-Allow-to-delimit-tags.patch

It allows "," (the default for completing-read-multiple) and ":" 
to delimit tags when completing-read-multiple is used.
The reason for allowing "," is that it's easier to type than ":". 
I make liberal use of tags and IMO typing a "Shift+;" between each 
tag is annoying and slow.
The comma is also used as the default separator when 
completing-read-multiple is used.


If we relax a constraint, I'd rather have this hardcoded and 
well

documented than adding a new defvar or defcustom.


The latest patch removed the defcustom and replaced it with a 
defvar for the crm-separator regexp.
If it would ease your mind I'd be happy to convert it to a 
defconst.
It's also worth noting that the constraint was only recently 
introduced.
"," worked fine to delimit tags in `org-set-tags-command' prior to 
the switch to completing-read-multiple.


Regarding documentation, let me know where you'd prefer it 
documented. 



[BUG] 502/slow response from new repo [9.5 (9.5-g9364b2 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-26 Thread No Wayman



Experiencing 502 errors and delay when trying to clone the new 
development repo:


time git clone https://git.savannah.gnu.org/git/emacs/org-mode.git
Cloning into 'org-mode'...
remote: Counting objects: 129920, done.
remote: Compressing objects: 100% (28292/28292), done.
remote: Total 129920 (delta 101703), reused 129609 (delta 101488)
Receiving objects: 100% (129920/129920), 81.43 MiB | 10.35 MiB/s, 
done.

Resolving deltas: 100% (101703/101703), done.

real1m59.019s
user0m27.884s
sys 0m0.955s

That was after multiple attempts which resulted in 502 errors.

For comparison:
time git clone -b master git://git.sv.gnu.org/emacs.git
Cloning into 'emacs'...
remote: Counting objects: 950806, done.
remote: Compressing objects: 100% (167880/167880), done.
remote: Total 950806 (delta 782727), reused 949614 (delta 781638)
Receiving objects: 100% (950806/950806), 318.40 MiB | 31.17 MiB/s, 
done.

Resolving deltas: 100% (782727/782727), done.

real1m37.033s
user2m56.213s
sys 0m2.527s

Just a heads up.



Re: [PATCH] Declare functions for byte compiler [9.5 (9.5-g769a55 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-25 Thread No Wayman


Bastien  writes:

That's not just org-attach.el, right?  The patch does not apply 
either in the bugfix or in the main branch.  Could you resend 
it,

also wrapping the body of the ChangeLog at <80 lines?  M-x
change-log-mode RET can help.  TIA!


Sorry. Didn't realize the first patch had already been committed, 
so I rolled the change into that.

Separated the org-attach patch. See attached.

>From c5b77469c2fbff5d9fd25fcf9025b8a354406256 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sat, 25 Sep 2021 15:05:08 -0400
Subject: [PATCH] org-attach: Fix byte-comp function warning

* (org-attach.el): Declare function for byte compiler.
---
 lisp/org-attach.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 162a01e5e..c2d71514c 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -40,6 +40,7 @@
 (require 'org-id)
 
 (declare-function dired-dwim-target-directory "dired-aux")
+(declare-function dired-get-marked-files "dired" ( localp arg filter distinguish-one-marked error))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-type "org-element" (element))
 (declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
-- 
2.33.0



Re: [PATCH] Declare functions for byte compiler [9.5 (9.5-g769a55 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-25 Thread No Wayman


No Wayman  writes:

And one more in org-attach.el.
See attached.

>From 21620549a24703697d65c46bc88258cd4b2aaa80 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sat, 25 Sep 2021 15:05:08 -0400
Subject: [PATCH] Fix byte-comp function warnings

* (org.el, org-attach.el, org-keys.el, org-table.el): Declare functions for byte compiler.
---
 lisp/org-attach.el | 1 +
 lisp/org-keys.el   | 3 ++-
 lisp/org-table.el  | 1 +
 lisp/org.el| 5 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 162a01e5e..c2d71514c 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -40,6 +40,7 @@
 (require 'org-id)
 
 (declare-function dired-dwim-target-directory "dired-aux")
+(declare-function dired-get-marked-files "dired" ( localp arg filter distinguish-one-marked error))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-type "org-element" (element))
 (declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 8f25bda2e..2984a4f51 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -58,7 +58,6 @@
 (declare-function org-clone-subtree-with-time-shift "org" (n  shift))
 (declare-function org-columns "org" ( global columns-fmt-string))
 (declare-function org-comment-dwim "org" (arg))
-(declare-function org-refile-copy "org" ())
 (declare-function org-copy-special "org" ())
 (declare-function org-copy-visible "org" (beg end))
 (declare-function org-ctrl-c-ctrl-c "org" ( arg))
@@ -145,6 +144,8 @@
 (declare-function org-promote-subtree "org" ())
 (declare-function org-redisplay-inline-images "org" ())
 (declare-function org-refile "org" ( arg1 default-buffer rfloc msg))
+(declare-function org-refile-copy "org" ())
+(declare-function org-refile-reverse "org-refile" ( arg default-buffer rfloc msg))
 (declare-function org-reftex-citation "org" ())
 (declare-function org-reload "org" ( arg1))
 (declare-function org-remove-file "org" ( file))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 0bc668757..9a703d8bc 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -66,6 +66,7 @@
 (declare-function org-export-install-filters "ox" (info))
 (declare-function org-export-table-has-special-column-p "ox" (table))
 (declare-function org-export-table-row-is-special-p "ox" (table-row info))
+(declare-function org-forward-paragraph "org" ( arg))
 (declare-function org-id-find "org-id" (id  markerp))
 (declare-function org-indent-line "org" ())
 (declare-function org-load-modules-maybe "org" ( force))
diff --git a/lisp/org.el b/lisp/org.el
index e1780cf8d..630bfb19d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -158,13 +158,18 @@ Stars are put in group 1 and the trimmed body in group 2.")
 (declare-function org-element-context "org-element" ( element))
 (declare-function org-element-copy "org-element" (datum))
 (declare-function org-element-create "org-element" (type  props  children))
+(declare-function org-element-extract-element "org-element" (element))
+(declare-function org-element-insert-before "org-element" (element location))
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-lineage "org-element" (blob  types with-self))
 (declare-function org-element-link-parser "org-element" ())
+(declare-function org-element-map "org-element" (data types fun  info first-match no-recursion with-affiliated))
 (declare-function org-element-nested-p "org-element" (elem-a elem-b))
 (declare-function org-element-parse-buffer "org-element" ( granularity visible-only))
+(declare-function org-element-parse-secondary-string "org-element" (string restriction  parent))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-put-property "org-element" (element property value))
+(declare-function org-element-restriction "org-element" (element))
 (declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
 (declare-function org-element-timestamp-parser "org-element" ())
 (declare-function org-element-type "org-element" (element))
-- 
2.33.0



[PATCH] Declare functions for byte compiler [9.5 (9.5-g769a55 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-25 Thread No Wayman


Recent changes have introduced byte-comp warnings for unknown 
functions at compile time.
These warnings are "louder" now that more users are native 
compiling Elisp, so one more reason to avoid them.


See attached patch.

>From 736e72b56b10ba451016e4cc07305d8065c02ac9 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sat, 25 Sep 2021 15:05:08 -0400
Subject: [PATCH] Fix byte-comp function warnings

* (org.el, org-table.el org-keys.el) Declare functions for byte compiler.
---
 lisp/org-keys.el  | 3 ++-
 lisp/org-table.el | 1 +
 lisp/org.el   | 5 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 8f25bda2e..2984a4f51 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -58,7 +58,6 @@
 (declare-function org-clone-subtree-with-time-shift "org" (n  shift))
 (declare-function org-columns "org" ( global columns-fmt-string))
 (declare-function org-comment-dwim "org" (arg))
-(declare-function org-refile-copy "org" ())
 (declare-function org-copy-special "org" ())
 (declare-function org-copy-visible "org" (beg end))
 (declare-function org-ctrl-c-ctrl-c "org" ( arg))
@@ -145,6 +144,8 @@
 (declare-function org-promote-subtree "org" ())
 (declare-function org-redisplay-inline-images "org" ())
 (declare-function org-refile "org" ( arg1 default-buffer rfloc msg))
+(declare-function org-refile-copy "org" ())
+(declare-function org-refile-reverse "org-refile" ( arg default-buffer rfloc msg))
 (declare-function org-reftex-citation "org" ())
 (declare-function org-reload "org" ( arg1))
 (declare-function org-remove-file "org" ( file))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 0bc668757..9a703d8bc 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -66,6 +66,7 @@
 (declare-function org-export-install-filters "ox" (info))
 (declare-function org-export-table-has-special-column-p "ox" (table))
 (declare-function org-export-table-row-is-special-p "ox" (table-row info))
+(declare-function org-forward-paragraph "org" ( arg))
 (declare-function org-id-find "org-id" (id  markerp))
 (declare-function org-indent-line "org" ())
 (declare-function org-load-modules-maybe "org" ( force))
diff --git a/lisp/org.el b/lisp/org.el
index e1780cf8d..630bfb19d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -158,13 +158,18 @@ Stars are put in group 1 and the trimmed body in group 2.")
 (declare-function org-element-context "org-element" ( element))
 (declare-function org-element-copy "org-element" (datum))
 (declare-function org-element-create "org-element" (type  props  children))
+(declare-function org-element-extract-element "org-element" (element))
+(declare-function org-element-insert-before "org-element" (element location))
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-lineage "org-element" (blob  types with-self))
 (declare-function org-element-link-parser "org-element" ())
+(declare-function org-element-map "org-element" (data types fun  info first-match no-recursion with-affiliated))
 (declare-function org-element-nested-p "org-element" (elem-a elem-b))
 (declare-function org-element-parse-buffer "org-element" ( granularity visible-only))
+(declare-function org-element-parse-secondary-string "org-element" (string restriction  parent))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-put-property "org-element" (element property value))
+(declare-function org-element-restriction "org-element" (element))
 (declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
 (declare-function org-element-timestamp-parser "org-element" ())
 (declare-function org-element-type "org-element" (element))
-- 
2.33.0



Re: Switching to new Git repositories

2021-09-23 Thread No Wayman
Sounds like a weird issue.  I don't think this 9.5-dev tag is 
something from the Org repo.


There is a bug in mk/targets.mk introduced by 61336f80dc.
As others have pointed out, the new repository does not have tags.
As a fallback, org.el's version is read in it's header.
However, it looks like Kyle forgot to trim that string so we get 
ORGVERSION set to "9.5-dev" instead of "9.5".

This causes `org-version' to return an incorrect version string.

The attached patch addresses the issue in the makefile.

>From 9b81f396e69af146faceb13f5602fb6aa06a84e0 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 23 Sep 2021 17:13:34 -0400
Subject: [PATCH] mk/targets.mk: Fix ORGVERSION in tag-less repos

* mk/targets.mk (ORGVERSION, GITVERSION): properly generate ORGVERSION.

Fix bug introduced 61336f80 which caused ORGVERSION to be generated as
"Major.Minor-dev" instead of "Major.Minor" in tag-less repos.
---
 mk/targets.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 693e3781f..35383f173 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -15,9 +15,9 @@ ifneq ($(wildcard .git),)
   ifeq ($(ORGVERSION),)
 # In elpa.git, there are no tags available.  Fall back to using
 # the org.el header.
-ORGVERSION := $(shell $(BATCH) --eval "(require 'lisp-mnt)" \
-  --visit lisp/org.el --eval '(princ (lm-header "version"))')
-GITVERSION ?= $(ORGVERSION)-g$(shell git rev-parse --short=6 HEAD)
+ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
+  --visit lisp/org.el --eval '(princ (lm-header "version"))'))
+GITVERSION ?= $(ORGVERSION)-g$(shell git rev-parse --short=6 HEAD))
   else
 GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
   endif
-- 
2.33.0



Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-17 Thread No Wayman


Tim, Allen:

The attached compromise implements the bare minimum.
Tags can be separated with "," or ":" in the previously mentioned 
cases.

Scrapped the defcustom and showing delimiters in the prompt.
Any objections?

>From 31fbfca4884083adacd95054155cda9ed0128fba Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Fri, 3 Sep 2021 14:50:48 -0400
Subject: [PATCH] Allow "," to delimit tags

* org.el: Add `org-tags-crm-separtor' regexp
(org-set-tags-command, org-capture-fill-template): Use `org-tags-crm-separators'.
---
 lisp/org-capture.el | 2 +-
 lisp/org.el | 5 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index cbdb30c03..cd65f8e6d 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1739,7 +1739,7 @@ The template may still contain \"%?\" for cursor positioning."
 			(org-add-colon-after-tag-completion t)
 			(ins (mapconcat
   #'identity
-  (let ((crm-separator "[ \t]*:[ \t]*"))
+  (let ((crm-separator org-tags-crm-separator))
 (completing-read-multiple
  (if prompt (concat prompt ": ") "Tags: ")
  org-last-tags-completion-table nil nil nil
diff --git a/lisp/org.el b/lisp/org.el
index 8b9d57157..572e291c7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12007,6 +12007,9 @@ tags."
 	;; it now points to BLANK-START.  Use COLUMN instead.
 	(if in-blank? (org-move-to-column column) (goto-char origin))
 
+(defvar org-tags-crm-separator (format "[ \t]*%s[ \t]*" (regexp-opt '("," ":")))
+  "Regexp to separate tags in commands which use `completing-read-multiple'.")
+
 (defun org-set-tags-command ( arg)
   "Set the tags for the current visible entry.
 
@@ -12066,7 +12069,7 @@ in Lisp code use `org-set-tags' instead."
 		  table
 		  (and org-fast-tag-selection-include-todo org-todo-key-alist))
 		   (let ((org-add-colon-after-tag-completion (< 1 (length table)))
- (crm-separator "[ \t]*:[ \t]*"))
+ (crm-separator org-tags-crm-separator))
 		 (mapconcat #'identity
 (completing-read-multiple
 			 "Tags: "
-- 
2.33.0



Re: [BUG?][PATCH] Should the `lexical-binding' variable be bound during src block with :lexical t? [9.4.6 (9.4.6-ga451f9 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-10 Thread No Wayman



No Wayman  writes:


The third case I outlined.
Tangling a :lexical t src block sults in a dynamically scoped 
file unless the

user manually inserts the file-local variable line.


*results

That's adjacent to the issue I originally raised, but we could do 
better in that case.





Re: [BUG?][PATCH] Should the `lexical-binding' variable be bound during src block with :lexical t? [9.4.6 (9.4.6-ga451f9 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-10 Thread No Wayman



Timothy  writes:


Hi NoWayman,


I ran into this with some code I’m writing which checks against
`lexical-binding’.
Should the following result in “lexical binding enabled” or
“lexical binding disabled”?:


Can you think of any examples where this results in different 
behaviour (without

explicitly checking `lexical-binding')?

All the best,
Timothy



The third case I outlined.
Tangling a :lexical t src block sults in a dynamically scoped file 
unless the user manually inserts the file-local variable line.





Re: [BUG?][PATCH] Should the `lexical-binding' variable be bound during src block with :lexical t? [9.4.6 (9.4.6-ga451f9 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-09 Thread No Wayman



My thoughts on this would be that if lexical-bindings is 
supposed to be
bound to t, it should be done by eval when it gets a non-nil 
value for
it's optional argument. If I execute (eval FORM t) in an emacs 
lisp
buffer, it looks like lexical-bind is not set either, so I don't 
think
it should be in org either. To set it means we could get the 
same code
behaving differently depending on whether the source block is 
'tangled'
and then evaluated or evaluated within org, which doesn't feel 
right.
 

I agree that we should avoid inconsistency. However it is already 
present.

You can verify this with the following src block:

#+begin_src emacs-lisp :lexical t :tangle ./dynamic.el :results 
verbatim

(symbol-value lexical-binding)
#+end_src

1. `org-babel-execute-src-block' with point in the src block => 
nil (lexical binding enabled)
2. `org-edit-special' with point in the src block, 
`eval-last-sexp' within *Org Src* buffer => t (lexical binding 
enabled)
3. Tangle to the block to "dynamic.el", `eval-last-sexp' within 
"dynamic.el" => nil (dynamic binding)


Might be worth asking on emacs-devel why (eval FORM t) does not 
set this variable?


I understand why it doesn't. Elisp can be interpreted independent 
of a buffer, and different buffers need to distinguish which scope 
to use. 
It's more a question of what do we gain by leaving it unbound 
while evaluating a src block?
A user can rebind `lexical-binding' without hurting anything. The 
only case I can think of is if they intend to use it as a free 
variable, it won't be free. I can't imagine a use case where that 
would be true while the user is also explicitly requesting lexical 
binding, though.

IMO, it should be set during evaluation (addressed by my patch).

An alternative solution would be to allow one to set the lexical 
environment as part of the header args. e.g.


#+begin_src emacs-ilsp :lexical ((lexical-binding . t) t)
(symbol-value lexical-binding)
#+end_src

That way we offer the full flexibility of `eval' to those who 
would use it.


A separate issue, but one worth considering, is whether or not 
tangling a `:lexical t` src block should automatically add the 
file-local variable line in the tangled file.


Prior confusion (its not just me, I swear):

https://emacs.stackexchange.com/questions/61754/how-can-i-enable-lexical-binding-for-elisp-code-in-org-mode#comment100554_61758

https://lists.gnu.org/archive/html/emacs-orgmode/2019-08/msg00247.html



[BUG?][PATCH] Should the `lexical-binding' variable be bound during src block with :lexical t? [9.4.6 (9.4.6-ga451f9 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-09 Thread No Wayman


I ran into this with some code I'm writing which checks against 
`lexical-binding'.
Should the following result in "lexical binding enabled" or 
"lexical binding disabled"?:


#+begin_src emacs-lisp :lexical t
(message "lexical binding %sabled" (if lexical-binding "en" 
"dis"))

#+end_src

Currently the `lexical-binding' variable is not bound because 
`org-babel-execute:emacs-lisp'
passes t to `eval', which enables lexical binding, but does not 
bind the `lexical-binding' variable.

The attached patch binds the variable in the lexical environment.
It's a matter of whether or not this is the right thing to do.
Thoughts?


Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X 
toolkit, cairo version 1.17.4, Xaw3d scroll bars)

of 2021-09-04
Package: Org mode version 9.4.6 (9.4.6-ga451f9 @ 
/home/n/.emacs.d/straight/build/org/)


>From 42b92303faa86b1e9bd0692fca9469eb6a8f02ce Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 9 Sep 2021 16:40:02 -0400
Subject: [PATCH] ob-emacs-lisp: bind lexical-binding for :lexical t src blocks

* lisp/ob-emacs-lisp.el (org-babel-execute:emacs-lisp): bind lexical-binding in lexical environments

Because we use `eval' to execute the src block, this variable needs to
be explicitly set. Passing t as eval's LEXICAL arg will not bind
this variable.
---
 lisp/ob-emacs-lisp.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el
index d03151f13..6cf387b96 100644
--- a/lisp/ob-emacs-lisp.el
+++ b/lisp/ob-emacs-lisp.el
@@ -61,7 +61,7 @@ by `org-edit-src-code'.")
 
 (defun org-babel-execute:emacs-lisp (body params)
   "Execute a block of emacs-lisp code with Babel."
-  (let* ((lexical (cdr (assq :lexical params)))
+  (let* ((lexical (org-babel-emacs-lisp-lexical (cdr (assq :lexical params
 	 (result-params (cdr (assq :result-params params)))
 	 (body (format (if (member "output" result-params)
 			   "(with-output-to-string %s\n)"
@@ -71,7 +71,7 @@ by `org-edit-src-code'.")
  (member "pp" result-params))
  (concat "(pp " body ")")
 			   body))
-		   (org-babel-emacs-lisp-lexical lexical
+		   (when lexical (list (cons 'lexical-binding t) t)
 (org-babel-result-cond result-params
   (let ((print-level nil)
 (print-length nil))
-- 
2.33.0



Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-06 Thread No Wayman



Allen Li  writes:

green-blue is recoverable, and green:blue is not.  Consider a 
file where
some headings are tagged :green:blue: and some are tagged 
:green_blue:.
If green-blue gets changed into :green:blue:, then it is no 
longer

possible to tell which :green:blue: headings are supposed to be
:green_blue:.  If they were left as green-blue, it is trivial to 
fix
them with a search-replace.  It is also easy to notice that they 
were
typed incorrectly because the tags would be highlighted 
differently (as

they are invalid).


It's not so easy to notice such corruption in the case of captures 
which are filed away and then searched for (by tag) at a later 
time.
But that's neither here nor there. We both agree the behavior 
should be more consistent, and the patch I've proposed takes care 
of that.


Yes, I think using only ":" and "," is the best default option. 
I still
don't think there is a need to make it customizable (I doubt 
anyone is

typing tags separated with ! or @ or #), but I suppose
there's minimal harm from doing so.


I don't see the need to prevent customization here, either.
There may be use cases we don't anticiapte and it adds very little 
in the way of maitenance.
Consider if the author of crm.el decided to hardcode the 
separator.

Your original patch would not have been so trivial.

I am -0.5 on showing the delimiters since this is not 
conventional for
completing-read-multiple, especially after we add support for 
"," like
most other uses of completing-read-multiple.  It needlessly 
inflates the

length of the prompt.


I don't know what you mean by -0.5, but I wouldn't say it's 
needless.

`org-todo-list' adds the following to the prompt:


"Keyword (or KWD1|KWD2|...): "


We're talking a handful of characters at most. e.g.


"Tags (: , to delimit): "


Actually shorter than what `org-todo-list' does now.
I'm open to suggestions on improving that prompt format as well.


I suggest adding a helper function for the:

  (separators (or org-tags-crm-separators '(?: ?,)))
   (crm-separator (org-tags-crm-regexp separators))

so you can call it like:

  (crm-separator (org-tags--crm-separator-regexp))

since you repeat this verbatim below.


The separators are stored in a separate variable for use in the 
prompt.
I'll have to take another look to see if we can eliminate the 
duplicate code.
I do agree the function can be "private" and named more 
appropriately.

I'll change that in the next revision.

You should make the :type a list of characters so the widget is 
more

user friendly


Agreed. I'll tidy that up as well once a solution is agreed upon.
(IME Org/Emacs patches require more discussion up front, so I'd 
rather deal with that first

instead of putting too much time into a trivial patch up front)

So it looks like the remaining issue is whether or not it's worth 
displaying the tag delimiters in the prompt. I'll think on it some 
more and give it some time to see if anyone else has any arguments 
in favor or against the idea. If I don't see anything by the 
weekend, I'll amend the patch with the changes suggested above.




Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-03 Thread No Wayman


No Wayman  writes:


No Wayman  writes:


See the attached patch for a first draft implementation.


Attached is a second draft which compiles cleanly and makes use 
of mapconcat

where appropriate.

[2. org-tags-crm-separators-2 --- text/x-patch; 
0001-Add-org-tags-crm-separators.patch]...


See attached with amended commit message.

>From d059c4369ac17fcba885adf87c95c6797894d230 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Fri, 3 Sep 2021 14:50:48 -0400
Subject: [PATCH] Add org-tags-crm-separators

* org.el (org-tags-crm-separators): Defcustom controlling which
characters are used to delimit tags in commands which utilize
`completing-read-multiple'.
(org-set-tags-command, org-capture-fill-template): Make use of org-tags-crm-separators; Show
delimiters in tag prompt.
---
 lisp/org-capture.el |  7 +--
 lisp/org.el | 17 ++---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index c51744680..e51d039d5 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1740,9 +1740,12 @@ The template may still contain \"%?\" for cursor positioning."
 			(org-add-colon-after-tag-completion t)
 			(ins (mapconcat
   #'identity
-  (let ((crm-separator "[ \t]*:[ \t]*"))
+  (let* ((separators (or org-tags-crm-separators '(?: ?,)))
+ (crm-separator (org-tags-crm-regexp separators)))
 (completing-read-multiple
- (if prompt (concat prompt ": ") "Tags: ")
+ (if prompt (concat prompt ": ")
+   (format "Tags (%s to delimit): "
+   (mapconcat #'char-to-string separators " ")))
  org-last-tags-completion-table nil nil nil
  'org-tags-history))
   ":")))
diff --git a/lisp/org.el b/lisp/org.el
index ce68f4692..4cd173c99 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2980,6 +2980,11 @@ is better to limit inheritance to certain tags using the variables
 	  (const :tag "Reverse alphabetical" org-string-collate-greaterp)
 	  (function :tag "Custom function" nil)))
 
+(defcustom org-tags-crm-separators '(?: ?,)
+  "List of tag delimiting characters used when reading multiple tags."
+  :type 'list
+  :group 'org-tags)
+
 (defvar org-tags-history nil
   "History of minibuffer reads for tags.")
 (defvar org-last-tags-completion-table nil
@@ -12007,6 +12012,10 @@ tags."
 	;; it now points to BLANK-START.  Use COLUMN instead.
 	(if in-blank? (org-move-to-column column) (goto-char origin))
 
+(defun org-tags-crm-regexp (chars)
+  "Return `crm-separator' regexp using CHARS as separators."
+  (format "[ \t]*%s[ \t]*" (regexp-opt (mapcar #'char-to-string chars
+
 (defun org-set-tags-command ( arg)
   "Set the tags for the current visible entry.
 
@@ -12065,11 +12074,13 @@ in Lisp code use `org-set-tags' instead."
 		  inherited-tags
 		  table
 		  (and org-fast-tag-selection-include-todo org-todo-key-alist))
-		   (let ((org-add-colon-after-tag-completion (< 1 (length table)))
- (crm-separator "[ \t]*:[ \t]*"))
+		   (let* ((org-add-colon-after-tag-completion (< 1 (length table)))
+  (separators (or org-tags-crm-separators '(?: ?,)))
+  (crm-separator (org-tags-crm-regexp separators)))
 		 (mapconcat #'identity
 (completing-read-multiple
-			 "Tags: "
+ (format "Tags (%s to delimit): "
+ (mapconcat #'char-to-string separators " "))
 			 org-last-tags-completion-table
 			 nil nil (org-make-tag-string current-tags)
 			 'org-tags-history)
-- 
2.33.0



Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-03 Thread No Wayman


No Wayman  writes:


See the attached patch for a first draft implementation.


Attached is a second draft which compiles cleanly and makes use of 
mapconcat where appropriate.


>From 079f116f6bedcf2c2b1d08c18d71d8e432d94d38 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Fri, 3 Sep 2021 14:50:48 -0400
Subject: [PATCH] Add org-tags-crm-separators

commit message/formatting pending discussion of solution.
---
 lisp/org-capture.el |  7 +--
 lisp/org.el | 17 ++---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index c51744680..e51d039d5 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1740,9 +1740,12 @@ The template may still contain \"%?\" for cursor positioning."
 			(org-add-colon-after-tag-completion t)
 			(ins (mapconcat
   #'identity
-  (let ((crm-separator "[ \t]*:[ \t]*"))
+  (let* ((separators (or org-tags-crm-separators '(?: ?,)))
+ (crm-separator (org-tags-crm-regexp separators)))
 (completing-read-multiple
- (if prompt (concat prompt ": ") "Tags: ")
+ (if prompt (concat prompt ": ")
+   (format "Tags (%s to delimit): "
+   (mapconcat #'char-to-string separators " ")))
  org-last-tags-completion-table nil nil nil
  'org-tags-history))
   ":")))
diff --git a/lisp/org.el b/lisp/org.el
index ce68f4692..4cd173c99 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2980,6 +2980,11 @@ is better to limit inheritance to certain tags using the variables
 	  (const :tag "Reverse alphabetical" org-string-collate-greaterp)
 	  (function :tag "Custom function" nil)))
 
+(defcustom org-tags-crm-separators '(?: ?,)
+  "List of tag delimiting characters used when reading multiple tags."
+  :type 'list
+  :group 'org-tags)
+
 (defvar org-tags-history nil
   "History of minibuffer reads for tags.")
 (defvar org-last-tags-completion-table nil
@@ -12007,6 +12012,10 @@ tags."
 	;; it now points to BLANK-START.  Use COLUMN instead.
 	(if in-blank? (org-move-to-column column) (goto-char origin))
 
+(defun org-tags-crm-regexp (chars)
+  "Return `crm-separator' regexp using CHARS as separators."
+  (format "[ \t]*%s[ \t]*" (regexp-opt (mapcar #'char-to-string chars
+
 (defun org-set-tags-command ( arg)
   "Set the tags for the current visible entry.
 
@@ -12065,11 +12074,13 @@ in Lisp code use `org-set-tags' instead."
 		  inherited-tags
 		  table
 		  (and org-fast-tag-selection-include-todo org-todo-key-alist))
-		   (let ((org-add-colon-after-tag-completion (< 1 (length table)))
- (crm-separator "[ \t]*:[ \t]*"))
+		   (let* ((org-add-colon-after-tag-completion (< 1 (length table)))
+  (separators (or org-tags-crm-separators '(?: ?,)))
+  (crm-separator (org-tags-crm-regexp separators)))
 		 (mapconcat #'identity
 (completing-read-multiple
-			 "Tags: "
+ (format "Tags (%s to delimit): "
+ (mapconcat #'char-to-string separators " "))
 			 org-last-tags-completion-table
 			 nil nil (org-make-tag-string current-tags)
 			 'org-tags-history)
-- 
2.33.0



Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-03 Thread No Wayman



Timothy  writes:

Reading your thoughts I’m inclined to agree, perhaps it’s best 
if we settle on a
set of “sensible” separation characters, document them, and 
leave it at that.


NoWayman, what do you think of that?



I disagree with the idea that it shouldn't be customizable.
See the second patch I've offered.
I feel it addresses the issue without preventing customization.



Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-03 Thread No Wayman


Allen Li  writes:

Sorry about that (I wrote the crm patch).  I did not consider 
people
deliberately using invalid tag characters to separate tags. 
It's an
(un?)happy coincidence that org-set-tags-commands retains this 
behavior,

because the fast tags selection logic gets in the way.

The inconsistency in behavior can be easily fixed by deleting 
the code
in org-set-tags-commands that replaces invalid tag characters 
with ":".


The question here is, which behavior do we want?  My philosphy 
is that
programs shouldn't try to silently re-interpret the user's 
intentions.

For example, if I accidentally mistyped the tag "green_blue" as
"green-blue", I don't want Org to "helpfully" split one tag into 
two
tags "green:blue".  I may not realize the data corruption until 
too

late.


Consider the current behavior of `org-capture-fill-template':

If you were to mistype your tag as "green-blue" it would be 
captured as part of the headline string instead of a set of tags.
Future tag completions would not include any reference to it, and 
so you likely wouldn't notice until long after the fact 
(especially in the case of a template with a non-nil 
:immediate-finish).
So the risk of data corruption exists now by allowing the function 
to return an invalid tag string.



There's also the option to only allow ":" and "," as separators.
Whichever behavior we choose, I don't think it's worth making it 
customizable.


I would rather not have to type ":" to separate Org tags when CRM 
allows me to use ","
(or another character of my choice) everywhere else. This violates 
the principle of least surprise.


An even simpler solution than my original patch is to have a 
defcustom which allows the user to customize

the CRM separator character(s) Org uses to read tags.

See the attached patch for a first draft implementation.

It defaults to what you've proposed (allowing ":" and "," to 
delimit tags).
It avoids introducing a new regexp variable which needs to be 
maintained in lockstep with `org-tag-re'.

It's customizable.
It informs the user about the tag delimiting characters in the 
prompt.


>From 34d292a60bc45923589646499b6e06c5cb3ca036 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Fri, 3 Sep 2021 14:50:48 -0400
Subject: [PATCH] Add org-tags-crm-separators

commit message/formatting pending discussion of solution.
---
 lisp/org-capture.el |  7 +--
 lisp/org.el | 17 ++---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index c51744680..e9cd8f490 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1740,9 +1740,12 @@ The template may still contain \"%?\" for cursor positioning."
 			(org-add-colon-after-tag-completion t)
 			(ins (mapconcat
   #'identity
-  (let ((crm-separator "[ \t]*:[ \t]*"))
+  (let* ((separators (or org-tags-crm-separators '(?: ?,)))
+ (crm-separator (org-tags-crm-regexp separators)))
 (completing-read-multiple
- (if prompt (concat prompt ": ") "Tags: ")
+ (if prompt (concat prompt ": ")
+   (format "Tags (%s to delimit): "
+   (string-join (mapcar #'char-to-string separators) " ")))
  org-last-tags-completion-table nil nil nil
  'org-tags-history))
   ":")))
diff --git a/lisp/org.el b/lisp/org.el
index ce68f4692..d6739f7ed 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2980,6 +2980,11 @@ is better to limit inheritance to certain tags using the variables
 	  (const :tag "Reverse alphabetical" org-string-collate-greaterp)
 	  (function :tag "Custom function" nil)))
 
+(defcustom org-tags-crm-separators '(?: ?,)
+  "List of characters used to separate tags during Org commands which read mutiple tags."
+  :type 'list
+  :group 'org-tags)
+
 (defvar org-tags-history nil
   "History of minibuffer reads for tags.")
 (defvar org-last-tags-completion-table nil
@@ -12007,6 +12012,10 @@ tags."
 	;; it now points to BLANK-START.  Use COLUMN instead.
 	(if in-blank? (org-move-to-column column) (goto-char origin))
 
+(defun org-tags-crm-regexp (chars)
+  "Return `crm-separator' regexp using CHARS as separators."
+  (format "[ \t]*%s[ \t]*" (regexp-opt (mapcar #'char-to-string chars
+
 (defun org-set-tags-command ( arg)
   "Set the tags for the current visible entry.
 
@@ -12065,11 +12074,13 @@ in Lisp code use `org-set-tags' instead."
 		  inherited-tags
 		  table
 		  (and org-fast-tag-selection-include-todo org-todo-key-alist))
-		   (let ((org-add-colon-after-tag-completion (< 1 (length table)))
- (crm-separator "[ \t]*:[ \t]*"))
+		   (let* ((org-add-colon-after-tag-completion (< 1 (length table)))
+  (separators (or org-tags-crm-separators '(?: ?,)))
+  (crm-separator (org-tags-crm-regexp 

Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-03 Thread No Wayman



Timothy  writes:

Ah, right — that looks sensible. I think we should probably note 
that in a

comment somewhere,


Yes, a comment is warranted.
I'll address minor issues like this once a solution is agreed 
upon.


or perhaps construct the regexp with `rx' so it’s actually using 
`org-tag-re'?


Unfortunately I don't think it's that simple.
They are very similar regexps, but I don't think we can just plug 
`org-tag-re'

into an rx form and have it work. A direct comparison:


org-tag-re =>"[[:alnum:]_@#%]+"
org-tag-crm-separator => "[^[:alnum:]_@#%]"

This is brittle, but we could define `org-tag-crm-separator' in 
terms of `org-tag-re' like so:


(defvar org-tag-crm-separator (concat "[^" (substring org-tag-re 1 
-1







Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-09-02 Thread No Wayman



Timothy  writes:


Hi NoWayman,

Thanks for your suggestion. At a glance it looks reasonable to 
me, but would you
be able to explain the default value you’ve set? It isn’t 
obvious to me how you
arrived at `"[ \t]*[^[:alnum:]_@#%][ \t]*"'. Also, do you think 
a
one-size-fits-all solution is a good fit here? I don’t do much 
with tags

personally, so I’m probably not the best person to judge.


(defconst org-tag-crm-separator “[ ]*[^[:alnum:]_@#%][ ]*”
  “Regexp used to determine `crm-separator’ when reading 
  multiple tags.”)


All the best,
Timothy


I was aiming for the inverse of `org-tag-re' which is:

"[[:alnum:]_@#%]+"

The idea being we treat any character which is not a valid tag 
character as the crm separator.




[BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)]

2021-08-26 Thread No Wayman


Remember to cover the basics, that is, what you expected to happen 
and
what in fact did happen.  You don't know how to make a good 
report?  See


https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


622f9fa76c8ee0766b15945c013b0950d703b955 ("org: Use crm for 
completing tags")
lexically binds crm-separator to ":" while prompting for multiple 
tags in

org-set-tags-command and org-capture-fill-template.

org-set-tags-command correctly parses the tags when using a comma 
(the default
crm-separator) to separate them, but completion is broken unless 
":" is used as

the separator.
org-capture-fill-template incorrectly parses this.

Reproducible from emacs -Q:

org-set-tags-command:
1. Insert a new Org entry in the a buffer 
2. M-x org-set-tags-command 
3. At the prompt enter "one,two,three"
4. Entry's tags are correctly set to :one:two:three: 


org-capture-fill-template:
1. evaluate (org-capture-fill-template "%^g")
2. At the prompt enter "one,two,three"
3. String returned is incorrect: ":one,two,three:"


I can think of a couple ways we could improve this and make the 
behavior consistent.
We could introduce a defcustom which allows the user to choose 
whether or not
Org will rebind crm-separator during commands/functions which 
utilize

completing-read-multiple.
e.g.

#+begin_src emacs-lisp :lexical t
(defcustom org-contextual-crm-separator t
 "Use contextual binding of crm-separator during Org commands.
For example, when setting tags, \":\" is used as the separator.
If nil, `crm-separator' is used.")
#+end_src

Alternatively, we could change the lexical binding we're using 
during these commands/functions.
Instead of binding the separator explicitly to "[ \t]*:[ \t]*", we 
could instead use a regexp
which will match any character not described by org-tag-re. The 
benefit of
this is that completing-read-multiple completion will work for any 
separator
that doesn't match org-tag-re transparently and the results should 
be
consistent between org-set-tags-command and 
org-capture-fill-template.


The attached patch implements that change, which seems to do the 
right thing
from my testing. I can polish it, but I wanted to get opinions on 
the solution first.


Note this does not change the case of org-todo-list, which binds
crm-separator to "|". I chose not to touch that because I'm not 
fully aware 
of what the restrictions on characters for todo-keywords are, if 
any.
org-todo-list also does the right thing by mentioning the 
separator in the prompt.


We could also combine the approaches:

- Introduce a defcustom that determines if we're going to 
 contextually rebind crm-separator

- Use a broader regexp when contextually binding crm-separator
- Mention the separator in the prompt when rebound

Thoughts?


Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.30, cairo version 1.17.4)

of 2021-08-02
Package: Org mode version 9.4.6 (9.4.6-g366444 @ 
/home/n/.emacs.d/straight/build/org/)


>From 2ec28b530eb28cf788c38556ec3cb97f3bacd4af Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Thu, 26 Aug 2021 12:51:27 -0400
Subject: [PATCH] RFC: broader regexp for lexically bound crm-separator

For testing purposes. Ammended commit message pending.
---
 lisp/org-capture.el | 2 +-
 lisp/org.el | 5 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index c51744680..47b47c3ca 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1740,7 +1740,7 @@ The template may still contain \"%?\" for cursor positioning."
 			(org-add-colon-after-tag-completion t)
 			(ins (mapconcat
   #'identity
-  (let ((crm-separator "[ \t]*:[ \t]*"))
+  (let ((crm-separator org-tag-crm-separator))
 (completing-read-multiple
  (if prompt (concat prompt ": ") "Tags: ")
  org-last-tags-completion-table nil nil nil
diff --git a/lisp/org.el b/lisp/org.el
index ce68f4692..f5e396cba 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -602,6 +602,9 @@ not contribute to the agenda listings.")
 (defconst org-tag-re "[[:alnum:]_@#%]+"
   "Regexp matching a single tag.")
 
+(defconst org-tag-crm-separator "[ \t]*[^[:alnum:]_@#%][ \t]*"
+  "Regexp used to determine `crm-separator' when reading multiple tags.")
+
 (defconst org-tag-group-re "[ \t]+\\(:\\([[:alnum:]_@#%:]+\\):\\)[ \t]*$"
   "Regexp matching the tag group at the end of a line, with leading spaces.
 Tags are stored in match group 1.  Match group 2 stores the tags
@@ -12066,7 +12069,7 @@ in Lisp code use `org-set-tags' instead."
 		  table
 		  (and org-fast-tag-selection-include-todo org-todo-key-alist))
 		   (let ((org-add-colon-after-tag-completion (< 1 (length table)))
- (crm-separator "[ \t]*:[ \t]*"))
+ (crm-separator 

Re: [PATCH] Rename headline to heading

2021-08-15 Thread No Wayman


No Wayman  writes:

As far as org-capture is concerned, support for transparently 
upgrading the
user's templates could easily be added to the 
`org-capture-upgrade-templates`

function.

It would just be one more case added to the existing pcase 
statement and would

prevent breakage for users.


See the attached patch which adds the mentioned case.
The docstring for `org-capture-upgrade-templates` could be worded 
better/more generally.
I believe we could also do a better job notifying the user when 
they have outdated
capture syntax. Really we should be recording *which* templates 
use outdated syntax
and pointing them to a solution. These are separate issues, 
though.


>From 4a133f0c5a7fef18ea1dfb38e2e1539da1db834e Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Sun, 15 Aug 2021 12:48:00 -0400
Subject: [PATCH] org-capture.el: Upgrade file+headline template target syntax

* lisp/org-capture.el (org-capture-upgrade-templates): Upgrade
templates which utilize file+headline target syntax to file+heading
---
 lisp/org-capture.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 831c3e1f4..28b3e33f4 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -109,7 +109,8 @@
   "Update the template list to the new format.
 TEMPLATES is a template list, as in `org-capture-templates'. The
 new format unifies all the date/week tree targets into one that
-also allows for an optional outline path to specify a target."
+also allows for an optional outline path to specify a target.
+It also accounts for renaming `headline` to `heading`."
   (let ((modified-templates
 	 (mapcar
 	  (lambda (entry)
@@ -128,6 +129,9 @@ also allows for an optional outline path to specify a target."
 	  (`(,key ,desc ,type (file+weektree+prompt . ,path) ,tpl . ,props)
 	   `(,key ,desc ,type (file+olp+datetree ,@path) ,tpl
 		  :tree-type week :time-prompt t ,@props))
+  ;; Rename "headline" to "heading"
+	  (`(,key ,desc ,type (file+headline . ,file+heading) ,tpl . ,props)
+	   `(,key ,desc ,type (file+heading ,@file+heading) ,tpl ,@props))
 	  ;; Other templates are left unchanged.
 	  (_ entry)))
 	  templates)))
-- 
2.32.0



Re: [PATCH] Rename headline to heading

2021-08-15 Thread No Wayman



As far as org-capture is concerned, support for transparently 
upgrading the user's templates could easily be added to the 
`org-capture-upgrade-templates` function.


It would just be one more case added to the existing pcase 
statement and would prevent breakage for users.




Re: what would cause failure in template for org capture?

2021-07-27 Thread No Wayman



Thanks for doing the bisect.
I was in the process of doing it myself and comparing disassembled 
byte-code when I saw the patch had been pushed.
For anyone curious, this particular bug was a byte compilation 
error.
When byte-compiled, org-capture-fill-template was attempting to 
compare strings
via a jump-table-eq bytecode instruction instead of a 
jump-table-equal.


Resolved on Emacs master as of 
949dd41c31dab69f7a5067bba324c28bb2cfbf8e




Re: what would cause failure in template for org capture?

2021-07-23 Thread No Wayman



from an earlier thread, I recall you mentioned you were using 
native

compilation? This is almost certainly the cause of your problem.


This does smell like a byte-compilation problem.
Seems to be a failure with any interactive, single-character 
%-escaped patterns in a template string (e.g. %^g, %^C, %^t).
I've narrowed it down to a call to pcase in 
`org-capture-fill-template'.
As Eric mentions, the problem disappears if the function is 
re-evaluated/instrumented.
I have disabled native compilation and the problem persists with 
just a freshly byte-compiled elc of org-capture.

Tested this with the following recipe:

1. eval the following:
(org-capture-fill-template "%^t") ;fails with `unrecognized 
template placeholder: %^t`
2. eval org-capture-fill-template's definition, and then re-eval 
the above. Works properly. User is prompted for a time.
3. byte compile org-capture-fill-template: (byte-compile 
#'org-capture-fill-template)

4. eval (org-capture-fill-template "%^t") ; error is back


Running Emacs 28.0.50
Repository revision: 903ecd7bea7d8f99a7dc84150728219283d79bf0
Repository branch: master






Re: new org-contrib and straight.el

2021-05-21 Thread No Wayman



Greg Minshall  writes:


Nick,
...i have not been getting the updated org-mode info
pages with my org package. 


Straight provides its own means of building/installing package 
info.

This may be a bug with the Org mode recipe we provide.
Please file a bug report at:

https://github.com/raxod502/straight.el

Be sure to include the output of `M-x straight-version` and `M-x 
emacs-version` at a minimum.


If you feel you have a reproduction case or recipe that works 
better, you can include

that recipe with a report using `straight-bug-report'.
It's a macro that will install straight in a clean environment,
run your code and produce a formatted report to share.




Re: new org-contrib and straight.el

2021-05-19 Thread No Wayman



Greg Minshall  writes:


Nick,

The recent changes to org-contrib's location/structure have 
been
accounted for on straight's "develop" branch. Once on that 
branch you

can rely on the default recipe:


thanks very much.  i'll look at switching to the development 
branch,

freezing and thawing.

cheers, Greg




You're welcome.

I've merged the develop branch into the master branch this 
morning, too.
So you should be able to reap that benefit on either branch, but I 
still

recommend using the lockfiles to your advantage.




Re: new org-contrib and straight.el

2021-05-18 Thread No Wayman




Hi, Greg.

The recent changes to org-contrib's location/structure have been 
accounted for on straight's
"develop" branch. Once on that branch you can rely on the default 
recipe:


#+begin_src emacs-lisp
(straight-use-package 'org-contrib)
#+end_src

You can see which version of straight you're currently using via 
`M-x straight-version`.
If you're on the "master" branch (commit e1390a9 as of this 
writing), you can update to the "develop"

branch by adding:

#+begin_src emacs-lisp
(setq straight-repository-branch "develop")
#+end_src

prior to straight's bootstrapping snippet in your in init file.
I recommend using the develop branch and utilizing the lockfile 
system via
`straight-freeze-versions` and `straight-thaw-versions` to define 
your own "stable releases".


Hope that helps.
If you have any other questions or run into problems feel free to 
reach out on our issue tracker:


https://github.com/raxod502/straight.el/issues/new/choose

Hope that helps,

Nick



Re: Bug: [PATCH] org-babel-tangle: persmission denied when tangling [9.4.5 (9.4.5-gbc2659 @ /home/n/.emacs.d/straight/build/org/)]

2021-05-05 Thread No Wayman



Sébastien Miquel  writes:

Here's another patch, to be applied on top of the previous one, 
that

fixes this.

The specific case you mention can also be achieved by setting 
the
:tangle argument to `yes`: in this case, the tangled file name 
is

computed using the buffer file name and changing the extension
according to the src block language.


Thanks for the tip. I probably added that years ago and haven't 
changed it.

Updated to keep things simple.

Thank you again for the report, and sorry for breaking 
everything.



Thanks for the patches. Tested them and everything seems to be 
working OK.




Re: Bug: org-babel-tangle: persmission denied when tangling [9.4.5 (9.4.5-gbc2659 @ /home/n/.emacs.d/straight/build/org/)]

2021-05-04 Thread No Wayman



Sébastien Miquel  writes:


Hi Bastien,

Bastien writes:
I tried to apply this (transitory?) patch against maint and it 
did not
apply. It applies okay on master. For bug fixes, please make 
patches

againt the maint branch.
This fixes a bug introduced by a commit in master. I've attached 
the same
patch here, properly formated. I think it should be applied to 
master.


It reverts a part of a2cb9b853: permissions are no longer set 
before writing

to the tangled file.

I've CC'd Tom, which made the original suggestion. I guess we 
could set the
write and execute permissions before writing, and set the read 
permissions

afterwards.



Another related bug to the changes:

I have the :tangle header-arg set to evaluate some elisp to return 
the file name:


org-babel no longer interprets this elisp. It is being used 
literally as the file name:

e.g.

Wrote /home/n/.emacs.d/(concat (file-name-sans-extension 
(buffer-file-name)) ".el")




Re: Bug: org-babel-tangle: persmission denied when tangling [9.4.5 (9.4.5-gbc2659 @ /home/n/.emacs.d/straight/build/org/)]

2021-05-04 Thread No Wayman



Sébastien Miquel  writes:


Hi,

No Wayman writes:
I'm tangling my early-init/init.el with the :tangle-mode header 
arg set to

(identity (#o444)).

This should be `(identity #o444)` I believe ?



Apologies, I transcribed that incorrectly. I do have `(identity 
#o444)`. 

File permissions are now set before writing to the file, for 
security
reasons. In this case, you remove write permission so emacs 
fails to
write to the file. Perhaps we should try to support this use 
case.


However, even with the previous version, it seems that 
subsequent
tangles should have failed (emacs should fail to delete the 
previous
tangled file). Can you confirm this and explain how you dealt 
with it ?



Subsequent tangles did not fail for me. I just tested by building 
Org from a2cb9b853's parent: f84033b08.
Multiple tangles work with no permission errors on subsequent 
tangles.


Here's my init.org, if that's useful:

https://raw.githubusercontent.com/progfolio/.emacs.d/master/init.org


As a workaround, you could use a file-local
`org-babel-post-tangle-hook` to set file permission. Although
subsequent tangles will still fail.


Unfortunately, I don't have much use for the workaround if 
subsequent tangles will fail.
I currently have an after-save-hook function which tangles the 
files if I've edited any of the
src blocks. It's very convenient and I often will edit/tangle 
files set up like this multiple times.




Bug: org-babel-tangle: persmission denied when tangling [9.4.5 (9.4.5-gbc2659 @ /home/n/.emacs.d/straight/build/org/)]

2021-05-04 Thread No Wayman



I'm tangling my early-init/init.el with the :tangle-mode header 
arg set to (identity (#o444)).
The idea behind this was to prevent myself from accidentally 
editing the tangled source files
instead of the Org files. Unfortunately, since a3cb9b853 there 
seems to be a behavior change for org-babel-tangle which prevents 
this. An abbreviated stacktrace which shows the error when I try 
to tangle my files:


Debugger entered--Lisp error: (file-error "Opening output file" 
"Permission denied" "/home/n/.emacs.d/early-init.el")

 write-region("" nil "~/.emacs.d/early-init.el" nil 0)

Any way to work around this?

Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X 
toolkit, cairo version 1.17.4, Xaw3d scroll bars)

of 2021-05-03
Package: Org mode version 9.4.5 (9.4.5-gbc2659 @ 
/home/n/.emacs.d/straight/build/org/)




Re: Bug: [PATCH] define-minor-mode: prefer keyword args [9.4.5 (9.4.5-ga02a3b @ /home/n/.emacs.d/straight/build/org-plus-contrib/)]

2021-04-27 Thread No Wayman



Kyle Meyer  writes:


Bastien writes:


Hi,

thanks for the patch, we do indeed need to move forward for 
this.


Could you propose the patch against the master branch (not the 
maint
branch, since this is not a bugfix) and perhaps fix *all* 
warnings?


Thanks, but these were already taken care of by 8c29cbdef 
(Backport
commit c45bfd3c4 from Emacs, 2021-04-18), which was merged into 
master

with 664b65344.


Apologies for the noise!



Bug: [PATCH] define-minor-mode: prefer keyword args [9.4.5 (9.4.5-ga02a3b @ /home/n/.emacs.d/straight/build/org-plus-contrib/)]

2021-04-26 Thread No Wayman


Remember to cover the basics, that is, what you expected to happen 
and
what in fact did happen.  You don't know how to make a good 
report?  See


https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


The attached patch updates the calling convention for several 
minor-mode definitions to use keywords in place of the older 
positional arguments. With the native comp branch being merged 
into Emacs' master branch, these types of warnings become more 
apparent to end users, so I figure it's a good idea to stay on top 
of them.


Thanks,
Nick

>From b33e081225a441e43cd03cd127197e4abaa0966d Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Mon, 26 Apr 2021 08:25:25 -0400
Subject: [PATCH] Update define-minor-mode calling convention

* org-list.el, org-src.el, org-table.el, org.el: Migrate minor mode
definitions from positional arguments to keyword args.
---
 lisp/org-list.el  | 2 +-
 lisp/org-src.el   | 2 +-
 lisp/org-table.el | 4 ++--
 lisp/org.el   | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/org-list.el b/lisp/org-list.el
index 98d9e36da..4d84d99bb 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -2296,7 +2296,7 @@ is an integer, 0 means `-', 1 means `+' etc.  If WHICH is
 ;;;###autoload
 (define-minor-mode org-list-checkbox-radio-mode
   "When turned on, use list checkboxes as radio buttons."
-  nil " CheckBoxRadio" nil
+  :lighter " CheckBoxRadio"
   (unless (eq major-mode 'org-mode)
 (user-error "Cannot turn this mode outside org-mode buffers")))
 
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 20acee4e6..cabedecb6 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -682,7 +682,7 @@ This minor mode is turned on in two situations:
 \\{org-src-mode-map}
 
 See also `org-src-mode-hook'."
-  nil " OrgSrc" nil
+  :lighter " OrgSrc"
   (when org-edit-src-persistent-message
 (setq header-line-format
 	  (substitute-command-keys
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 3030751cc..a0c354d86 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -499,7 +499,7 @@ This may be useful when columns have been shrunk."
 ;;;###autoload
 (define-minor-mode org-table-header-line-mode
   "Display the first row of the table at point in the header line."
-  nil " TblHeader" nil
+  :lighter " TblHeader"
   (unless (eq major-mode 'org-mode)
 (user-error "Cannot turn org table header mode outside org-mode buffers"))
   (if org-table-header-line-mode
@@ -1966,7 +1966,7 @@ lines."
 When this mode is active, the field editor window will always show the
 current field.  The mode exits automatically when the cursor leaves the
 table (but see `org-table-exit-follow-field-mode-when-leaving-table')."
-  nil " TblFollow" nil
+  :lighter " TblFollow"
   (if org-table-follow-field-mode
   (add-hook 'post-command-hook 'org-table-follow-fields-with-editor
 		'append 'local)
diff --git a/lisp/org.el b/lisp/org.el
index 675a614e2..f7fd90cf9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15640,7 +15640,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 This mode supports entering LaTeX environment and math in LaTeX fragments
 in Org mode.
 \\{org-cdlatex-mode-map}"
-  nil " OCDL" nil
+  :lighter " OCDL"
   (when org-cdlatex-mode
 (require 'cdlatex)
 (run-hooks 'cdlatex-mode-hook)
-- 
2.31.1



Re: org-capture: question about function to create template

2021-03-15 Thread No Wayman




From: Joost Kremers 
To: emacs-orgmode@gnu.org
Subject: org-capture: question about function to create template
Message-ID: <87eeggh0r5@fastmail.fm>
Content-Type: text/plain

Hi list,

I've been looking at the =org-capture= mechanism a bit more 
closely recently and
noticed that in =org-capture-templates=, the template can also 
be a function.
This looks like a potentially useful feature, but I was 
wondering if there's any
way for this function to access the state of the ongoing capture 
process.


The metadata for the template is stored in the `org-capture-plist' 
variable.



Specifically, it would be useful for me if the function can find 
out the key of

the template that the user selected.


This is stored on the above plist as :key.

There are some corner cases to consider if you have overlapping 
capture processes.
You'll want to look into `org-capture-get' and 
`org-capture-current-plist' as well.


Depending on your needs you may find DOCT useful:

https://www.github.com/progfolio/doct






Re: Bug: org.el has wrong (or none) version [fatal: No names found, cannot describe anything. (fatal: No names found, cannot describe anything. @ /Users/niels/.emacs.d/straight/build/org-agenda/)]

2021-01-06 Thread No Wayman



I don't know anything about straight, but this sounds like what 
you'd
get if you try to generate org-version.el in an Org repo without 
tags.


This is the correct assessment.
Straight has a user option, `straight-vc-git-default-clone-depth', 
which may be customized
to perform shallow clones of N commits. I've ammended the default 
Org recipe to ensure a
full clone is performed. I've contacted Niels on his github to 
illustrate how this can be done on a per-recipe basis as well via 
the `:depth` keyword.


Thank you,

Nick Vollmer



[feature] capture: defcustom for item/checkitem to skip LOGBOOK [9.4.4 (release_9.4.4-159-g9140a7 @ /home/n/.emacs.d/straight/build/org/)]

2020-12-30 Thread No Wayman



Consider the following file named "/tmp/capture-item-logbook.org":

 start capture-item-logbook.org ---
* TODO TASK
SCHEDULED: <2020-12-30 Wed 21:30 ++1d>
:PROPERTIES:
:STYLE:habit
:END:
:LOGBOOK:
- State "DONE"   from "TODO"   [2020-12-29 Tue 21:30]
:END:

:+begin_src emacs-lisp :lexical t
(let ((org-capture-templates
  '(("x" "TASK ITEM" item
 (file+headline "/tmp/capture-item-logbook.org" 
 "TASK")

 (org-capture nil "x"))
#+end_src
 end capture-item-logbook.org ---

Executing the src block places the capture item in the LOGBOOK 
drawer if the entry type is 'item or 'checkitem.
Technically this is the correct behavior according to 
`org-capture-templates' docstring:


item  a plain list item, will be placed in the
   first plain list at the target location.
   Its default template is:
 "- %?"

The documentation on LOGBOOK drawers also mentions:

"You can also arrange for state change notes  and clock times to 
be stored in a ‘LOGBOOK’ drawer.
If you want to store a quick note there, in a similar way to state 
changes, use..." 

Is it worth having an option for org-capture's item/checkitem 
templates to skip targeting drawers?
capture is flexible enough where user's can implement their own 
point-placing function, but I wonder

if skipping drawers is the common case.

Thoughts?






Re: Org Capture Menu cannot be fully viewed

2020-12-16 Thread No Wayman




What is here missing is `org-capture-by-completing-read' so that
user may select among many various capture templates.



Compensating for initial bad design is expensive effort.


Are you suggesting something like this?:

#+begin_src emacs-lisp
(defun +org-capture-read ( arg)
 "completing read interface for org-capture template selection.
ARG is passed to `org-capture'."
 (let (parent)
   (when-let* ((templates
(mapcar (lambda (template)
  (let* ((keys (car template))
 (parentkeys (car parent)))
(if (= (length template) 2)
(progn (setq parent template) 
nil)
  (cons (concat (when (and parentkeys 
  (string-prefix-p parentkeys keys))
  (concat (cadr 
  parent) "/"))

(cadr template))
keys
org-capture-templates))
   (selection (alist-get
   (completing-read "capture template: "
(mapcar #'car (delq 
nil templates))

nil 'require-match)
   templates
   nil nil
   #'string=)))
 (org-capture arg selection
#+end_src emacs-lisp




Re: Org Capture Menu cannot be fully viewed

2020-12-16 Thread No Wayman



Pietru:

If you are extensively using Org's capture templates I suggest 
taking a look at:


https://github.com/progfolio/doct

A brief summary of some of the benefits it provides:

- Allows capture template inheritance
- Checks for certain errors in template declarations *before* 
 capture.

- Automatically computes the keys for nested menus
- Makes per-template hooks/contexts easy to declare.
- Allows for storing custom metadata with templates which can be 
 used within templates
- Declarative: Your template declarations will be easier to 
 read/share.


Taking the list of templates provided earlier as an example,
It could utilize nested menus/inheritance like so:

#+begin_src emacs-lisp :lexical t
(doct
'( :group "Archaeology"
   :file "~/histr/archaeol.org"
   :template "* Site_Type: %?\n %T\n"
   :children (("Research" :keys "r"
   :children (("Bioarchaeological" :keys "b")
  ("Collections"   :keys "c")
  ("Design/Data Recovery"  :keys "d")
  ("Environment"   :keys "e")
  ("Ethnographic"  :keys "g")
  ("Ethnohistoric" :keys "h")
  ("Historic Eval/Testing" :keys "t")))
  ("Survey" :keys "s"
   :children (("Architectural"   :keys "a")
  ("Geophysical" :keys "g")
  ("Reconnaissance"  :keys "r")
  ("Recovery/Excavation" :keys "R")))
  ("Consultation"  :keys "c")
  ("Architectural Documentation"   :keys "d")
  ("Site Stabilization":keys "e")
  ("Ground Disturbance Monitoring" :keys "g")
  ("Heritage Management"   :keys "h")
  ("Records Search/Inventory Checking" :keys "i")
  ("Methodology, Theory, Synthesis":keys "m")
  ("Archaeological Overview"   :keys "o")
  ("Remote Sensing":keys "R")
  ("Site Stewardship Monitoring"   :keys "d"
#+end_src

Each template inherits the :file and :template values.
The keys for the "Research" and "Survey" children templates are 
computed by doct,
so changing the whole groups prefix key only requires a change on 
the parent template's :keys.


I haven't demoed the custom metadata in this example as I don't 
know your exact use case,

but there is an example in the documentation:

https://github.com/progfolio/doct#custom-data


Hope this is useful for you.

~ Nick



Bug: [PATCH] org-agenda: "Invalid face reference: t" errors [9.4 (release_9.4-49-g4b150d @ /home/n/.emacs.d/straight/build/org/)]

2020-10-05 Thread No Wayman


I noticed recently that my message buffer was getting clobbered 
with thousands of Invalid face reference errors when moving point 
around an org-agenda buffer. e.g.:



Invalid face reference: t [4519 times]


Git bisect points to commit 
7a12e149907b5921011710d869b7554c35859c89



org.el (org-display-outline-path): Fix faces of the message

* lisp/org.el (org-display-outline-path): Set :height as the
default face height, and don't change other face attributes.

See a3576543f for a previous fix, and this discussion:



As a workaround, setting `org-agenda-show-outline-path' to nil 
prevents the errors.
I believe the face spec in the call to `add-face-text-property' in 
`org-display-outline-path' is incorrect.
The attached patch replaces it with an anonymous face, which works 
on my end.


>From 4b150d7ca3f8d7d9fe30f6b562b35a5f4072e5e1 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Tue, 6 Oct 2020 01:30:09 -0400
Subject: [PATCH] org.el (org-display-outline-path): Fix invalid face reference
 error

* lisp/org.el (org-display-outline-path): Use an anonymous face when
adding default :height to outline path
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 425e9391b..beb830b36 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8057,7 +8057,7 @@ If JUST-RETURN-STRING is non-nil, return a string, don't display a message."
 	   (and file bfn (concat (file-name-nondirectory bfn) separator))
 	   separator))
 (add-face-text-property 0 (length res)
-			`((t :height ,(face-attribute 'default :height)))
+			`(:height ,(face-attribute 'default :height))
 			nil res)
 (if just-return-string
 	res
-- 
2.28.0



Re: Proposal: do not align tags in Agenda

2020-10-05 Thread No Wayman
I recently proposed a patch that would allow a workaround for this:

https://orgmode.org/list/87ft8gelpn@gmail.com/

It allows custom placement of the habit consistency graph within the agenda.
There is an accompanying example that places the graph on its own line
under the agenda item.
I've attached an org file with my current workaround which advises
`org-habit-insert-consistency-graphs'.


org-habit-single-line-suggestion.org
Description: Lotus Organizer


Re: org-capture at point

2020-10-02 Thread No Wayman



Looks like it was introduced with:

f5573e6a0 org-capture.el: Fix heading's level when inserting a
template "here"


I believe the issue is due to `org-back-to-heading' moving point 
when calculating the heading level.

The attached patch corrects the issue on my end.
Tested by running:

#+begin_src emacs-lisp :lexical t
(dotimes (n 3)
 (let ((org-capture-templates
`(( "e" "test"
entry
(file "/temp/null.org")
,(format "* %d" n)
:immediate-finish t
:no-save t
   (goto-char (point-max))
   (org-capture 0 "e")))
#+end_src

With a buffer containing:

* foo
** one
*** two
 three
*** four

Which results in:

* foo
** one
*** two
 three
*** four
*** 0
*** 1
*** 2

>From 5a35577f22cdc849ebcede6bac7b7f22da7eb16b Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Fri, 2 Oct 2020 14:01:35 -0400
Subject: [PATCH] org-capture.el: Fix heading's position when inserting a
 template "here"

* lisp/org-capture.el (org-capture-place-entry): Fix heading's
position when inserting a template "here" with C-0 M-x org-capture.
---
 lisp/org-capture.el | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 67c58ffdd..020feb4d6 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1150,10 +1150,11 @@ may have been stored before."
  (insert-here?
   ;; FIXME: level should probably set directly within (let ...).
   (setq level (org-get-valid-level
-		   (if (or (org-at-heading-p)
-			   (ignore-errors (org-back-to-heading t)))
-		   (org-outline-level)
-		 1
+   (if (or (org-at-heading-p)
+   (ignore-errors
+			 (save-excursion (org-back-to-heading t
+   (org-outline-level)
+ 1
  ;; Insert as a child of the current entry.
  ((org-capture-get :target-entry-p)
   (setq level (org-get-valid-level
-- 
2.28.0



Re: org-capture at point

2020-09-29 Thread No Wayman




Since org-plus-contrib 20200920, I'm no longer able to get
org-capture to insert a template at the point. Instead, it seems
to place the entry at the appropriate heading level, above the
current heading. Looking at the help page, perhaps it's this
behavior:

This happens with both a custom interactive function that calls
(org-capture 0), and by using a zero prefix.

I'm not able to get this functionality to work:
"When called with a ‘C-0’ (zero) prefix, insert a template at
point."


I can confirm this behavior.
Looks like it was introduced with:

f5573e6a0 org-capture.el: Fix heading's level when inserting a 
template "here"


I tested by running the following:

#+begin_src emacs-lisp :lexical t
(dotimes (n 3)
 (let ((org-capture-templates
`(( "e" "test"
entry
(file "/temp/null.org")
,(format "* %d" n)
:immediate-finish t
:no-save t
   (goto-char (point-max))
   (org-capture 0 "e")))
#+end_src


with Org built from f5573e6a0 output is:

* 1
* 2
* 0

prior to f5573e6a0 (tested on b79fef1da) output is:

* 0
* 1
* 2



Re: Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)]

2020-09-25 Thread No Wayman


No Wayman  writes:

If `v-a' is an empty string, the call to `replace-match' throws 
an

Args out of range error. Similar assignments in that area of the
code use an `and' comparison to guard against this, so perhaps 
it

should be:



(v-L (if (and v-a (string-match l-re v-a))
(replace-match "\\1" nil nil v-a)
  v-a))


See attached patch

>From be476c236e40dd0ba87be9d466dd5cd00a6960b7 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer 
Date: Fri, 25 Sep 2020 03:42:57 -0400
Subject: [PATCH] capture: Fix bare link "Args out of range"

* lisp/org-capture.el (org-capture-fill-template): guard against empty
annotation string
---
 lisp/org-capture.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a6e95f24e..67c58ffdd 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1595,7 +1595,7 @@ The template may still contain \"%?\" for cursor positioning."
 	 (v-l (if (and v-a (string-match l-re v-a))
 		  (replace-match "[[\\1]]" nil nil v-a)
 		v-a))
-	 (v-L (if (or v-a (string-match l-re v-a))
+	 (v-L (if (and v-a (string-match l-re v-a))
 		  (replace-match "\\1" nil nil v-a)
 		v-a))
 	 (v-n user-full-name)
-- 
2.28.0



Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)]

2020-09-25 Thread No Wayman



d06aa486d6c3163b6ef6e9ab665117bd93dff34a introduces the following 
in

`org-capture-fill-template':


(v-L (if (or v-a (string-match l-re v-a))
(replace-match "\\1" nil nil v-a)
  v-a))


If `v-a' is an empty string, the call to `replace-match' throws an 
Args out of range error. Similar assignments in that are of the 
code use an `and' comparison to guard against this, so perhaps it 
should be:




(v-L (if (and v-a (string-match l-re v-a))
(replace-match "\\1" nil nil v-a)
  v-a))



Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.23, cairo version 1.17.3)

of 2020-09-19
Package: Org mode version 9.4 (release_9.4-31-g8c44f2 @ 
/home/n/.emacs.d/straight/build/org/)




Re: [PATCH] org-add-planning-info: respect caller's given time [9.3.7 (release_9.3.7-716-g3d4876 @ /home/n/.emacs.d/straight/build/org/)]

2020-09-10 Thread No Wayman




I'll keep researching and see if I can come up with anything.


This is particularly difficult.
When instrumenting `org-add-planning-info` with edebug the 
resulting timestamp always has its time portion (given and/or 
end-time) ignored.

Tried it with both my personal setup and emacs -q. No luck.
I'm more likely to hack around this than figure out a proper 
patch,
though I still consider it a bug that org-schedule is unable to be 
informed by org-time-given and org-end-time-given I originally 
described.




  1   2   >