Re: [PATCH] lisp/ob-shell.el: Also override explicit-shell-file-name

2024-03-15 Thread Aaron Zeng
Thanks for the merge!

On Fri, Mar 15, 2024, at 17:38, Matt wrote:
> Finally had time to commit it. 
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0e2a9524dc6da8b4d60672e85aba74076baac211
>
> Nice catch and thanks for your contribution!
>
> --
> Matt Trzcinski
> Emacs Org contributor (ob-shell)
> Learn more about Org mode at https://orgmode.org
> Support Org development at https://liberapay.com/org-mode



[BUG] Bad interaction between org-add-log-setup and org-with-remote-undo [9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]

2023-08-04 Thread Aaron Zeng
Hi folks,

It seems there is a bad interaction between org-add-log-setup and
org-with-remote-undo, such that org-agenda-undo does not function
correctly.  For example,

1. Enable logging on reschedule, by setting `org-log-reschedule' to
   `time'.
2. Reschedule an already-scheduled TODO item through an agenda buffer,
   by pressing C-c C-s (org-schedule).
3. Press C-/ (org-agenda-undo) while still in the agenda buffer.

This has the unfortunate consequence of undoing all of the changes in
the agenda buffer but only a subset of the changes in the source
buffer where the task was defined (namely, the "rescheduled" log entry
is removed but the timestamp is not restored to the original time).

I believe this is because org-with-remote-undo creates an undo
boundary after executing the body of the macro, but org-add-log-setup
makes changes to the buffer in post-command-hook, after the
undo-boundary is created.  This means that /two/ undoable changes in
the source buffer now logically correspond to the same change in the
agenda buffer, which org-agenda-undo does not handle correctly.

Some commands do not have this issue, such as org-agenda-todo, which
calls org-add-log-note instead of org-add-log-setup and therefore does
not make use of post-command-hook.  This seems to be intentional:

