emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Vladimir Panteleev <thecybershadow@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] org-shift*: Honor org-support-shift-select for table cell movement
Date: Wed, 08 Apr 2020 04:26:36 +0000	[thread overview]
Message-ID: <87mu7miow3.fsf@kyleam.com> (raw)
In-Reply-To: <87zhbnzxdf.fsf@kyleam.com>

Kyle Meyer <kyle@kyleam.com> writes:

> The change in behavior happened with 09f950723 (Added keybindings for
> `org-table-move-cell-*' functions), which was a part of the v9.3
> release.  Looking at that commit and scanning the associated thread [^],
> I'm guessing the interaction with org-support-shift-select was simply
> overlooked and those org-table-move-cell-* calls should be updated to
> inspect org-support-shift-select, like (some of) the other neighboring
> branches in the code.
>
> I'll take a look at doing that tomorrow.

Here's a patch that prevents calling org-table-move-cell-* when
org-support-shift-select is `always'.  I'll apply this in a day or two
if no one chimes in to explain why org-table-move-cell-* shouldn't
consider org-support-shift-select.

-- >8 --
Subject: [PATCH] org-shift*: Honor org-support-shift-select for table cell
 movement

* lisp/org.el (org-support-shift-select): Mention table context.
(org-shiftup):
(org-shiftdown):
(org-shiftright):
(org-shiftleft): Don't move table cells when org-support-shift-select
is `always'.

Reported-by: Vladimir Panteleev <thecybershadow@gmail.com>
<CAHhfkvw8O4cSxe5CJXQ8L+ce+9wOhuM==Xv9rB2NVhsCgYANdA@mail.gmail.com>
---
 lisp/org.el | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 3d841dfa6..c1dffab3c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -854,6 +854,7 @@ (defcustom org-support-shift-select nil
 - in a plain list item, changing the bullet type
 - in a property definition line, switching between allowed values
 - in the BEGIN line of a clock table (changing the time block).
+- in a table, moving the cell in the specified direction.
 Outside these contexts, the commands will throw an error.
 
 When this variable is t and the cursor is not in a special
@@ -863,9 +864,9 @@ (defcustom org-support-shift-select nil
 if the cursor is exactly on the bullet.
 
 If you set this variable to the symbol `always', then the keys
-will not be special in headlines, property lines, and item lines,
-to make shift selection work there as well.  If this is what you
-want, you can use the following alternative commands:
+will not be special in headlines, property lines, item lines, and
+table cells, to make shift selection work there as well.  If this is
+what you want, you can use the following alternative commands:
 `\\[org-todo]' and `\\[org-priority]' \
 to change TODO state and priority,
 `\\[universal-argument] \\[universal-argument] \\[org-todo]' \
@@ -17435,7 +17436,9 @@ (defun org-shiftup (&optional arg)
    ((and (not org-support-shift-select) (org-at-item-p))
     (call-interactively 'org-previous-item))
    ((org-clocktable-try-shift 'up arg))
-   ((org-at-table-p) (org-table-move-cell-up))
+   ((and (not (eq org-support-shift-select 'always))
+	 (org-at-table-p))
+    (org-table-move-cell-up))
    ((run-hook-with-args-until-success 'org-shiftup-final-hook))
    (org-support-shift-select
     (org-call-for-shift-select 'previous-line))
@@ -17461,7 +17464,9 @@ (defun org-shiftdown (&optional arg)
    ((and (not org-support-shift-select) (org-at-item-p))
     (call-interactively 'org-next-item))
    ((org-clocktable-try-shift 'down arg))
-   ((org-at-table-p) (org-table-move-cell-down))
+   ((and (not (eq org-support-shift-select 'always))
+	 (org-at-table-p))
+    (org-table-move-cell-down))
    ((run-hook-with-args-until-success 'org-shiftdown-final-hook))
    (org-support-shift-select
     (org-call-for-shift-select 'next-line))
@@ -17499,7 +17504,9 @@ (defun org-shiftright (&optional arg)
 	 (org-at-property-p))
     (call-interactively 'org-property-next-allowed-value))
    ((org-clocktable-try-shift 'right arg))
-   ((org-at-table-p) (org-table-move-cell-right))
+   ((and (not (eq org-support-shift-select 'always))
+	 (org-at-table-p))
+    (org-table-move-cell-right))
    ((run-hook-with-args-until-success 'org-shiftright-final-hook))
    (org-support-shift-select
     (org-call-for-shift-select 'forward-char))
@@ -17537,7 +17544,9 @@ (defun org-shiftleft (&optional arg)
 	 (org-at-property-p))
     (call-interactively 'org-property-previous-allowed-value))
    ((org-clocktable-try-shift 'left arg))
-   ((org-at-table-p) (org-table-move-cell-left))
+   ((and (not (eq org-support-shift-select 'always))
+	 (org-at-table-p))
+    (org-table-move-cell-left))
    ((run-hook-with-args-until-success 'org-shiftleft-final-hook))
    (org-support-shift-select
     (org-call-for-shift-select 'backward-char))

base-commit: 561e9efd062e23321f3b56b2e3482ef3afc7416f
-- 
2.26.0



  reply	other threads:[~2020-04-08  4:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-05  8:40 Bug: org-shiftright etc. do not respect org-support-shift-select [9.3.6 (9.3.6-elpa @ /home/vladimir/.emacs.d/elpa/org-9.3.6/)] Vladimir Panteleev
2020-04-07  5:19 ` Kyle Meyer
2020-04-08  4:26   ` Kyle Meyer [this message]
2020-04-10  2:32     ` [PATCH] org-shift*: Honor org-support-shift-select for table cell movement Kyle Meyer

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=87mu7miow3.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=thecybershadow@gmail.com \
    /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).