summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2021-05-13 14:56:18 +0200
committerBastien <bzg@gnu.org>2021-05-14 21:24:52 +0200
commit0e39bf839a6b0f17bef94b6997f20c0d0a8cbb5e (patch)
treec61c30bc98561006bda42f55925a324a4b51d608
parentdcb6013fb6a2c4eecdc8fb13cd7bae8a71ef25cd (diff)
downloadorg-mode-0e39bf839a6b0f17bef94b6997f20c0d0a8cbb5e.tar.gz
Throw user errors when trying to drag inline tasks
* lisp/org.el (org-metaup, org-metadown): Throw a user error explaining that dragging inline tasks is not supported. * lisp/org-inlinetask.el (org-inlinetask-insert-task) (org-inlinetask-promote, org-inlinetask-demote): Fix bug when demoting/promoting inline tasks at the end of the buffer and throw user errors instead of errors. Based on an initial patch by Carsten. Reported-by: Christian Hemminghaus <chrhemmi@gmail.com> Link: https://orgmode.org/list/CAE47VC=yhObXs3jexLUkf53cNzcOWUkTMqpF8QK4Dcg98QijyQ@mail.gmail.com/
-rw-r--r--lisp/org-inlinetask.el22
-rw-r--r--lisp/org.el6
2 files changed, 20 insertions, 8 deletions
diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el
index 7353f38..79146d2 100644
--- a/lisp/org-inlinetask.el
+++ b/lisp/org-inlinetask.el
@@ -131,7 +131,7 @@ If there is a region wrap it inside the inline task."
;; before this one.
(when (and (org-inlinetask-in-task-p)
(not (and (org-inlinetask-at-task-p) (bolp))))
- (error "Cannot nest inline tasks"))
+ (user-error "Cannot nest inline tasks"))
(or (bolp) (newline))
(let* ((indent (if org-odd-levels-only
(1- (* 2 org-inlinetask-min-level))
@@ -225,7 +225,7 @@ If the task has an end part, promote it. Also, prevents level from
going below `org-inlinetask-min-level'."
(interactive)
(if (not (org-inlinetask-in-task-p))
- (error "Not in an inline task")
+ (user-error "Not in an inline task")
(save-excursion
(let* ((lvl (org-inlinetask-get-task-level))
(next-lvl (org-get-valid-level lvl -1))
@@ -233,15 +233,18 @@ going below `org-inlinetask-min-level'."
(down-task (concat (make-string next-lvl ?*)))
beg)
(if (< next-lvl org-inlinetask-min-level)
- (error "Cannot promote an inline task at minimum level")
+ (user-error "Cannot promote an inline task at minimum level")
(org-inlinetask-goto-beginning)
(setq beg (point))
(replace-match down-task nil t nil 1)
(org-inlinetask-goto-end)
- (if (eobp) (beginning-of-line) (forward-line -1))
+ (if (and (eobp) (looking-back "END\\s-*"))
+ (beginning-of-line)
+ (forward-line -1))
(unless (= (point) beg)
+ (looking-at (org-inlinetask-outline-regexp))
(replace-match down-task nil t nil 1)
- (when org-adapt-indentation
+ (when (eq org-adapt-indentation t)
(goto-char beg)
(org-fixup-indentation diff))))))))
@@ -250,7 +253,7 @@ going below `org-inlinetask-min-level'."
If the task has an end part, also demote it."
(interactive)
(if (not (org-inlinetask-in-task-p))
- (error "Not in an inline task")
+ (user-error "Not in an inline task")
(save-excursion
(let* ((lvl (org-inlinetask-get-task-level))
(next-lvl (org-get-valid-level lvl 1))
@@ -261,10 +264,13 @@ If the task has an end part, also demote it."
(setq beg (point))
(replace-match down-task nil t nil 1)
(org-inlinetask-goto-end)
- (if (eobp) (beginning-of-line) (forward-line -1))
+ (if (and (eobp) (looking-back "END\\s-*"))
+ (beginning-of-line)
+ (forward-line -1))
(unless (= (point) beg)
+ (looking-at (org-inlinetask-outline-regexp))
(replace-match down-task nil t nil 1)
- (when org-adapt-indentation
+ (when (eq org-adapt-indentation t)
(goto-char beg)
(org-fixup-indentation diff)))))))
diff --git a/lisp/org.el b/lisp/org.el
index b388bca..a9a2bef 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17161,6 +17161,9 @@ for more information."
(transpose-regions a b c d)
(goto-char c)))
((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up))
+ ((and (featurep 'org-inlinetask)
+ (org-inlinetask-in-task-p))
+ (user-error "Dragging inline tasks is not supported"))
((org-at-heading-p) (call-interactively 'org-move-subtree-up))
((org-at-item-p) (call-interactively 'org-move-item-up))
(t (org-drag-element-backward))))
@@ -17191,6 +17194,9 @@ commands for more information."
(transpose-regions a b c d)
(goto-char d)))
((org-at-table-p) (call-interactively 'org-table-move-row))
+ ((and (featurep 'org-inlinetask)
+ (org-inlinetask-in-task-p))
+ (user-error "Dragging inline tasks is not supported"))
((org-at-heading-p) (call-interactively 'org-move-subtree-down))
((org-at-item-p) (call-interactively 'org-move-item-down))
(t (org-drag-element-forward))))