;; Make sure that log is recorded in current undo.
(when (and org-log-setup
   (not (eq org-log-note-how 'note)))
  (org-add-log-note))

I wonder if org-add-log-setup should be removed and refactored away,
or if org-with-remote-undo should not be creating an undo boundary
(which sounds redundant with the automatic ones created by the command
loop?).

Emacs  : GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 
Version 12.6.6 (Build 21G646))
of 2023-07-30
Package: Org mode version 9.6.6 (release_9.6.6 @ 
/Applications/Emacs.app/Contents/Resources/lisp/org/ 
)



[PATCH] Fix bug in orgtbl-self-insert-command when used with evil-escape

2023-04-06 Thread Aaron Zeng
There appears to be a bug in orgtbl-self-insert-command, which uses 
last-input-event instead of last-command-event.  self-insert-command itself 
uses the latter variable.

Reproduction steps:

1. Enable evil-mode and evil-escape-mode
2. Set `evil-escape-key-sequence' to "fd" (the default)
3. In an empty text-mode buffer with orgtbl-mode enabled:
   a. Press `f RET' slowly; this inserts f and then a newline
   b. Press `f RET` quickly; this inserts just two newlines

After step 3b, view-lossage contains:

 f ;; orgtbl-self-insert-command
   ;; orgtbl-hijacker-command-100

With the patch, the above steps correctly insert f and then a newline.

>From 8ae98a51a15bdd4d4c2014e7870ab36afd03562d Mon Sep 17 00:00:00 2001
From: "Aaron L. Zeng" 
Date: Mon, 3 Apr 2023 13:46:26 -0400
Subject: [PATCH 1/2] org-table: Refactor away unnecessary variable

* org-table.el (orgtbl-self-insert-command): Remove unnecessary
intermediate variable.  `(cdr nil)` is nil.

TINYCHANGE
---
 lisp/org-table.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 97120fffd..f477d74a0 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -5408,11 +5408,9 @@ overwritten, and the table is not marked as requiring realignment."
 	(self-insert-command N))
 (setq org-table-may-need-update t)
 (let* (orgtbl-mode
-	   a
 	   (cmd (or (key-binding
 		 (or (and (listp function-key-map)
-			  (setq a (assoc last-input-event function-key-map))
-			  (cdr a))
+			  (cdr (assoc last-input-event function-key-map)))
 			 (vector last-input-event)))
 		'self-insert-command)))
   (call-interactively cmd)
-- 
2.30.2

>From 4ca188a09c2f628a03b5731b1725bd603620227a Mon Sep 17 00:00:00 2001
From: "Aaron L. Zeng" 
Date: Mon, 3 Apr 2023 13:53:57 -0400
Subject: [PATCH 2/2] org-table: Fix incorrect input when used with evil-escape

* org-table.el (org-self-insert-command): Use `last-command-event'
instead of `last-input-event'.  Using `last-input-event' causes
problems in the presence of `evil-escape'.  Consider a buffer that has
`orgtbl-mode' enabled while evil-escape is in use.  Assume the
evil-escape sequence is "fd".  Typing "f RET" will instead insert "RET
RET" into the buffer, since `last-input-event' is "RET", but
`last-command-event' is "f".

TINYCHANGE
---
 lisp/org-table.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index f477d74a0..e0cc84ed6 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -5410,8 +5410,8 @@ overwritten, and the table is not marked as requiring realignment."
 (let* (orgtbl-mode
 	   (cmd (or (key-binding
 		 (or (and (listp function-key-map)
-			  (cdr (assoc last-input-event function-key-map)))
-			 (vector last-input-event)))
+			  (cdr (assoc last-command-event function-key-map)))
+			 (vector last-command-event)))
 		'self-insert-command)))
   (call-interactively cmd)
   (if (and org-self-insert-cluster-for-undo
-- 
2.30.2



Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions

2023-02-08 Thread Aaron Zeng
New patch looks good.  Thanks!

On Wed, Feb 8, 2023 at 05:09 Ihor Radchenko  wrote:

> "Aaron L. Zeng"  writes:
>
> > * org-agenda.el (org--batch-store-agenda-views): Fix treatment of
> > lambda functions used as custom agenda commands.
> > `org-agenda-custom-commands' entries may specify a custom function
> > instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
> > behaved differently from `org-agenda' when that custom function was
> > defined as a lambda rather than a symbol, incorrectly treating the
> > lambda form as a list of agenda commands.  Instead, use the same test
> > as `org-agenda' does to determine whether the command is a series.
>
> Thanks for the updated patch!
> I am attaching amended version with the comment placed closer to where
> the custom command list is being used.
> I also added TINYCHANGE cookie because you are not listed as a
> contributor with FSF copyright assignment.
>
> Let me know if you have any objections.
>
>
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions

2023-02-07 Thread Aaron Zeng
Thanks Ihor, I sent a new patch with your comment included verbatim, and
also added a ChangeLog entry.

On Tue, Feb 7, 2023 at 12:47 PM Aaron L. Zeng  wrote:

> * org-agenda.el (org--batch-store-agenda-views): Fix treatment of
> lambda functions used as custom agenda commands.
> `org-agenda-custom-commands' entries may specify a custom function
> instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
> behaved differently from `org-agenda' when that custom function was
> defined as a lambda rather than a symbol, incorrectly treating the
> lambda form as a list of agenda commands.  Instead, use the same test
> as `org-agenda' does to determine whether the command is a series.
> ---
>  lisp/org-agenda.el | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 1d1f2271b..49f93c338 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -3525,10 +3525,13 @@ This ensures the export commands can easily use
> it."
>(let ((cmds (org-agenda-normalize-custom-commands
> org-agenda-custom-commands))
>  (pop-up-frames nil)
>  (dir default-directory)
> -cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
> +cmd thiscmdkey thiscmdcmd match files opts cmd-or-set
> +seriesp bufname)
>  (save-window-excursion
>(while cmds
> (setq cmd (pop cmds)
> +  ;; series: (0:key 1:desc 2:(cmd1 cmd2 ...)
> 3:general-settings 4:files)
> +  ;; non-series: (0:key 1:desc 2:type 3:match4:settings
>5:files)
>   thiscmdkey (car cmd)
>   thiscmdcmd (cdr cmd)
>   match (nth 2 thiscmdcmd)
> @@ -3538,8 +3541,9 @@ This ensures the export commands can easily use it."
>   (format "*Org Agenda(%s)*" thiscmdkey))
> org-agenda-buffer-name)
>   cmd-or-set (nth 2 cmd)
> - opts (nth (if (listp cmd-or-set) 3 4) cmd)
> - files (nth (if (listp cmd-or-set) 4 5) cmd))
> + seriesp (not (or (symbolp cmd-or-set) (functionp
> cmd-or-set)))
> + opts (nth (if seriesp 3 4) cmd)
> + files (nth (if seriesp 4 5) cmd))
> (if (stringp files) (setq files (list files)))
> (when files
>   (let* ((opts (append org-agenda-exporter-settings opts))
> --
> 2.38.1
>
>


Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1

2023-01-24 Thread Aaron Zeng
Much obliged :)

On Tue, Jan 24, 2023 at 1:20 PM Ihor Radchenko  wrote:

> Aaron Zeng  writes:
>
> > Hi Ihor, I just noticed that this patch only fixes one of the lines
> calling
> > `string-pad'.  There is another callsite below which needs to be removed.
>
> Oops. Now, should be good.
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=20ee7b85ebc0e3e08805b1e9e3e824f50347340e
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>


Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1

2023-01-24 Thread Aaron Zeng
Hi Ihor, I just noticed that this patch only fixes one of the lines calling
`string-pad'.  There is another callsite below which needs to be removed.

On Tue, Jan 24, 2023 at 11:30 AM Aaron Zeng  wrote:

> Thanks for the quick response, Ihor!
>
> On Tue, Jan 24, 2023 at 4:23 AM Ihor Radchenko 
> wrote:
>
>> "Aaron L. Zeng"  writes:
>>
>> > * org-compat.el (org-string-pad): Add compatibility function
>> > `org-string-pad' for `string-pad', introduced in Emacs 28.1.
>> >
>> > * org-agenda.el (org-fix-agenda-info): Use `org-string-pad' rather
>> > than `string-pad'.
>> >
>> > Since this is more-or-less just copying string-pad's definition from
>> > subr-x.el, I think this qualifies for TINYCHANGE.
>>
>> Thanks!
>> This issue has not been caught by byte-compilation.
>>
>> I applied an alternative fix not using `string-pad' at all.
>> Canceled.
>>
>>
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5bbb97f3df9788646b8d48d60e8b8ea06566e05f
>>
>> --
>> Ihor Radchenko // yantar92,
>> Org mode contributor,
>> Learn more about Org mode at <https://orgmode.org/>.
>> Support Org development at <https://liberapay.com/org-mode>,
>> or support my work at <https://liberapay.com/yantar92>
>>
>


Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1

2023-01-24 Thread Aaron Zeng
Thanks for the quick response, Ihor!

On Tue, Jan 24, 2023 at 4:23 AM Ihor Radchenko  wrote:

> "Aaron L. Zeng"  writes:
>
> > * org-compat.el (org-string-pad): Add compatibility function
> > `org-string-pad' for `string-pad', introduced in Emacs 28.1.
> >
> > * org-agenda.el (org-fix-agenda-info): Use `org-string-pad' rather
> > than `string-pad'.
> >
> > Since this is more-or-less just copying string-pad's definition from
> > subr-x.el, I think this qualifies for TINYCHANGE.
>
> Thanks!
> This issue has not been caught by byte-compilation.
>
> I applied an alternative fix not using `string-pad' at all.
> Canceled.
>
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5bbb97f3df9788646b8d48d60e8b8ea06566e05f
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: [PATCH] org-todo-yesterday: Fix interactive arg when in agenda buffer

2022-05-25 Thread Aaron Zeng
Thanks Ihor!  And, noted for the future.

On Thu, May 26, 2022 at 12:34 AM Ihor Radchenko  wrote:

> "Aaron L. Zeng"  writes:
>
> > (I'm resubmitting this patch because my previous submission was
> in-reply-to
> > another email which I suspect was ignored.  Would love to get this
> relatively
> > simple bug fixed.  Thanks!)
> >
> > * lisp/org.el (org-todo-yesterday): Fix an incorrect use of apply when
> > org-todo-yesterday intends to call org-agenda-todo-yesterday with the
> > same interactive arg.  Before this change, the command incorrectly set
> > the todo state of the task to blank when called with C-u C-u C-u in an
> > agenda buffer (supposed to bypass any blocked checkboxes/subtasks).
>
> Thanks! Applied onto main via 713c15d85.
>
> I have made amendments to the commit message. Function/symbol names
> should be quoted as `org-todo-yesterday'.
>
> Best,
> Ihor
>


[PATCH] org-todo-yesterday: Fix interactive arg when in agenda buffer

2022-03-18 Thread Aaron Zeng
The following changes since commit 668205f7693e028f15240ffc043e037b411daf81:

  Backport commit d52c929e3 from Emacs (2022-03-02 23:02:50 -0500)

are available in the Git repository at:

  g...@github.com:bcc32/org-mode.git bugfix

for you to fetch changes up to 0a073f0b0d7b0eb72f41e2edde4e070ca431ff71:

  org-todo-yesterday: Fix interactive arg when in agenda buffer
(2022-03-18 23:31:37 -0400)


Aaron L. Zeng (1):
  org-todo-yesterday: Fix interactive arg when in agenda buffer

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



Re: Bug: Infinite loop in org-agenda-dim-blocked-tasks

2021-05-10 Thread Aaron Zeng
Hi Bastien,

Unfortunately, I think this bug is still there (I also didn't see any
commits addressing it, but I could have missed it in the log
somewhere).  I tried the master branch but was still able to reproduce
the bug using `emacs -q -L ~/src/org-mode/lisp`:

After using `customize-set-variable` to enable
org-enforce-todo-checkbox-dependencies, with the following agenda
file:

* TODO blocked task
  - [ ] checkbox

Trying to clock into the task from org-todo-list results in an infinite loop.

Thanks,
Aaron



Re: [O] Bug: org-clock-cancel doesn't set org-clock-current-task correctly [9.2.3 (9.2.3-23-g967801-elpaplus @ /.emacs.d/elpa/26.2/develop/org-plus-contrib-20190603/)]

2019-06-10 Thread Aaron Zeng
Yes, I still see this with a vanilla config.  I tried with [emacs -q] and
the builtin org mode (9.1.9), as well as with 967801.

On Mon, Jun 10, 2019 at 10:43 PM Kyle Meyer  wrote:

> Aaron Zeng  writes:
>
> > (I'm running org mode from the Spacemacs org layer, which includes the
> > org-plus-contrib package).
> >
> > Reproduction:
> > 1. Create a new entry "* TODO Temp"
> > 2. Clock in under that entry
> > 3. Cancel the clock
> > 4. [M-x describe-variable org-clock-current-task] is still set to
> > "Temp" instead of being nil, which is what I expected.
> > 5. In Spacemacs with the spaceline-all-the-icons mode line, "Temp"
> > still appears in the "currently clocked task" position.
> >
> > Emacs  : GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
> >  of 2019-04-13
> > Package: Org mode version 9.2.3 (9.2.3-23-g967801-elpaplus @
> > /.emacs.d/elpa/26.2/develop/org-plus-contrib-20190603/)
>
> Following your steps on commit 967801 (which matches your version
> output), I'm unable to trigger the issue (i.e. org-clock-current-task is
> nil following 3).
>
> If you try with a vanilla configuration and Org loaded, do you still see
> the issue?  Perhaps there's an interaction with a configuration value.
>
> --
> Kyle
>


[O] Bug: org-clock-cancel doesn't set org-clock-current-task correctly [9.2.3 (9.2.3-23-g967801-elpaplus @ /.emacs.d/elpa/26.2/develop/org-plus-contrib-20190603/)]

2019-06-10 Thread Aaron Zeng
(I'm running org mode from the Spacemacs org layer, which includes the
org-plus-contrib package).

Reproduction:
1. Create a new entry "* TODO Temp"
2. Clock in under that entry
3. Cancel the clock
4. [M-x describe-variable org-clock-current-task] is still set to
"Temp" instead of being nil, which is what I expected.
5. In Spacemacs with the spaceline-all-the-icons mode line, "Temp"
still appears in the "currently clocked task" position.

Emacs  : GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
 of 2019-04-13
Package: Org mode version 9.2.3 (9.2.3-23-g967801-elpaplus @
/.emacs.d/elpa/26.2/develop/org-plus-contrib-20190603/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-babel-after-execute-hook '(spacemacs/ob-fix-inline-images)
 org-insert-heading-respect-content t
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-agenda-tags-todo-honor-ignore-options t
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-refile-targets '((nil :maxlevel . 10) (org-agenda-files :maxlevel . 10))
 org-src-tab-acts-natively t
 org-imenu-depth 8
 org-download-annotate-function 'org-download-annotate-default
 org-mode-hook '(org-clock-load #[0 "\301\211 \207"
[imenu-create-index-function org-imenu-get-tree] 2] #[0
"\300\301\302\303\304$\207" [add-hook change-major-mode-hook
org-show-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook
change-major-mode-hook org-babel-show-result-all append local] 5]
org-babel-result-hide-spec org-babel-hide-all-hashes
spacemacs/org-setup-evil-surround spacemacs/load-yasnippet
toc-org-enable
 org-download-enable org-bullets-mode
dotspacemacs//prettify-spacemacs-docs
spacemacs//org-babel-do-load-languages spacemacs//evil-org-mode
org-eldoc-load spacemacs//init-company-org-mode company-mode)
 org-clock-persist t
 org-outline-path-complete-in-steps nil
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-agenda-restore-windows-after-quit t
 org-confirm-elisp-link-function 'yes-or-no-p
 org-startup-indented t
 org-startup-with-inline-images t
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-babel-load-languages '((shell . t) (python . t) (perl . t) (sql .
t) (C . t) (emacs-lisp . t))
 org-log-done 'time
 org-export-backends '(ascii html icalendar latex org texinfo)
 org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" .
