Re: [PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands

2023-07-04 Thread Ihor Radchenko
Evgenii Klimov  writes:

> Maybe I got it wrong, but I tried to follow the docstring for
> `org-metaleft'. And I don't see here the use of the return value either:
>
> #+begin_example
>   (defun org-metaleft ( _arg)
> "...
> This function runs the hook `org-metaleft-hook' as a first step,
> and returns at first non-nil value."
> ...)
> #+end_example

> Should I keep it like this?
>   This function runs the hook `org-shiftmetaleft-hook' as a first
>   step, and `org-shiftmetaleft-final-hook' as the penultimate step.

Apparently the original wording is quite confusing.
What it is supposed to say is:

This function runs the functions in `org-metaleft-hook' one by one
as a first step, and exits immediately if a function from the hook
returns non-nil.

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



Re: [PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands

2023-07-03 Thread Evgenii Klimov


Ihor Radchenko  writes:

[...]
>> +individual commands for more information.
>> +
>> +This function runs the hook `org-shiftmetaleft-hook' as a first
>> +step, `org-shiftmetaleft-final-hook' as the penultimate step, and
>> +returns at first non-nil value."
>
> Upon looking closer, I realized that you also defined return value of
> the function here.  Is there any particular reason for this? The return
> value is currently not defined and supposed to be discarded.

Maybe I got it wrong, but I tried to follow the docstring for
`org-metaleft'. And I don't see here the use of the return value either:

#+begin_example
  (defun org-metaleft ( _arg)
"...
This function runs the hook `org-metaleft-hook' as a first step,
and returns at first non-nil value."
...)
#+end_example

Should I keep it like this?
  This function runs the hook `org-shiftmetaleft-hook' as a first
  step, and `org-shiftmetaleft-final-hook' as the penultimate step.



Re: [PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands

2023-07-03 Thread Ihor Radchenko
Evgenii Klimov  writes:

> ...

Thanks for the update.

Few comments.

First, please add Changelog entry for etc/ORG-NEWS.

> +(defvar org-metaleft-final-hook nil
> +  "Hook for functions attaching themselves to `M-left'.
> +See `org-ctrl-c-ctrl-c-hook' for more information.")

Note that unlike the docstring your added, `org-shiftup-final-hook'
specifies when the hook is executed:

(defvar org-shiftup-final-hook nil
  "Hook for functions attaching themselves to `S-up'.
This one runs after all other options except shift-select have been excluded.
See `org-ctrl-c-ctrl-c-hook' for more information.")

It is better to follow the pattern and clarify the purpose of the hook
better instead of leaving docstrings for both the -final and other hook
same.

> +individual commands for more information.
> +
> +This function runs the hook `org-shiftmetaleft-hook' as a first
> +step, `org-shiftmetaleft-final-hook' as the penultimate step, and
> +returns at first non-nil value."

Upon looking closer, I realized that you also defined return value of
the function here.  Is there any particular reason for this? The return
value is currently not defined and supposed to be discarded.

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