emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Evgenii Klimov <eugene.dev@lipklim.org>
To: emacs-orgmode@gnu.org
Cc: Evgenii Klimov <eugene.dev@lipklim.org>
Subject: [PATCH 1/3] lisp/org.el: Add final hooks to the M-cursor commands
Date: Thu, 29 Jun 2023 23:31:27 +0100	[thread overview]
Message-ID: <20230629223129.17191-2-eugene.dev@lipklim.org> (raw)
In-Reply-To: <20230629223129.17191-1-eugene.dev@lipklim.org>

* lisp/org.el (org-metaleft-final-hook, org-metaright-final-hook,
org-metaup-final-hook, org-metadown-final-hook): Define final hooks
for S-cursor commands.
(org-metaleft, org-metaright, org-metaup, org-metadown): Add final
hooks to M-commands and document them in the docstring.
---
 lisp/org.el | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4063ba98f..b396456a2 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16714,15 +16714,27 @@ before indentation and \t insertion takes place.")
 (defvar org-metaleft-hook nil
   "Hook for functions attaching themselves to `M-left'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metaleft-final-hook nil
+  "Hook for functions attaching themselves to `M-left'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metaright-hook nil
   "Hook for functions attaching themselves to `M-right'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metaright-final-hook nil
+  "Hook for functions attaching themselves to `M-right'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metaup-hook nil
   "Hook for functions attaching themselves to `M-up'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metaup-final-hook nil
+  "Hook for functions attaching themselves to `M-up'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metadown-hook nil
   "Hook for functions attaching themselves to `M-down'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metadown-final-hook nil
+  "Hook for functions attaching themselves to `M-down'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetaleft-hook nil
   "Hook for functions attaching themselves to `M-S-left'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
@@ -16879,7 +16891,8 @@ default `backward-word'.  See the individual commands for more
 information.
 
 This function runs the hook `org-metaleft-hook' as a first step,
-and returns at first non-nil value."
+`org-metaleft-final-hook' as the penultimate step, and returns at
+first non-nil value."
   (interactive "P")
   (cond
    ((run-hook-with-args-until-success 'org-metaleft-hook))
@@ -16902,6 +16915,7 @@ and returns at first non-nil value."
 	       (org-at-item-p))))
     (when (org-check-for-hidden 'items) (org-hidden-tree-error))
     (call-interactively 'org-outdent-item))
+   ((run-hook-with-args-until-success 'org-metaleft-final-hook))
    (t (call-interactively 'backward-word))))
 
 (defun org-metaright (&optional _arg)
@@ -16915,7 +16929,8 @@ With no specific context, calls the Emacs default `forward-word'.
 See the individual commands for more information.
 
 This function runs the hook `org-metaright-hook' as a first step,
-and returns at first non-nil value."
+`org-metaright-final-hook' as the penultimate step, and returns
+at first non-nil value."
   (interactive "P")
   (cond
    ((run-hook-with-args-until-success 'org-metaright-hook))
@@ -16940,6 +16955,7 @@ and returns at first non-nil value."
 	       (org-at-item-p))))
     (when (org-check-for-hidden 'items) (org-hidden-tree-error))
     (call-interactively 'org-indent-item))
+   ((run-hook-with-args-until-success 'org-metaright-final-hook))
    (t (call-interactively 'forward-word))))
 
 (defun org-check-for-hidden (what)
@@ -16973,7 +16989,11 @@ this function returns t, nil otherwise."
   "Move subtree up or move table row up.
 Calls `org-move-subtree-up' or `org-table-move-row' or
 `org-move-item-up', depending on context.  See the individual commands
-for more information."
+for more information.
+
+This function runs the hook `org-metaup-hook' as a first step,
+`org-metaup-final-hook' as the penultimate step, and returns at
+first non-nil value."
   (interactive "P")
   (cond
    ((run-hook-with-args-until-success 'org-metaup-hook))
@@ -17030,13 +17050,18 @@ for more information."
     (org-drag-element-backward))
    ((org-at-heading-p) (call-interactively 'org-move-subtree-up))
    ((org-at-item-p) (call-interactively 'org-move-item-up))
+   ((run-hook-with-args-until-success 'org-metaup-final-hook))
    (t (org-drag-element-backward))))
 
 (defun org-metadown (&optional _arg)
   "Move subtree down or move table row down.
 Calls `org-move-subtree-down' or `org-table-move-row' or
 `org-move-item-down', depending on context.  See the individual
-commands for more information."
+commands for more information.
+
+This function runs the hook `org-metadown-hook' as a first step,
+`org-metadown-final-hook' as the penultimate step, and returns at
+first non-nil value."
   (interactive "P")
   (cond
    ((run-hook-with-args-until-success 'org-metadown-hook))
@@ -17089,6 +17114,7 @@ commands for more information."
     (org-drag-element-forward))
    ((org-at-heading-p) (call-interactively 'org-move-subtree-down))
    ((org-at-item-p) (call-interactively 'org-move-item-down))
+   ((run-hook-with-args-until-success 'org-metadown-final-hook))
    (t (org-drag-element-forward))))
 
 (defun org-shiftup (&optional arg)
-- 
2.34.1



  reply	other threads:[~2023-06-30 11:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 22:31 Add final hooks to S-/M-/S-M-cursor commands Evgenii Klimov
2023-06-29 22:31 ` Evgenii Klimov [this message]
2023-06-29 22:31 ` [PATCH 2/3] lisp/org.el: Fix docstring for S-cursor commands Evgenii Klimov
2023-06-29 22:31 ` [PATCH 3/3] lisp/org.el: Add final hooks to the S-M-cursor commands Evgenii Klimov
2023-07-01 10:40 ` Add final hooks to S-/M-/S-M-cursor commands Ihor Radchenko
2023-07-01 12:16   ` Evgenii Klimov
2023-07-01 12:22     ` Ihor Radchenko
2023-07-01 13:19   ` [PATCH v2] lisp/org.el: " Evgenii Klimov
2023-07-03 12:44     ` Ihor Radchenko
2023-07-03 19:40       ` Evgenii Klimov
2023-07-04 11:34         ` Ihor Radchenko
2023-07-04 22:28       ` [PATCH v3] " Evgenii Klimov
2023-07-05 10:46         ` Ihor Radchenko
2023-07-05 11:14           ` Evgenii Klimov
2023-07-05 11:27             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230629223129.17191-2-eugene.dev@lipklim.org \
    --to=eugene.dev@lipklim.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).