Explorar o código

New macro

* lisp/org-agenda.el (org-agenda-with-point-at-orig-entry): New macro.
Carsten Dominik %!s(int64=15) %!d(string=hai) anos
pai
achega
6f61135c84
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      lisp/org-agenda.el

+ 12 - 0
lisp/org-agenda.el

@@ -1488,6 +1488,18 @@ the lower-case version of all tags."
   (require 'cl))
 (require 'org)
 
+(defmacro org-agenda-with-point-at-orig-entry (string &rest body)
+  "Execute BODY with point at location given by `org-hd-marker' property.
+If STRING is non-nil, the text property will be fetched from position 0
+in that string.  If STRING is nil, it will be fetched from the beginning
+of the current line."
+  `(let ((marker (get-text-property (if string 0 (point-at-bol))
+				    'org-hd-marker string)))
+     (with-current-buffer (marker-buffer marker)
+       (save-excursion
+	 (goto-char marker)
+	 ,@body))))
+
 (defun org-add-agenda-custom-command (entry)
   "Replace or add a command in `org-agenda-custom-commands'.
 This is mostly for hacking and trying a new command - once the command