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 3/3] lisp/org.el: Add final hooks to the S-M-cursor commands
Date: Thu, 29 Jun 2023 23:31:29 +0100	[thread overview]
Message-ID: <20230629223129.17191-4-eugene.dev@lipklim.org> (raw)
In-Reply-To: <20230629223129.17191-1-eugene.dev@lipklim.org>

* lisp/org.el (org-shiftmetaleft-final-hook,
org-shiftmetaright-final-hook, org-shiftmetaup-final-hook,
org-shiftmetadown-final-hook): Define final hooks for the S-M-cursor
commands.
(org-shiftmetaleft, org-shiftmetaright, org-shiftmetaup,
org-shiftmetadown): Add final hooks to the S-M-cursor commands and
document hooks in the docstring.
---
 lisp/org.el | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index bf61062b1..326d3eed9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16738,15 +16738,27 @@ 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.")
+(defvar org-shiftmetaleft-final-hook nil
+  "Hook for functions attaching themselves to `M-S-left'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetaright-hook nil
   "Hook for functions attaching themselves to `M-S-right'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetaright-final-hook nil
+  "Hook for functions attaching themselves to `M-S-right'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetaup-hook nil
   "Hook for functions attaching themselves to `M-S-up'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetaup-final-hook nil
+  "Hook for functions attaching themselves to `M-S-up'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetadown-hook nil
   "Hook for functions attaching themselves to `M-S-down'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetadown-final-hook nil
+  "Hook for functions attaching themselves to `M-S-down'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metareturn-hook nil
   "Hook for functions attaching themselves to `M-RET'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
@@ -16814,7 +16826,11 @@ When ARG is a numeric prefix, show contents of this level."
   "Promote subtree or delete table column.
 Calls `org-promote-subtree', `org-outdent-item-tree', or
 `org-table-delete-column', depending on context.  See the
-individual commands for more information."
+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."
   (interactive)
   (cond
    ((and (eq system-type 'darwin)
@@ -16828,13 +16844,18 @@ individual commands for more information."
       (save-excursion (goto-char (region-beginning))
 		      (org-at-item-p)))
     (call-interactively 'org-outdent-item-tree))
+   ((run-hook-with-args-until-success 'org-shiftmetaleft-final-hook))
    (t (org-modifier-cursor-error))))
 
 (defun org-shiftmetaright ()
   "Demote subtree or insert table column.
 Calls `org-demote-subtree', `org-indent-item-tree', or
 `org-table-insert-column', depending on context.  See the
-individual commands for more information."
+individual commands for more information.
+
+This function runs the hook `org-shiftmetaright-hook' as a first
+step, `org-shiftmetaright-final-hook' as the penultimate step,
+and returns at first non-nil value."
   (interactive)
   (cond
    ((and (eq system-type 'darwin)
@@ -16848,6 +16869,7 @@ individual commands for more information."
       (save-excursion (goto-char (region-beginning))
 		      (org-at-item-p)))
     (call-interactively 'org-indent-item-tree))
+   ((run-hook-with-args-until-success 'org-shiftmetaright-final-hook))
    (t (org-modifier-cursor-error))))
 
 (defun org-shiftmetaup (&optional _arg)
@@ -16855,13 +16877,18 @@ individual commands for more information."
 In a table, kill the current row.
 On a clock timestamp, update the value of the timestamp like `S-<up>'
 but also adjust the previous clocked item in the clock history.
-Everywhere else, drag the line at point up."
+Everywhere else, drag the line at point up.
+
+This function runs the hook `org-shiftmetaup-hook' as a first
+step, `org-shiftmetaup-final-hook' as the penultimate step, and
+returns at first non-nil value."
   (interactive "P")
   (cond
    ((run-hook-with-args-until-success 'org-shiftmetaup-hook))
    ((org-at-table-p) (call-interactively 'org-table-kill-row))
    ((org-at-clock-log-p) (let ((org-clock-adjust-closest t))
 			   (call-interactively 'org-timestamp-up)))
+   ((run-hook-with-args-until-success 'org-shiftmetaup-final-hook))
    (t (call-interactively 'org-drag-line-backward))))
 
 (defun org-shiftmetadown (&optional _arg)
@@ -16869,13 +16896,18 @@ Everywhere else, drag the line at point up."
 In a table, insert an empty row at the current line.
 On a clock timestamp, update the value of the timestamp like `S-<down>'
 but also adjust the previous clocked item in the clock history.
-Everywhere else, drag the line at point down."
+Everywhere else, drag the line at point down.
+
+This function runs the hook `org-shiftmetadown-hook' as a first
+step, `org-shiftmetadown-final-hook' as the penultimate step, and
+returns at first non-nil value."
   (interactive "P")
   (cond
    ((run-hook-with-args-until-success 'org-shiftmetadown-hook))
    ((org-at-table-p) (call-interactively 'org-table-insert-row))
    ((org-at-clock-log-p) (let ((org-clock-adjust-closest t))
 			   (call-interactively 'org-timestamp-down)))
+   ((run-hook-with-args-until-success 'org-shiftmetadown-final-hook))
    (t (call-interactively 'org-drag-line-forward))))
 
 (defsubst org-hidden-tree-error ()
-- 
2.34.1



  parent 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 ` [PATCH 1/3] lisp/org.el: Add final hooks to the M-cursor commands Evgenii Klimov
2023-06-29 22:31 ` [PATCH 2/3] lisp/org.el: Fix docstring for S-cursor commands Evgenii Klimov
2023-06-29 22:31 ` Evgenii Klimov [this message]
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-4-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).