From d8498a40e815d8604311e9844e6c75bbf074d026 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 2 Sep 2010 11:34:26 +0200 Subject: [PATCH] Fix read-only issue with capture * lisp/org-capture.el (org-capture): Remove read-only text properties from capture text. (org-capture-set-target-location): Throw an error if file+headline target does not point into a file which is in Org mode. Richard Riley writes: > If I select a region in, in this case, an erc (emacs irc client) > buffer in the read only section and then use my global keys to create > a new item using the following "j" template while the text is still > selected > > ("j" "Journal" entry > (file+datetree "journal.org") > "* %T %?\n %i\n %a") > > then I get the following backtrace :- > > Debugger entered--Lisp error: (error "Capture abort: (text-read-only)") > signal(error ("Capture abort: (text-read-only)")) > error("Capture abort: %s" (text-read-only)) > byte-code("\301\302!\203\n --- lisp/org-capture.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 3bc30eb4c..4cf887e42 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -383,6 +383,10 @@ bypassed." (initial (and (org-region-active-p) (buffer-substring (point) (mark)))) (entry (org-capture-select-template keys))) + (when initial + (remove-text-properties 0 (length initial) '(read-only t) initial)) + (when annotation + (remove-text-properties 0 (length initial) '(read-only t) annotation)) (cond ((equal entry "C") (customize-variable 'org-capture-templates)) @@ -590,6 +594,8 @@ already gone." (set-buffer (org-capture-target-buffer (nth 1 target))) (let ((hd (nth 2 target))) (goto-char (point-min)) + (unless (org-mode-p) + (error "Target buffer for file+headline should be in Org mode")) (if (re-search-forward (format org-complex-heading-regexp-format (regexp-quote hd)) nil t) -- 2.11.4.GIT