From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id yR61Abi8omTYegAASxT56A (envelope-from ) for ; Mon, 03 Jul 2023 14:19:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 6EZdALi8omQgagEAauVa8A (envelope-from ) for ; Mon, 03 Jul 2023 14:19:04 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7930F18086 for ; Mon, 3 Jul 2023 14:19:03 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lipklim.org header.s=key1 header.b=sUhxmApc; dmarc=pass (policy=quarantine) header.from=lipklim.org; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688386743; a=rsa-sha256; cv=none; b=RvMvAsnov5fwx7mKl1lo/gJwK54U0t1nmymPXVullkIJ9vsmYAf5YiINgasCHnJ6XUsPao A26YXQqvd00fNhhDw1BVKWGR/Vpj13hTs8ZfYyVVjdeq6tLG76pt6OdVyT5s6F5j3bXNjs /PzfVVgDe+OqSUoxfwsBpRTBFW4U7pjPruQRP0Y4L6FVgyuVfG1odh9lfcKKiushjrppFp NayiRMwSYe3tzr/4dI301Gb38KQ0fHUs8o4fROquZFzCyvcZg3kcdb0WLc6gfnzvzR/N6r KKfv02485WkKNyr2coftny5s07/X/NDeckwHEaeNjv+pdzSRmTXndM3qWQdRqQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lipklim.org header.s=key1 header.b=sUhxmApc; dmarc=pass (policy=quarantine) header.from=lipklim.org; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688386743; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=XOXVAemReF87JB0PxIGXJoEsx0Tn5eXKxB0cZquLyvs=; b=jYag5ydgRP5iSd4PR6P59fqPw45W/oYEjexsjmvopnT3WMbodQXkoR4/0UlVd/HEn9YJ+Q xS0E1pqw7/71cWkevtYqTRu6MV/cgS8n2HOPUe/dUSs1iSXr5p15PGv4DjPddzxa9xdisg b7QC+G8AaKE/ZibnPCThbPqqELg+9pSTn+426OfZqlkZoWiIhTxbm/QKKY9PwsrfttQy1L mkZH1VSOgaGUe+1mknL1qMKA3/mU3Ity1mteJWtzEimzb5BpohT+2C/eANWXJf/VN0S49x A5d5whVTaLgeanqjVeMRhlzFNiVtIF3U5e3jVFs1hYm/bXuJUq9ruIcrzwtSWw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGIVA-0000oJ-6A; Mon, 03 Jul 2023 08:17:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFacg-0004dJ-0y for emacs-orgmode@gnu.org; Sat, 01 Jul 2023 09:26:46 -0400 Received: from out-1.mta0.migadu.com ([2001:41d0:1004:224b::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFacc-0005QU-Cz for emacs-orgmode@gnu.org; Sat, 01 Jul 2023 09:26:45 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lipklim.org; s=key1; t=1688217998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOXVAemReF87JB0PxIGXJoEsx0Tn5eXKxB0cZquLyvs=; b=sUhxmApc5iP3AM45Bp6P0oTOo8TF5MByJsgAkzUD7mtpTSfMZRZUi8FnPqB48E54H+sPSy VlC4QGTIfGLPGc3nV9KgXOfQ1kW3qIkBJ2uEnxTWB/bx7kaistjIvRENcE89TS3M0bdlDp zQw5ptFxzBjF3wapsuE1VZCrDQXxoU8= From: Evgenii Klimov To: emacs-orgmode@gnu.org Cc: Evgenii Klimov Subject: [PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands Date: Sat, 1 Jul 2023 14:19:03 +0100 Message-Id: <20230701131902.1679-1-eugene.dev@lipklim.org> In-Reply-To: <873527q5iw.fsf@localhost> References: <873527q5iw.fsf@localhost> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:41d0:1004:224b::1; envelope-from=eugene.dev@lipklim.org; helo=out-1.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 03 Jul 2023 08:17:48 -0400 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -3.96 X-Migadu-Queue-Id: 7930F18086 X-Spam-Score: -3.96 X-TUID: blg8srMZgWmW * 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 (org-shiftup, org-shiftdown, org-shiftright, org-shiftleft): Document hooks for S-cursor commands in the docstring. * 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. TINYCHANGE --- Probably you are right and there's no need to add the final hook to `org-meta-return'. Previously, I thought that the last condition fully simulate C-RET, but the latter turned out to be `org-insert-heading-respect-content'. etc/ORG-NEWS | 17 +++++++++ lisp/org.el | 98 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 103 insertions(+), 12 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index cb4bc632b..f88e3df3d 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -249,6 +249,23 @@ Currently implemented options are: iCalendar programs support this usage. ** New features +*** New final hooks for Modifier-Cursor keys + +Final hooks are added to the following commands: +- ~org-metaleft-final-hook~ to ~org-metaleft~ (bound to =M-=). +- ~org-metaright-final-hook~ to ~org-metaright~ (bound to + =M-=). +- ~org-metaup-final-hook~ to ~org-metaup~ (bound to =M-=). +- ~org-metadown-final-hook~ to ~org-metadown~ (bound to =M-=). +- ~org-shiftmetaleft-final-hook~ to ~org-shiftmetaleft~ (bound to + =M-S-=). +- ~org-shiftmetaright-final-hook~ to ~org-shiftmetaright~ (bound to + =M-S-=). +- ~org-shiftmetaup-final-hook~ to ~org-shiftmetaup~ (bound to + =M-S-=). +- ~org-shiftmetadown-final-hook~ to ~org-shiftmetadown~ (bound to + =M-S-=). + *** ~org-insert-todo-heading-respect-content~ now accepts prefix arguments The prefix arguments are passed to ~org-insert-todo-heading~. diff --git a/lisp/org.el b/lisp/org.el index fdb920864..052c592ed 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16831,27 +16831,51 @@ 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.") +(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.") @@ -16919,7 +16943,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) @@ -16933,13 +16961,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) @@ -16953,6 +16986,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) @@ -16960,13 +16994,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-' 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) @@ -16974,13 +17013,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-' 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 () @@ -16996,7 +17040,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)) @@ -17019,6 +17064,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) @@ -17032,7 +17078,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)) @@ -17057,6 +17104,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) @@ -17090,7 +17138,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)) @@ -17147,13 +17199,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)) @@ -17206,13 +17263,18 @@ 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) "Act on current element according to context. Call `org-timestamp-up' or `org-priority-up', or `org-previous-item', or `org-table-move-cell-up'. See the -individual commands for more information." +individual commands for more information. + +This function runs the hook `org-shiftup-hook' as a first step, +`org-shiftup-final-hook' as the penultimate step, and returns at +first non-nil value." (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftup-hook)) @@ -17240,7 +17302,11 @@ individual commands for more information." "Act on current element according to context. Call `org-timestamp-down' or `org-priority-down', or `org-next-item', or `org-table-move-cell-down'. See the -individual commands for more information." +individual commands for more information. + +This function runs the hook `org-shiftdown-hook' as a first step, +`org-shiftdown-final-hook' as the penultimate step, and returns +at first non-nil value." (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftdown-hook)) @@ -17273,7 +17339,11 @@ This does one of the following: - on an item, switch entire list to the next bullet type - on a property line, switch to the next allowed value - on a clocktable definition line, move time block into the future -- in a table, move a single cell right" +- in a table, move a single cell right + +This function runs the hook `org-shiftright-hook' as a first +step, `org-shiftright-final-hook' as the penultimate step, and +returns at first non-nil value." (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftright-hook)) @@ -17313,7 +17383,11 @@ This does one of the following: - on an item, switch entire list to the previous bullet type - on a property line, switch to the previous allowed value - on a clocktable definition line, move time block into the past -- in a table, move a single cell left" +- in a table, move a single cell left + +This function runs the hook `org-shiftleft-hook' as a first step, +`org-shiftleft-final-hook' as the penultimate step, and returns +at first non-nil value." (interactive "P") (cond ((run-hook-with-args-until-success 'org-shiftleft-hook)) -- 2.34.1