php) ("C" . c) ("C++" . c++) ("asymptote" . asy) ("bash" . sh)
("beamer" . latex) ("calc" . fundamental) ("cpp" . c++) ("ditaa" .
artist) ("dot" . fundamental) ("elisp" . emacs-lisp)
  ("ocaml" . tuareg) ("screen" . shell-script)
("shell" . sh) ("sqlite" . sql))
 org-occur-hook '(org-first-headline-recenter)
 org-log-into-drawer t
 org-agenda-todo-ignore-time-comparison-use-seconds t
 org-ctrl-c-ctrl-c-hook '(spacemacs//counsel-org-ctrl-c-ctrl-c-org-tag)
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-show-empty-lines
org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
 org-babel-tangle-lang-exts '(("D" . "d") ("C++" . "cpp") ("perl" .
"pl") ("python" . "py") ("emacs-lisp" . "el") ("elisp" . "el"))
 org-refile-use-outline-path 'file
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("id" :follow org-id-open) ("eww" :follow eww
:store org-eww-store-link) ("rmail" :follow org-rmail-open :store
org-rmail-store-link) ("mhe" :follow org-mhe-open :store
org-mhe-store-link)
   ("irc" :follow org-irc-visit :store
org-irc-store-link :export org-irc-export) ("info" :follow
org-info-open :export org-info-export :store org-info-store-link)
("gnus" :follow org-gnus-open :store org-gnus-store-link)
   ("docview" :follow org-docview-open :export
org-docview-export :store org-docview-store-link) ("bibtex" :follow
org-bibtex-open :store org-bibtex-store-link)
   ("bbdb" :follow org-bbdb-open :export
org-bbdb-export :complete org-bbdb-complete-link :store
org-bbdb-store-link) ("w3m" :store org-w3m-store-link) ("file+sys")
("file+emacs")
   ("orgit-rev" :store orgit-rev-store :follow
orgit-rev-open :export orgit-rev-export :complete
orgit-rev-complete-link) ("orgit-log" :store orgit-log-store :follow
orgit-log-open :export orgit-log-export :complete
orgit-log-complete-link)
   ("orgit" :store orgit-status-store :follow
orgit-status-open :export orgit-status-export :complete
orgit-status-complete-link) ("doi" :follow org--open-doi-link)
("elisp" :follow org--open-elisp-link) ("file" :complete
org-file-complete-link)