Small refactoring
* lisp/org.el (org-add-planning-info): Small refactoring.
This commit is contained in:
parent
ed825d738b
commit
1ff01cc07a
39
lisp/org.el
39
lisp/org.el
|
@ -13397,9 +13397,7 @@ If non is given, the user is prompted for a date.
|
||||||
REMOVE indicates what kind of entries to remove. An old WHAT entry will also
|
REMOVE indicates what kind of entries to remove. An old WHAT entry will also
|
||||||
be removed."
|
be removed."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let (org-time-was-given org-end-time-was-given ts
|
(let (org-time-was-given org-end-time-was-given default-time default-input)
|
||||||
end default-time default-input)
|
|
||||||
|
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(when (and (memq what '(scheduled deadline))
|
(when (and (memq what '(scheduled deadline))
|
||||||
(or (not time)
|
(or (not time)
|
||||||
|
@ -13408,15 +13406,14 @@ be removed."
|
||||||
;; Try to get a default date/time from existing timestamp
|
;; Try to get a default date/time from existing timestamp
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(org-back-to-heading t)
|
(org-back-to-heading t)
|
||||||
(setq end (save-excursion (outline-next-heading) (point)))
|
(let ((end (save-excursion (outline-next-heading) (point))) ts)
|
||||||
(when (re-search-forward (if (eq what 'scheduled)
|
(when (re-search-forward (if (eq what 'scheduled)
|
||||||
org-scheduled-time-regexp
|
org-scheduled-time-regexp
|
||||||
org-deadline-time-regexp)
|
org-deadline-time-regexp)
|
||||||
end t)
|
end t)
|
||||||
(setq ts (match-string 1)
|
(setq ts (match-string 1)
|
||||||
default-time
|
default-time (apply 'encode-time (org-parse-time-string ts))
|
||||||
(apply 'encode-time (org-parse-time-string ts))
|
default-input (and ts (org-get-compact-tod ts)))))))
|
||||||
default-input (and ts (org-get-compact-tod ts))))))
|
|
||||||
(when what
|
(when what
|
||||||
(setq time
|
(setq time
|
||||||
(if (stringp time)
|
(if (stringp time)
|
||||||
|
@ -13429,14 +13426,13 @@ be removed."
|
||||||
default-time default-input)))))
|
default-time default-input)))))
|
||||||
|
|
||||||
(when (and org-insert-labeled-timestamps-at-point
|
(when (and org-insert-labeled-timestamps-at-point
|
||||||
(member what '(scheduled deadline)))
|
(memq what '(scheduled deadline)))
|
||||||
(insert
|
(insert
|
||||||
(if (eq what 'scheduled) org-scheduled-string org-deadline-string) " ")
|
(if (eq what 'scheduled) org-scheduled-string org-deadline-string) " ")
|
||||||
(org-insert-time-stamp time org-time-was-given
|
(org-insert-time-stamp time org-time-was-given
|
||||||
nil nil nil (list org-end-time-was-given))
|
nil nil nil (list org-end-time-was-given))
|
||||||
(setq what nil))
|
(setq what nil))
|
||||||
(save-excursion
|
(org-with-wide-buffer
|
||||||
(save-restriction
|
|
||||||
(let (col list elt ts buffer-invisibility-spec)
|
(let (col list elt ts buffer-invisibility-spec)
|
||||||
(org-back-to-heading t)
|
(org-back-to-heading t)
|
||||||
(looking-at (concat org-outline-regexp "\\( *\\)[^\r\n]*"))
|
(looking-at (concat org-outline-regexp "\\( *\\)[^\r\n]*"))
|
||||||
|
@ -13444,10 +13440,7 @@ be removed."
|
||||||
(setq col (current-column))
|
(setq col (current-column))
|
||||||
(goto-char (match-end 0))
|
(goto-char (match-end 0))
|
||||||
(if (eobp) (insert "\n") (forward-char 1))
|
(if (eobp) (insert "\n") (forward-char 1))
|
||||||
(when (and (not what)
|
(unless (or what (org-looking-at-p org-planning-line-re))
|
||||||
(not (looking-at
|
|
||||||
(concat "[ \t]*"
|
|
||||||
org-keyword-time-not-clock-regexp))))
|
|
||||||
;; Nothing to add, nothing to remove...... :-)
|
;; Nothing to add, nothing to remove...... :-)
|
||||||
(throw 'exit nil))
|
(throw 'exit nil))
|
||||||
(if (and (not (looking-at org-outline-regexp))
|
(if (and (not (looking-at org-outline-regexp))
|
||||||
|
@ -13475,7 +13468,7 @@ be removed."
|
||||||
(and org-adapt-indentation (bolp) (org-indent-to-column col))
|
(and org-adapt-indentation (bolp) (org-indent-to-column col))
|
||||||
(when what
|
(when what
|
||||||
(insert
|
(insert
|
||||||
(if (not (or (bolp) (eq (char-before) ?\ ))) " " "")
|
(if (or (bolp) (eq (char-before) ?\s)) "" " ")
|
||||||
(cond ((eq what 'scheduled) org-scheduled-string)
|
(cond ((eq what 'scheduled) org-scheduled-string)
|
||||||
((eq what 'deadline) org-deadline-string)
|
((eq what 'deadline) org-deadline-string)
|
||||||
((eq what 'closed) org-closed-string))
|
((eq what 'closed) org-closed-string))
|
||||||
|
@ -13486,17 +13479,17 @@ be removed."
|
||||||
(and (eq what 'closed) org-log-done-with-time))
|
(and (eq what 'closed) org-log-done-with-time))
|
||||||
(eq what 'closed)
|
(eq what 'closed)
|
||||||
nil nil (list org-end-time-was-given)))
|
nil nil (list org-end-time-was-given)))
|
||||||
(insert
|
(unless (or (bolp)
|
||||||
(if (not (or (bolp) (eq (char-before) ?\ )
|
(eq (char-before) ?\s)
|
||||||
(memq (char-after) '(32 10))
|
(memq (char-after) '(?\n ?\s))
|
||||||
(eobp))) " " ""))
|
(eobp))
|
||||||
|
(insert " "))
|
||||||
(end-of-line 1))
|
(end-of-line 1))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(widen)
|
(widen)
|
||||||
(if (and (looking-at "[ \t]*\n")
|
(when (and (looking-at "[ \t]*\n") (eq (char-before) ?\n))
|
||||||
(equal (char-before) ?\n))
|
(delete-region (1- (point)) (line-end-position)))
|
||||||
(delete-region (1- (point)) (point-at-eol)))
|
ts)))))
|
||||||
ts))))))
|
|
||||||
|
|
||||||
(defvar org-log-note-marker (make-marker))
|
(defvar org-log-note-marker (make-marker))
|
||||||
(defvar org-log-note-purpose nil)
|
(defvar org-log-note-purpose nil)
|
||||||
|
|
Loading…
Reference in New Issue