Re: strange error exporting to ascii

2023-12-23 Thread Fraga, Eric
On Saturday, 23 Dec 2023 at 09:52, Ihor Radchenko wrote:
> ... me adding one innocent require to ox.el

Complex systems... :-)

Fantastic video, by the way.

-- 
: Eric S Fraga, with org release_9.6.13-1003-g872c1b in Emacs 30.0.50


Re: How to execute Lisp code /after/ a capture template has been filled before it is finalized?

2023-12-23 Thread Ihor Radchenko
Tim Landscheidt  writes:

> I (want to) have a capture template that fills a table and
> then (re-)calculates a cell based on a formula (and aligns
> the table):
> ...
> If I naively append "%(org-table-recalculate t)" to that
> template, the expression gets evaluated immediately when I
> start the capture and the text:
>
> | %![Error: (user-error Not at a table)]
>
> gets appended to the capture buffer /before/ I get prompted
> for the first field.
>
> Looking at the hooks for org-capture-mode, I also thought
> about recalculating the table at finalizing the capture (*1)
> and tried:

> | %(progn (message "org-capture-prepare-finalize-hook = %S" 
> org-capture-prepare-finalize-hook) (add-hook 
> 'org-capture-prepare-finalize-hook (lambda nil (message "Hook called.")) 0 t) 
> (message "org-capture-prepare-finalize-hook = %S" 
> org-capture-prepare-finalize-hook) "")

%(...) expansion is executed _before_ capture template is fully
 calculated. It is generally not designed to side-effect functions.

You can instead use template-local hooks, introduced in Org 9.6. See
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n1270

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



Re: strange error exporting to ascii

2023-12-23 Thread Ihor Radchenko
Ihor Radchenko  writes:

> This is most likely a bug with internal dependencies.
> I need some time to figure out how to approach it.

... me adding one innocent require to ox.el

   https://youtu.be/OpLU__bhu2w?t=237 _//

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



Re: Multi-line headers with longtable

2023-12-23 Thread Ihor Radchenko
Ihor Radchenko  writes:

>> This is using org version 9.5.3 and GNU Emacs 29.0.50 (snapshot).
>
> Confirmed.
> Daniel, could you please take a look?

It took a while, but...
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=539728840

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



Re: [BUG] ox-beamer uses ox-latex private functions

2023-12-23 Thread Ihor Radchenko
Niall Dooley  writes:

> In three separate places (lines 779, 825 and 874) ox-beamer uses
> ox-latex private functions namely:
>
> line779: `org-latex--wrap-label'
> line 825: `org-latex--insert-compiler'
> line 874: `org-latex--format-spec'
>
> I appreciate ox-beamer is a backend backend derived from ox-latex but
> isn't this bad practice if these private functions were to change in
> future?

Both ox-beamer and ox-latex are parts of Org mode. So, there is nothing
wrong with using these internal functions - we have the control over all
parts of Org mode. If we decide to make a breaking change in any
internal function in Org mode, its users in Org source code must be
changed; be it the same file or not.

Not a bug.
Canceled.

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



Re: [BUG] ox-beamer uses ox-latex private functions

2023-12-23 Thread Niall Dooley
On Sat, 23 Dec 2023 at 11:19, Ihor Radchenko  wrote:
> Both ox-beamer and ox-latex are parts of Org mode. So, there is nothing
> wrong with using these internal functions - we have the control over all
> parts of Org mode. If we decide to make a breaking change in any
> internal function in Org mode, its users in Org source code must be
> changed; be it the same file or not.

OK, thanks for the clarification.



How to execute Lisp code /after/ a capture template has been filled before it is finalized?

2023-12-23 Thread Tim Landscheidt
Hi,

I (want to) have a capture template that fills a table and
then (re-)calculates a cell based on a formula (and aligns
the table):

| - Note taken on %U 
|   | Coin | Count
|   |---+|
|   | 0.01 | %^{Number of € 0.01 coins|0} |
|   | 0.02 | %^{Number of € 0.02 coins|0} |
|   | 0.05 | %^{Number of € 0.05 coins|0} |
|   | 0.10 | %^{Number of € 0.10 coins|0} |
|   | 0.20 | %^{Number of € 0.20 coins|0} |
|   | 0.50 | %^{Number of € 0.50 coins|0} |
|   | 1.00 | %^{Number of € 1.00 coins|0} |
|   | 2.00 | %^{Number of € 2.00 coins|0} |
|   |---+|
|   |  | |
|   #+TBLFM: @>$>=(@I$1..@II$1)*(@I$2..@II$2)

If I naively append "%(org-table-recalculate t)" to that
template, the expression gets evaluated immediately when I
start the capture and the text:

| %![Error: (user-error Not at a table)]

gets appended to the capture buffer /before/ I get prompted
for the first field.

Looking at the hooks for org-capture-mode, I also thought
about recalculating the table at finalizing the capture (*1)
and tried:

| %(progn (message "org-capture-prepare-finalize-hook = %S" 
org-capture-prepare-finalize-hook) (add-hook 'org-capture-prepare-finalize-hook 
(lambda nil (message "Hook called.")) 0 t) (message 
"org-capture-prepare-finalize-hook = %S" org-capture-prepare-finalize-hook) "")

but to my surprise, org-capture-prepare-finalize-hook is nil
prior to the add-hook call, has stored the function after
the add-hook call, but in the interactive capture buffer is
nil again (and no message is printed in *Messages*).

How can I evaluate Lisp code after all prompts have been
answered?

TIA,
Tim

(*1)   I would prefer not doing this, as in this case I
   could not see the result prior to finalizing.



[PATCH] lisp/org-agenda.el: Check agenda type earlier

2023-12-23 Thread Morgan Smith
lisp/org-agenda.el (org-agenda-goto-date): Check agenda type earlier.
Also remove redundant error.

When this function is run on a todo agenda the user is given the
undescriptive error "(wrong-type-argument listp "todo")" because we
attempt to parse the 'org-last-args text-property prematurely.  With
this change users will get the much better error "Not allowed in
'todo'-type agenda buffer or component".
---
 lisp/org-agenda.el | 48 +++---
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d4dd6d823..9b75ee943 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8598,31 +8598,31 @@ See also:
(list
 (let ((org-read-date-prefer-future org-agenda-jump-prefer-future))
   (org-read-date
+  (org-agenda-check-type t 'agenda)
   (let* ((day (time-to-days (org-time-string-to-time date)))
-(org-agenda-sticky-orig org-agenda-sticky)
-(org-agenda-buffer-tmp-name (buffer-name))
-(args (get-text-property (min (1- (point-max)) (point)) 
'org-last-args))
-(0-arg (or current-prefix-arg (car args)))
-(2-arg (nth 2 args))
-(with-hour-p (nth 4 org-agenda-redo-command))
-(newcmd (list 'org-agenda-list 0-arg date
-  (org-agenda-span-to-ndays
-   2-arg (org-time-string-to-absolute date))
-  with-hour-p))
-(newargs (cdr newcmd))
-(inhibit-read-only t)
-org-agenda-sticky)
-(if (not (org-agenda-check-type t 'agenda))
-   (error "Not available in non-agenda views")
-  (add-text-properties (point-min) (point-max)
-  `(org-redo-cmd ,newcmd org-last-args ,newargs))
-  (org-agenda-redo)
-  (goto-char (point-min))
-  (while (not (or (= (or (get-text-property (point) 'day) 0) day)
- (save-excursion (move-beginning-of-line 2) (eobp
-   (move-beginning-of-line 2))
-  (setq org-agenda-sticky org-agenda-sticky-orig
-   org-agenda-this-buffer-is-sticky org-agenda-sticky
+ (org-agenda-sticky-orig org-agenda-sticky)
+ (org-agenda-buffer-tmp-name (buffer-name))
+ (args (get-text-property (min (1- (point-max)) (point))
+  'org-last-args))
+ (0-arg (or current-prefix-arg (car args)))
+ (2-arg (nth 2 args))
+ (with-hour-p (nth 4 org-agenda-redo-command))
+ (newcmd (list 'org-agenda-list 0-arg date
+   (org-agenda-span-to-ndays
+2-arg (org-time-string-to-absolute date))
+   with-hour-p))
+ (newargs (cdr newcmd))
+ (inhibit-read-only t)
+ org-agenda-sticky)
+(add-text-properties (point-min) (point-max)
+ `(org-redo-cmd ,newcmd org-last-args ,newargs))
+(org-agenda-redo)
+(goto-char (point-min))
+(while (not (or (= (or (get-text-property (point) 'day) 0) day)
+(save-excursion (move-beginning-of-line 2) (eobp
+  (move-beginning-of-line 2))
+(setq org-agenda-sticky org-agenda-sticky-orig
+  org-agenda-this-buffer-is-sticky org-agenda-sticky)))
 
 (defun org-agenda-goto-today ()
   "Go to today's date in the agenda buffer.
-- 
2.41.0




[PATCH] * doc/org-manual.org: Fix typo

2023-12-23 Thread Morgan Smith
doc/org-manual.org: 'org-hierarchical-checkbox-statistics' ->
'org-checkbox-hierarchical-statistics'
---
 doc/org-manual.org | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index a5cd9735e..8d74fa332 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -4724,7 +4724,7 @@ If all child checkboxes are checked, the parent checkbox 
is also checked.
 #+cindex: statistics, for checkboxes
 #+cindex: checkbox statistics
 #+cindex: @samp{COOKIE_DATA}, property
-#+vindex: org-hierarchical-checkbox-statistics
+#+vindex: org-checkbox-hierarchical-statistics
 The =[2/4]= and =[1/3]= in the first and second line are cookies
 indicating how many checkboxes present in this entry have been checked
 off, and the total number of checkboxes present.  This can give you an
@@ -4732,7 +4732,7 @@ idea on how many checkboxes remain, even without opening 
a folded
 entry.  The cookies can be placed into a headline or into (the first
 line of) a plain list item.  Each cookie covers checkboxes of direct
 children structurally below the headline/item on which the cookie
-appears[fn:: Set the variable ~org-hierarchical-checkbox-statistics~
+appears[fn:: Set the variable ~org-checkbox-hierarchical-statistics~
 if you want such cookies to count all checkboxes below the cookie, not
 just those belonging to direct children.].  You have to insert the
 cookie yourself by typing either =[/]= or =[%]=.  With =[/]= you get
-- 
2.41.0




How can I use org-add-note with emacsclient?

2023-12-23 Thread equal . moon0346
Hello Org mode users,

I'm trying to figure out how to start a note (C-c C-z) on the currently clocked 
task from emacsclient. Here's what I have so far:

Start Emacs:

emacs --fg-daemon=test -Q -nw --eval "(setq-default org-agenda-files 
'(\"~/org-agenda-files\"))"

Connect to the daemon in a different terminal, load the agenda:

emacsclient -s test -nw --eval '(org-agenda nil "a")' 

^ In this frame I'll also clock in to some heading with I in the agenda. Then I 
close the terminal.

In another terminal, try to start a new note on the currently clocked task:

emacsclient -s test -nw --eval '(progn (org-clock-goto) (org-add-note))'

This seems to have no effect. Oddly, if I paste this into M-:, it works fine. 
I've tried a number of things with e.g. plain capture templates that run the 
above code :after-finalize, using call-interactively, etc. After a cursory 
reading through the info manual on interactivity I find I'm still a bit lost. 
Can anyone explain what I'm doing wrong and hopefully point me to the right 
manual page to read on this?

Thanks and Happy Holidays!

Moon