Browse Source

New minor org-remember-mode, for extra keybindings.

This patch defines a new minor mode, `org-remember-mode', which is
turned on when Org-mode is used to handle a remember buffer.  This
provides a safe way to modify keybindings (in
`org-remember-mode-map'), without overwriting keys in `org-mode-map'.
Since Org put remember buffers into Org-mode, remember-mode-map will
be entirely ignored.
Carsten Dominik 17 years ago
parent
commit
e51d317a21
5 changed files with 36 additions and 4 deletions
  1. 4 0
      doc/ChangeLog
  2. 6 0
      doc/org.texi
  3. 5 2
      lisp/ChangeLog
  4. 3 0
      lisp/org-attach.el
  5. 18 2
      lisp/org-remember.el

+ 4 - 0
doc/ChangeLog

@@ -1,3 +1,7 @@
+2008-11-18  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Setting up Remember): Document `org-remember-mode'.
+
 2008-11-14  Carsten Dominik  <carsten.dominik@gmail.com>
 2008-11-14  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.texi (External links): Document that bbdb links can use a
 	* org.texi (External links): Document that bbdb links can use a

+ 6 - 0
doc/org.texi

@@ -4988,6 +4988,12 @@ stored: Just call @code{org-remember} with a prefix argument.  If you
 use two prefix arguments, Org jumps to the location where the last
 use two prefix arguments, Org jumps to the location where the last
 remember note was stored.
 remember note was stored.
 
 
+The remember buffer will actually use @code{org-mode} as its major mode, so
+that all editing features of Org-mode are available.  In addition to this, a
+minor mode @code{org-remember-mode} is turned on, for the single purpose that
+you can use its keymap @code{org-remember-mode-map} to overwrite some of
+Org-mode's key bindings.
+
 You can also call @code{org-remember} in a special way from the agenda,
 You can also call @code{org-remember} in a special way from the agenda,
 using the @kbd{k r} key combination.  With this access, any time stamps
 using the @kbd{k r} key combination.  With this access, any time stamps
 inserted by the selected remember template (see below) will default to
 inserted by the selected remember template (see below) will default to

+ 5 - 2
lisp/ChangeLog

@@ -1,7 +1,10 @@
 2008-11-18  Carsten Dominik  <carsten.dominik@gmail.com>
 2008-11-18  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
-	* org-remember.el (org-remember-apply-template): No ido
-	completion for free prompts in remember templates.
+	* org-remember.el (org-remember-apply-template): No ido completion
+	for free prompts in remember templates.
+	(org-remember-before-finalize-hook): New hook.
+	(org-remember-mode): New minor mode.
+	(org-remember-apply-template): Turn on `org-remember-mode'.
 
 
 	* org-id.el (org-id-add-location): Avoid error when no file is
 	* org-id.el (org-id-add-location): Avoid error when no file is
 	given.
 	given.

+ 3 - 0
lisp/org-attach.el

@@ -153,6 +153,9 @@ D       Delete all of a task's attachments.  A safer way is
   "Return the directory associated with the current entry.
   "Return the directory associated with the current entry.
 If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil,
 If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil,
 the directory and the corresponding ID will be created."
 the directory and the corresponding ID will be created."
+  (when (and (not (buffer-file-name (buffer-base-buffer)))
+	     (not (file-name-absolute-p org-attach-directory)))
+    (error "Need absolute `org-attach-directory' to attach in bufers without filename."))
   (let ((uuid (org-id-get (point) create-if-not-exists-p)))
   (let ((uuid (org-id-get (point) create-if-not-exists-p)))
     (when (or uuid create-if-not-exists-p)
     (when (or uuid create-if-not-exists-p)
       (unless uuid
       (unless uuid

+ 18 - 2
lisp/org-remember.el

@@ -195,6 +195,21 @@ calendar           |  %:type %:date"
 			 (symbol :tag "Major mode"))
 			 (symbol :tag "Major mode"))
 		 (function :tag "Perform a check against function")))))
 		 (function :tag "Perform a check against function")))))
 
 
+(defcustom org-remember-before-finalize-hook nil
+  "Hook that is run right before a remember process is finalized.
+The remember buffer is still current when this hook runs."
+  :group 'org-remember
+  :type 'hook)
+
+(defvar org-remember-mode-map (make-sparse-keymap)
+  "Keymap for org-remember-mode, a minor mode.
+Use this map to set additional keybindings for when Org-mode is used
+for a Remember buffer.")
+
+(define-minor-mode org-remember-mode
+  "Minor mode for special key bindings in a remember buffer."
+  nil "Rem" org-remember-mode-map)
+
 (defcustom org-remember-clock-out-on-exit 'query
 (defcustom org-remember-clock-out-on-exit 'query
   "Non-nil means, stop the clock when exiting a clocking remember buffer.
   "Non-nil means, stop the clock when exiting a clocking remember buffer.
 This only applies if the clock is running in the remember buffer.  If the
 This only applies if the clock is running in the remember buffer.  If the
@@ -446,7 +461,7 @@ to be run from that hook to function properly."
 		 (replace-match x t t))))
 		 (replace-match x t t))))
 
 
 	;; Turn on org-mode in the remember buffer, set local variables
 	;; Turn on org-mode in the remember buffer, set local variables
-	(let ((org-inhibit-startup t)) (org-mode))
+	(let ((org-inhibit-startup t)) (org-mode) (org-remember-mode 1))
 	(org-set-local 'org-finish-function 'org-remember-finalize)
 	(org-set-local 'org-finish-function 'org-remember-finalize)
 	(if (and file (string-match "\\S-" file) (not (file-directory-p file)))
 	(if (and file (string-match "\\S-" file) (not (file-directory-p file)))
 	    (org-set-local 'org-default-notes-file file))
 	    (org-set-local 'org-default-notes-file file))
@@ -540,7 +555,7 @@ to be run from that hook to function properly."
 	(if (re-search-forward "%\\?" nil t)
 	(if (re-search-forward "%\\?" nil t)
 	    (replace-match "")
 	    (replace-match "")
 	  (and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
 	  (and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
-    (let ((org-inhibit-startup t)) (org-mode))
+    (let ((org-inhibit-startup t)) (org-mode) (org-remember-mode 1))
     (org-set-local 'org-finish-function 'org-remember-finalize))
     (org-set-local 'org-finish-function 'org-remember-finalize))
   (when (save-excursion
   (when (save-excursion
 	  (goto-char (point-min))
 	  (goto-char (point-min))
@@ -579,6 +594,7 @@ from that hook."
 (defvar org-clock-marker) ; Defined in org.el
 (defvar org-clock-marker) ; Defined in org.el
 (defun org-remember-finalize ()
 (defun org-remember-finalize ()
   "Finalize the remember process."
   "Finalize the remember process."
+  (run-hooks 'org-remember-before-finalize-hook)
   (unless (fboundp 'remember-finalize)
   (unless (fboundp 'remember-finalize)
     (defalias 'remember-finalize 'remember-buffer))
     (defalias 'remember-finalize 'remember-buffer))
   (when (and org-clock-marker
   (when (and org-clock-marker