1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-28 10:56:57 +00:00

Bug fixes and documentation related to saving clock markers.

This commit is contained in:
Carsten Dominik 2008-05-02 09:01:56 +02:00
parent e364fa62e2
commit 453dbf7372
6 changed files with 67 additions and 33 deletions

View File

@ -1,3 +1,11 @@
2008-05-02 Carsten Dominik <dominik@science.uva.nl>
* lisp/org-clock.el (org-clock-save-markers-for-cut-and-paste):
New function.
* lisp/org-agenda.el (org-agenda-save-markers-for-cut-and-paste):
New function.
2008-05-01 Carsten Dominik <dominik@science.uva.nl>
* lisp/org-clock.el (org-clock-find-position): Don't include notes

View File

@ -4747,8 +4747,8 @@ from an buffer in @code{emacs-lisp-mode}. The second template will only be
available when the function @code{my-check} returns @code{t}. The third
template will be proposed in any context.
When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
something, org will prompt for a key to select the template (if you have
When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
something, Org will prompt for a key to select the template (if you have
more than one template) and then prepare the buffer like
@example
* TODO
@ -4823,14 +4823,20 @@ template that will be filled with the previous context information.
@node Storing notes, Refiling notes, Remember templates, Remember
@section Storing notes
When you are finished preparing a note with @i{remember}, you have to
press @kbd{C-c C-c} to file the note away. The handler will store the
note in the file and under the headline specified in the template, or it
will use the default file and headlines. The window configuration will
be restored, sending you back to the working context before the call to
@code{remember}. To re-use the location found during the last call to
@code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c},
i.e. specify a double prefix argument to @kbd{C-c C-c}.
When you are finished preparing a note with @i{remember}, you have to press
@kbd{C-c C-c} to file the note away. If you have started the clock in the
remember buffer, you will first be asked if you want to clock out
now@footnote{To avoid this query, configure the variable
@code{org-remember-clock-out-on-exit}.}. If you answer @kbd{n}, the clock
will continue to run after the note is filed away.
The handler will then store the note in the file and under the headline
specified in the template, or it will use the default file and headlines.
The window configuration will be restored, sending you back to the working
context before the call to @code{remember}. To re-use the location found
during the last call to @code{remember}, exit the remember buffer with
@kbd{C-u C-u C-c C-c}, i.e. specify a double prefix argument to @kbd{C-c
C-c}.
If you want to store the note directly to a different place, use
@kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the

View File

@ -2046,6 +2046,11 @@ no longer in use."
(while org-agenda-markers
(move-marker (pop org-agenda-markers) nil)))
(defun org-agenda-save-markers-for-cut-and-paste (beg end)
"Save relative positions of markers in region."
(mapc (lambda (m) (org-check-and-save-marker m beg end))
org-agenda-markers))
;;; Agenda timeline
(defvar org-agenda-only-exact-dates nil) ; dynamically scoped

View File

@ -218,9 +218,7 @@ this heading."
;; We first only copy, in case something goes wrong
;; we need to protect `this-command', to avoid kill-region sets it,
;; which would lead to duplication of subtrees
(let ((org-markers-to-move 'force)
this-command)
(org-copy-subtree))
(let (this-command) (org-copy-subtree 1 nil t))
(set-buffer buffer)
;; Enforce org-mode for the archive buffer
(if (not (org-mode-p))
@ -299,6 +297,7 @@ this heading."
;; Here we are back in the original buffer. Everything seems to have
;; worked. So now cut the tree and finish up.
(let (this-command) (org-cut-subtree))
(setq org-markers-to-move nil)
(message "Subtree archived %s"
(if (eq this-buffer buffer)
(concat "under heading: " heading)

View File

@ -125,6 +125,14 @@ of a different task.")
(nreverse org-clock-history)))))
(push m org-clock-history)))
(defun org-clock-save-markers-for-cut-and-paste (beg end)
"Save relative positions of markers in region."
(org-check-and-save-marker org-clock-marker beg end)
(org-check-and-save-marker org-clock-default-task beg end)
(org-check-and-save-marker org-clock-interrupted-task beg end)
(mapc (lambda (m) (org-check-and-save-marker m beg end))
org-clock-history))
(defun org-clock-select-task (&optional prompt)
"Select a task that recently was associated with clocking."
(interactive)

View File

@ -2199,6 +2199,7 @@ Normal means, no org-mode-specific context."
(newhead hdmarker &optional fixface))
(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
(declare-function org-agenda-maybe-redo "org-agenda" ())
(declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda" nil)
(declare-function parse-time-string "parse-time" (string))
(declare-function remember "remember" (&optional initial))
(declare-function remember-buffer-desc "remember" ())
@ -2363,6 +2364,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
;; Autoload org-clock.el
(declare-function org-clock-save-markers-for-cut-and-paste "org-clock")
(defvar org-clock-marker (make-marker)
"Marker recording the last clock-in.")
@ -4716,11 +4719,14 @@ This is a short-hand for marking the subtree and then cutting it."
(interactive "p")
(org-copy-subtree n 'cut))
(defun org-copy-subtree (&optional n cut)
(defun org-copy-subtree (&optional n cut force-store-markers)
"Cut the current subtree into the clipboard.
With prefix arg N, cut this many sequential subtrees.
This is a short-hand for marking the subtree and then copying it.
If CUT is non-nil, actually cut the subtree."
If CUT is non-nil, actually cut the subtree.
If FORCE-STORE-MARKERS is non-nil, store the relative locations
of some markers in the region, even if CUT is non-nil. This is
useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
(interactive "p")
(let (beg end folded (beg0 (point)))
(if (interactive-p)
@ -4741,7 +4747,7 @@ If CUT is non-nil, actually cut the subtree."
(goto-char beg0)
(when (> end beg)
(setq org-subtree-clip-folded folded)
(when (or cut (eq org-markers-to-move 'force))
(when (or cut force-store-markers)
(org-save-markers-in-region beg end))
(if cut (kill-region beg end) (copy-region-as-kill beg end))
(setq org-subtree-clip (current-kill 0))
@ -4819,8 +4825,8 @@ If optional TREE is given, use this text instead of the kill ring."
(org-back-over-empty-lines)
(setq beg (point))
(insert-before-markers txt)
(org-reinstall-markers-in-region beg)
(unless (string-match "\n\\'" txt) (insert "\n"))
(org-reinstall-markers-in-region beg)
(setq end (point))
(goto-char beg)
(skip-chars-forward " \t\n\r")
@ -4865,7 +4871,10 @@ If optional TXT is given, check this string instead of the current kill."
(throw 'exit nil)))
t))))
(defvar org-markers-to-move nil)
(defvar org-markers-to-move nil
"Markers that should be moved with a cut-and-paste operation.
Those markers are stored together with their positions relative to
the start of the region.")
(defun org-save-markers-in-region (beg end)
"Check markers in region.
@ -4877,26 +4886,22 @@ buffer. After re-insertion, `org-reinstall-markers-in-region' must be
called immediately, to move the markers with the entries."
(setq org-markers-to-move nil)
(when (featurep 'org-clock)
(org-check-and-save-marker org-clock-marker beg end)
(org-check-and-save-marker org-clock-default-task beg end)
(org-check-and-save-marker org-clock-interrupted-task beg end)
(mapc (lambda (m) (org-check-and-save-marker m beg end))
org-clock-history))
(org-clock-save-markers-for-cut-and-paste))
(when (featurep 'org-agenda)
(mapc (lambda (m) (org-check-and-save-marker m beg end))
org-agenda-markers)))
(org-agenda-save-markers-for-cut-and-paste)))
(defun org-check-and-save-marker (marker bed end)
(defun org-check-and-save-marker (marker beg end)
"Check if MARKER is between BEG and END.
If yes, remember the marker and the distance to BEG."
(when (and (marker-buffer marker)
(equal (marker-buffer marker) (current-buffer)))
(if (and (>= marker beg) (< marker end))
(push (cons marker (- marker beg)) org-markers-to-move))))
(push (cons marker (- marker beg)) org-markers-to-move))))
(defun org-reinstall-markers-in-region (beg)
"Move all remembered markers to their position relative to BEG."
(mapc (lambda (x) (move-marker (car x) (+ beg (cdr x))))
(mapc (lambda (x)
(move-marker (car x) (+ beg (cdr x))))
org-markers-to-move)
(setq org-markers-to-move nil))
@ -6246,7 +6251,10 @@ For file links, arg negates `org-context-in-file-links'."
(t nil)))
(when (or (null txt) (string-match "\\S-" txt))
(setq cpltxt
(concat cpltxt "::" (org-make-org-heading-search-string txt))
(concat cpltxt "::"
(condition-case nil
(org-make-org-heading-search-string txt)
(error "")))
desc "NONE"))))
(if (string-match "::\\'" cpltxt)
(setq cpltxt (substring cpltxt 0 -2)))
@ -7395,8 +7403,7 @@ operation has put the subtree."
(switch-to-buffer nbuf)
(goto-char pos)
(org-show-context 'org-goto))
(let ((org-markers-to-move 'force))
(org-copy-special))
(org-copy-subtree 1 nil t)
(save-excursion
(set-buffer (setq nbuf (or (find-buffer-visiting file)
(find-file-noselect file))))
@ -7415,7 +7422,8 @@ operation has put the subtree."
(point-max))))
(bookmark-set "org-refile-last-stored")
(org-paste-subtree level))))
(org-cut-special)
(org-cut-subtree)
(setq org-markers-to-move nil)
(message "Entry refiled to \"%s\"" (car it)))))))
(defun org-refile-goto-last-stored ()
@ -10473,7 +10481,7 @@ The command returns the inserted time stamp."
(message "Time stamp overlays removed")))
(defun org-display-custom-time (beg end)
"Overlay modified time stamp format over timestamp between BED and END."
"Overlay modified time stamp format over timestamp between BEG and END."
(let* ((ts (buffer-substring beg end))
t1 w1 with-hm tf time str w2 (off 0))
(save-match-data