From bc59617af78405293924d8a62b9b2aee544113d1 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 3 Mar 2008 23:17:05 +0000 Subject: [PATCH 01/13] Added the alias `org-publish-delete-duplicates'. In (< emacs-major-version 2), there is no `delete-dups'. So we use this alias, either calling `delete-dups' or using a routine copyied from subr.el in Emacs 22+. --- org-publish.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/org-publish.el b/org-publish.el index 4d454917e..5eb30a45f 100644 --- a/org-publish.el +++ b/org-publish.el @@ -356,6 +356,22 @@ If NO-EXCLUSION is non-nil, don't exclude files." (org-publish-expand-projects projects-alist)) all-files)) +(if (fboundp 'delete-dups) + (defalias 'org-publish-delete-duplicates 'delete-dups) + (defun org-publish-delete-duplicates (list) + "Destructively remove `equal' duplicates from LIST. +Store the result in LIST and return it. LIST must be a proper list. +Of several `equal' occurrences of an element in LIST, the first +one is kept. + +This is a compatibility function for Emacsen without `delete-dups'." + ;; Code from `subr.el' in Emacs 22: + (let ((tail list)) + (while tail + (setcdr tail (delete (car tail) (cdr tail))) + (setq tail (cdr tail)))) + list)) + (defun org-publish-expand-projects (projects-alist) "Expand projects contained in PROJECTS-ALIST." (let (without-component with-component) @@ -364,7 +380,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." (if (plist-get (cdr p) :components) 'with-component 'without-component) p)) projects-alist) - (delete-dups + (org-publish-delete-duplicates (append without-component (car (mapcar (lambda(p) (org-publish-expand-components p)) with-component)))))) @@ -372,7 +388,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." (defun org-publish-expand-components (project) "Expand PROJECT into an alist of its components." (let* ((components (plist-get (cdr project) :components))) - (delete-dups + (org-publish-delete-duplicates (mapcar (lambda(c) (assoc c org-publish-project-alist)) components)))) From e24d40b423562c38734e5c3188e4b92746bbc75e Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 3 Mar 2008 23:18:39 +0000 Subject: [PATCH 02/13] Put (require 'cl) back into (evel-when-compile ...) It against Emacs coding convention to require 'cl at run-time. --- org-irc.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org-irc.el b/org-irc.el index 5f21f7277..36b03d150 100644 --- a/org-irc.el +++ b/org-irc.el @@ -50,7 +50,10 @@ ;; ;;; Code: -(require 'cl) + +(eval-when-compile + (require 'cl)) + (require 'org) (require 'erc) (require 'erc-log) From a323f5eb7e62cdead6a0641d9430cab32f9d764b Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 3 Mar 2008 23:20:48 +0000 Subject: [PATCH 03/13] Put (require 'cl) back into (evel-when-compile ...) It is against Emacs coding convention to require 'cl at run-time. --- org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.el b/org.el index 36866f2ac..9fe9c83fa 100644 --- a/org.el +++ b/org.el @@ -66,8 +66,8 @@ ;;;; Require other packages -(require 'cl) (eval-when-compile + (require 'cl) (require 'gnus-sum) (require 'calendar)) ;; For XEmacs, noutline is not yet provided by outline.el, so arrange for From 6bbe3c549a47c6579fd62e1a1e9dab6f59e26442 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 3 Mar 2008 23:55:39 +0000 Subject: [PATCH 04/13] Added alias `org-publish-dired-files-attributes.' As far as I can tell `dired-files-attributes' is not part of Emacs 21.4. --- org-publish.el | 53 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/org-publish.el b/org-publish.el index 5eb30a45f..fe050bd2b 100644 --- a/org-publish.el +++ b/org-publish.el @@ -335,6 +335,41 @@ Also set it if the optional argument REFRESH is non-nil." (setq org-publish-files-alist (org-publish-get-files org-publish-project-alist)))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Compatibility aliases + +;; Looks like dired-files-attributes is not in Emacs 21.4a. +;; FIXME: Check this twice +(if (fboundp 'dired-files-attributes) + (defalias 'org-publish-dired-files-attributes 'dired-files-attributes) + ;; taken from dired-aux.el + (defun dired-files-attributes (dir) + "Return a list of all file names and attributes from DIR. +List has a form of (file-name full-file-name (attribute-list))" + (mapcar + (lambda (file-name) + (let ((full-file-name (expand-file-name file-name dir))) + (list file-name + full-file-name + (file-attributes full-file-name)))) + (directory-files dir)))) + +;; Delete-dups is not in Emacs <22 +(if (fboundp 'delete-dups) + (defalias 'org-publish-delete-duplicates 'delete-dups) + (defun org-publish-delete-duplicates (list) + "Destructively remove `equal' duplicates from LIST. +Store the result in LIST and return it. LIST must be a proper list. +Of several `equal' occurrences of an element in LIST, the first +one is kept. + +This is a compatibility function for Emacsen without `delete-dups'." + ;; Code from `subr.el' in Emacs 22: + (let ((tail list)) + (while tail + (setcdr tail (delete (car tail) (cdr tail))) + (setq tail (cdr tail)))) + list)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Getting project information out of org-publish-project-alist @@ -356,22 +391,6 @@ If NO-EXCLUSION is non-nil, don't exclude files." (org-publish-expand-projects projects-alist)) all-files)) -(if (fboundp 'delete-dups) - (defalias 'org-publish-delete-duplicates 'delete-dups) - (defun org-publish-delete-duplicates (list) - "Destructively remove `equal' duplicates from LIST. -Store the result in LIST and return it. LIST must be a proper list. -Of several `equal' occurrences of an element in LIST, the first -one is kept. - -This is a compatibility function for Emacsen without `delete-dups'." - ;; Code from `subr.el' in Emacs 22: - (let ((tail list)) - (while tail - (setcdr tail (delete (car tail) (cdr tail))) - (setq tail (cdr tail)))) - list)) - (defun org-publish-expand-projects (projects-alist) "Expand projects contained in PROJECTS-ALIST." (let (without-component with-component) @@ -405,7 +424,7 @@ matching filenames." (regexp (concat "^[^\\.].*\\.\\(" extension "\\)$")) alldirs allfiles files dir) ;; Get all files and directories in base-directory - (setq files (dired-files-attributes base-dir)) + (setq files (org-publish-dired-files-attributes base-dir)) ;; Get all subdirectories if recursive-p (setq alldirs (if recursive-p From 497dfe10939320c1fde37c3db8c55488cda04487 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 3 Mar 2008 23:56:37 +0000 Subject: [PATCH 05/13] *** empty log message *** --- ChangeLog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fea62e33d..00c48fb34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ -2008-03-03 Carsten Dominik +2008-03-03 Bastien Guerry + * org-publish.el (org-publish-delete-duplicates) + (org-publish-dired-files-attributes): New aliases. + +2008-03-03 Carsten Dominik * org.el (org-toggle-region-items): New function. (org-toggle-region-headings): New function. From cd52b4e45763137309861dc1261205fb5dfb7624 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 00:22:46 +0000 Subject: [PATCH 06/13] Rename `org-publish-delete-duplicates' to `org-publish-delete-dups'. `org-publish-delete-duplicates' was misleading because of the distinction between `delete-dups' and `delete-duplicates'. Also fix a bug in the interaction of `org-publish' and `org-publish-current-project'. --- org-publish.el | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/org-publish.el b/org-publish.el index fe050bd2b..d8595fbec 100644 --- a/org-publish.el +++ b/org-publish.el @@ -356,8 +356,8 @@ List has a form of (file-name full-file-name (attribute-list))" ;; Delete-dups is not in Emacs <22 (if (fboundp 'delete-dups) - (defalias 'org-publish-delete-duplicates 'delete-dups) - (defun org-publish-delete-duplicates (list) + (defalias 'org-publish-delete-dups 'delete-dups) + (defun org-publish-delete-dups (list) "Destructively remove `equal' duplicates from LIST. Store the result in LIST and return it. LIST must be a proper list. Of several `equal' occurrences of an element in LIST, the first @@ -399,7 +399,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." (if (plist-get (cdr p) :components) 'with-component 'without-component) p)) projects-alist) - (org-publish-delete-duplicates + (org-publish-delete-dups (append without-component (car (mapcar (lambda(p) (org-publish-expand-components p)) with-component)))))) @@ -407,7 +407,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." (defun org-publish-expand-components (project) "Expand PROJECT into an alist of its components." (let* ((components (plist-get (cdr project) :components))) - (org-publish-delete-duplicates + (org-publish-delete-dups (mapcar (lambda(c) (assoc c org-publish-project-alist)) components)))) @@ -573,17 +573,19 @@ Default for INDEX-FILENAME is 'index.org'." ;;; Interactive publishing functions ;;;###autoload -(defun org-publish (project-name &optional force) - "Publish the project named PROJECT-NAME." - (interactive - (list (progn (completing-read - "Project name: " org-publish-project-alist nil t)) - current-prefix-arg)) +(defun org-publish (project &optional force) + "Publish PROJECT." + (interactive "P") (save-window-excursion - (let ((org-publish-use-timestamps-flag - (if force nil org-publish-use-timestamps-flag))) + (let* ((force current-prefix-arg) + (org-publish-use-timestamps-flag + (if force nil org-publish-use-timestamps-flag))) (org-publish-projects - (list (assoc project-name org-publish-project-alist)))))) + (list (or project + (assoc (completing-read + "Publish project: " + org-publish-project-alist nil t) + org-publish-project-alist))))))) ;;;###autoload (defun org-publish-all (&optional force) From 9a2741f9addd0f2c3f52ea92238a64c0e5def55a Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 00:46:38 +0000 Subject: [PATCH 07/13] Bugfix for `org-publish-get-files'. `plist-get' was called with the wrong argument, thus causing an error in old Emacsen where `plist-get' was not safe. --- org-publish.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-publish.el b/org-publish.el index d8595fbec..27b0a9d90 100644 --- a/org-publish.el +++ b/org-publish.el @@ -381,7 +381,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." ;; add all projects (mapc (lambda(p) - (let* ((exclude (plist-get p :exclude)) + (let* ((exclude (plist-get (cdr p) :exclude)) (files (org-publish-get-base-files p exclude))) ;; add all files from this project (mapc (lambda(f) From 184e4e1fa39f7f384ff568d1356db6da6d83b7c2 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 00:54:40 +0000 Subject: [PATCH 08/13] Deleted trailing blank spaces. --- org-publish.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/org-publish.el b/org-publish.el index 27b0a9d90..994c74b1a 100644 --- a/org-publish.el +++ b/org-publish.el @@ -282,7 +282,7 @@ files." (defun org-publish-timestamp-filename (filename) "Return path to timestamp file for filename FILENAME." - (while (string-match + (while (string-match (if (eq system-type 'windows-nt) "~\\|/\\|:" "~\\|/") filename) (setq filename (replace-match "_" nil t filename))) (concat org-publish-timestamp-directory filename ".timestamp")) @@ -343,7 +343,7 @@ Also set it if the optional argument REFRESH is non-nil." (if (fboundp 'dired-files-attributes) (defalias 'org-publish-dired-files-attributes 'dired-files-attributes) ;; taken from dired-aux.el - (defun dired-files-attributes (dir) + (defun org-publish-dired-files-attributes (dir) "Return a list of all file names and attributes from DIR. List has a form of (file-name full-file-name (attribute-list))" (mapcar @@ -394,7 +394,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." (defun org-publish-expand-projects (projects-alist) "Expand projects contained in PROJECTS-ALIST." (let (without-component with-component) - (mapc (lambda(p) + (mapc (lambda(p) (add-to-list (if (plist-get (cdr p) :components) 'with-component 'without-component) p)) @@ -416,7 +416,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." If EXCLUDE-REGEXP is set, this will be used to filter out matching filenames." (let* ((project-plist (cdr project)) - (base-dir (file-name-as-directory + (base-dir (file-name-as-directory (plist-get project-plist :base-directory))) (include-list (plist-get project-plist :include)) (recursive-p (plist-get project-plist :recursive)) @@ -525,14 +525,14 @@ FILENAME is the filename of the file to be published." (defun org-publish-projects (projects) "Publish all files belonging to the PROJECTS alist. If :auto-index is set, publish the index too." - (mapc + (mapc (lambda (project) (let* ((project-plist (cdr project)) (exclude-regexp (plist-get project-plist :exclude)) (index-p (plist-get project-plist :auto-index)) - (index-filename (or (plist-get project-plist :index-filename) + (index-filename (or (plist-get project-plist :index-filename) "index.org")) - (index-function (or (plist-get project-plist :index-function) + (index-function (or (plist-get project-plist :index-function) 'org-publish-org-index)) (preparation-function (plist-get project-plist :preparation-function)) (files (org-publish-get-base-files project exclude-regexp)) file) @@ -580,9 +580,9 @@ Default for INDEX-FILENAME is 'index.org'." (let* ((force current-prefix-arg) (org-publish-use-timestamps-flag (if force nil org-publish-use-timestamps-flag))) - (org-publish-projects + (org-publish-projects (list (or project - (assoc (completing-read + (assoc (completing-read "Publish project: " org-publish-project-alist nil t) org-publish-project-alist))))))) From 71a582cc52f604e18e9464d4233040ee3043550f Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 01:11:23 +0000 Subject: [PATCH 09/13] *** empty log message *** --- ChangeLog | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00c48fb34..8de10a2e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,13 @@ +2008-03-04 Bastien Guerry + + * org-publish.el (org-publish-get-files): Bugfix. + (org-publish-get-files, org-publish-get-project-from-filename): + Use `expand-file-name' instead of `file-truename'. + 2008-03-03 Bastien Guerry - * org-publish.el (org-publish-delete-duplicates) - (org-publish-dired-files-attributes): New aliases. + * org-publish.el (org-publish-delete-dups): Aliases for + `delete-dups'. 2008-03-03 Carsten Dominik From 1336cd899938892aa5dc1beefdc74d7f767dc16f Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 01:12:05 +0000 Subject: [PATCH 10/13] Use `expand-file-name' instead of `file-true-name'. Also remove unused alias for `dired-files-attributes'. --- org-publish.el | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/org-publish.el b/org-publish.el index 994c74b1a..6a188d44f 100644 --- a/org-publish.el +++ b/org-publish.el @@ -338,22 +338,6 @@ Also set it if the optional argument REFRESH is non-nil." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Compatibility aliases -;; Looks like dired-files-attributes is not in Emacs 21.4a. -;; FIXME: Check this twice -(if (fboundp 'dired-files-attributes) - (defalias 'org-publish-dired-files-attributes 'dired-files-attributes) - ;; taken from dired-aux.el - (defun org-publish-dired-files-attributes (dir) - "Return a list of all file names and attributes from DIR. -List has a form of (file-name full-file-name (attribute-list))" - (mapcar - (lambda (file-name) - (let ((full-file-name (expand-file-name file-name dir))) - (list file-name - full-file-name - (file-attributes full-file-name)))) - (directory-files dir)))) - ;; Delete-dups is not in Emacs <22 (if (fboundp 'delete-dups) (defalias 'org-publish-delete-dups 'delete-dups) @@ -386,7 +370,7 @@ If NO-EXCLUSION is non-nil, don't exclude files." ;; add all files from this project (mapc (lambda(f) (add-to-list 'all-files - (cons (file-truename f) (car p)))) + (cons (expand-file-name f) (car p)))) files))) (org-publish-expand-projects projects-alist)) all-files)) @@ -449,7 +433,7 @@ matching filenames." (defun org-publish-get-project-from-filename (filename) "Return the project FILENAME belongs." - (let* ((project-name (cdr (assoc (file-truename filename) + (let* ((project-name (cdr (assoc (expand-file-name filename) org-publish-files-alist)))) (assoc project-name org-publish-project-alist))) From 8b527d4a6de06b547c2b6c374353cf12dac6815c Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 01:19:03 +0000 Subject: [PATCH 11/13] Fixing typo. --- org-publish.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-publish.el b/org-publish.el index 6a188d44f..1be162131 100644 --- a/org-publish.el +++ b/org-publish.el @@ -408,7 +408,7 @@ matching filenames." (regexp (concat "^[^\\.].*\\.\\(" extension "\\)$")) alldirs allfiles files dir) ;; Get all files and directories in base-directory - (setq files (org-publish-dired-files-attributes base-dir)) + (setq files (dired-files-attributes base-dir)) ;; Get all subdirectories if recursive-p (setq alldirs (if recursive-p From 187ab7d599fb1af28babdcd6a0d04d7326acdcb8 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 01:43:56 +0000 Subject: [PATCH 12/13] Added the template pre-selection feature. See the new docstring of `org-remember-templates' for details. Documented the template pre-selection feature in org.texi. --- org.el | 65 ++++++++++++++++++++++--- org.texi | 145 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 139 insertions(+), 71 deletions(-) diff --git a/org.el b/org.el index 9fe9c83fa..60a666f40 100644 --- a/org.el +++ b/org.el @@ -1544,6 +1544,14 @@ element can specify the headline in that file that should be offered first when the user is asked to file the entry. The default headline is given in the variable `org-remember-default-headline'. +An optional sixth element can specify the context in which the user should +be able to select this template. If this element is a list of major modes, +the template will only be available while invoking `org-remember' from a +buffer in one of these modes. If it is a function, the template will only +be selected if the function returns `t'. A value of `t' means select +this template in any context. When the element is `nil', the template +will be selected by default, i.e. when all contextual checks failed. + The template specifies the structure of the remember buffer. It should have a first line starting with a star, to act as the org-mode headline. Furthermore, the following %-escapes will be replaced with content: @@ -1588,7 +1596,7 @@ w3, w3m | %:type %:url info | %:type %:file %:node calendar | %:type %:date" :group 'org-remember - :get (lambda (var) ; Make sure all entries have 5 elements + :get (lambda (var) ; Make sure all entries have at least 5 elements (mapcar (lambda (x) (if (not (stringp (car x))) (setq x (cons "" x))) (cond ((= (length x) 4) (append x '(""))) @@ -1597,7 +1605,7 @@ calendar | %:type %:date" (default-value var))) :type '(repeat :tag "enabled" - (list :value ("" ?a "\n" nil nil) + (list :value ("" ?a "\n" nil nil nil) (string :tag "Name") (character :tag "Selection Key") (string :tag "Template") @@ -1606,7 +1614,13 @@ calendar | %:type %:date" (const :tag "Prompt for file" nil)) (choice (string :tag "Destination headline") - (const :tag "Selection interface for heading"))))) + (const :tag "Selection interface for heading")) + (choice + (const :tag "Use by default" nil) + (const :tag "Use in all contexts" t) + (repeat :tag "Use only if in major mode" + (symbol :tag "Major mode")) + (function :tag "Perform a check against function"))))) (defcustom org-reverse-note-order nil "Non-nil means, store new notes at the beginning of a file or entry. @@ -8113,7 +8127,7 @@ this heading." (org-entry-put (point) n v))))) ;; Save and kill the buffer, if it is not the same buffer. - (if (not (eq this-buffer buffer)) + (if (not (eq this-buffer buffer)) (progn (save-buffer) (kill-buffer buffer))))) ;; Here we are back in the original buffer. Everything seems to have ;; worked. So now cut the tree and finish up. @@ -13581,13 +13595,45 @@ RET at beg-of-buf -> Append to file as level 2 headline (defvar org-remember-previous-location nil) (defvar org-force-remember-template-char) ;; dynamically scoped +;; Save the major mode of the buffer we called remember from +(defvar org-select-template-temp-major-mode nil) + +;; Temporary store the buffer where remember was called from +(defvar org-select-template-original-buffer nil) + (defun org-select-remember-template (&optional use-char) (when org-remember-templates - (let* ((templates (mapcar (lambda (x) + (let* ((pre-selected-templates + (mapcar + (lambda (tpl) + (let ((ctxt (nth 5 tpl)) + (mode org-select-template-temp-major-mode) + (buf org-select-template-original-buffer)) + (if (or (and (functionp ctxt) + (save-excursion + (set-buffer buf) + ;; Protect the user-defined function from error + (condition-case nil (funcall ctxt) (error nil)))) + (and ctxt (listp ctxt) + (delq nil (mapcar (lambda(x) (eq mode x)) ctxt)))) + tpl))) + org-remember-templates)) + ;; If no template at this point, add the default templates: + (pre-selected-templates1 + (if (not (delq nil pre-selected-templates)) + (mapcar (lambda(x) (if (not (nth 5 x)) x)) + org-remember-templates) + pre-selected-templates)) + ;; Then unconditionnally add template for any contexts + (pre-selected-templates2 + (append (mapcar (lambda(x) (if (eq (nth 5 x) t) x)) + org-remember-templates) + (delq nil pre-selected-templates1))) + (templates (mapcar (lambda (x) (if (stringp (car x)) (append (list (nth 1 x) (car x)) (cddr x)) (append (list (car x) "") (cdr x)))) - org-remember-templates)) + (delq nil pre-selected-templates2))) (char (or use-char (cond ((= (length templates) 1) @@ -13827,6 +13873,10 @@ associated with a template in `org-remember-templates'." ((equal goto '(4)) (org-go-to-remember-target)) ((equal goto '(16)) (org-remember-goto-last-stored)) (t + ;; set temporary variables that will be needed in + ;; `org-select-remember-template' + (setq org-select-template-temp-major-mode major-mode) + (setq org-select-template-original-buffer (current-buffer)) (if (memq org-finish-function '(remember-buffer remember-finalize)) (progn (when (< (length org-remember-templates) 2) @@ -13850,7 +13900,8 @@ associated with a template in `org-remember-templates'." "Go to the target location of a remember template. The user is queried for the template." (interactive) - (let* ((entry (org-select-remember-template template-key)) + (let* (org-select-template-temp-major-mode + (entry (org-select-remember-template template-key)) (file (nth 1 entry)) (heading (nth 2 entry)) visiting) diff --git a/org.texi b/org.texi index 73aa30a97..da1398ac7 100644 --- a/org.texi +++ b/org.texi @@ -90,8 +90,8 @@ Software Foundation raise funds for GNU development.'' * Publishing:: Create a web site of linked Org-mode files * Miscellaneous:: All the rest which did not fit elsewhere * Extensions and Hacking:: It is possible to write add-on code -* History and Acknowledgments:: How Org-mode came into being -* Main Index:: +* History and Acknowledgments:: How Org-mode came into being +* Main Index:: * Key Index:: Key bindings and where they are described @detailmenu @@ -126,7 +126,7 @@ Archiving Tables * Built-in table editor:: Simple tables -* Narrow columns:: Stop wasting space in tables +* Narrow columns:: Stop wasting space in tables * Column groups:: Grouping to trigger vertical lines * orgtbl-mode:: The table editor as minor mode * The spreadsheet:: The table editor has spreadsheet capabilities. @@ -211,7 +211,7 @@ Dates and Times * Time stamps:: Assigning a time to a tree entry * Creating timestamps:: Commands which insert timestamps * Deadlines and scheduling:: Planning your work -* Clocking work time:: +* Clocking work time:: Creating timestamps @@ -260,7 +260,7 @@ Custom agenda views * Block agenda:: All the stuff you need in a single buffer * Setting Options:: Changing the rules * Exporting Agenda Views:: Writing agendas to files. -* Extracting Agenda Information for other programs:: +* Extracting Agenda Information for other programs:: Embedded LaTeX @@ -291,14 +291,14 @@ LaTeX export * LaTeX export commands:: How to invoke LaTeX export * Quoting LaTeX code:: Incorporating literal LaTeX code -* Sectioning structure:: +* Sectioning structure:: Text interpretation by the exporter * Comment lines:: Some lines will not be exported * Initial text:: Text before the first headline * Footnotes:: Numbers like [1] -* Quoted examples:: Inserting quoted chnuks of text +* Quoted examples:: Inserting quoted chnuks of text * Enhancing text:: Subscripts, symbols and more * Export options:: How to influence the export settings @@ -1145,7 +1145,7 @@ Org-mode supports these lists by tuning filling and wrapping commands to deal with them correctly@footnote{Org-mode only changes the filling settings for Emacs. For XEmacs, you should use Kyle E. Jones' @file{filladapt.el}. To turn this on, put into @file{.emacs}: -@code{(require 'filladapt)}}. +@code{(require 'filladapt)}}. The following commands act on items when the cursor is in the first line of an item (the line with the bullet or number). @@ -1271,7 +1271,7 @@ silently in the shadow. Org-mode comes with a fast and intuitive table editor. Spreadsheet-like calculations are supported in connection with the Emacs @file{calc} -package +package @ifinfo (@pxref{Top,Calc,,calc,Gnu Emacs Calculator Manual}). @end ifinfo @@ -1282,7 +1282,7 @@ calculator). @menu * Built-in table editor:: Simple tables -* Narrow columns:: Stop wasting space in tables +* Narrow columns:: Stop wasting space in tables * Column groups:: Grouping to trigger vertical lines * orgtbl-mode:: The table editor as minor mode * The spreadsheet:: The table editor has spreadsheet capabilities. @@ -1341,7 +1341,7 @@ If not, lines are split at whitespace into fields. You can use a prefix argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u C-u} forces TAB, and a numeric argument N indicates that at least N consequtive spaces, or alternatively a TAB will be the separator. -@* +@* If there is no active region, this command creates an empty Org-mode table. But it's easier just to start typing, like @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}. @@ -1678,7 +1678,7 @@ the value directly at the hline is used. @samp{0} refers to the current row and column. Also, if you omit either the column or the row part of the reference, the current -row/column is implied. +row/column is implied. Org-mode's references with @emph{unsigned} numbers are fixed references in the sense that if you use the same reference in the formula for two @@ -2195,7 +2195,7 @@ Org-mode will recognize plain URL-like links and activate them as clickable links. The general link format, however, looks like this: @example -[[link][description]] @r{or alternatively} [[link]] +[[link][description]] @r{or alternatively} [[link]] @end example Once a link in the buffer is complete (all brackets present), Org-mode @@ -2568,7 +2568,7 @@ compatibility, line numbers can also follow a single colon.} colon. For example, when the command @kbd{C-c l} creates a link (@pxref{Handling links}) to a file, it encodes the words in the current line as a search string that can be used to find this line back later when following the -link with @kbd{C-c C-o}. +link with @kbd{C-c C-o}. Here is the syntax of the different ways to attach a search to a file link, together with an explanation: @@ -3514,10 +3514,10 @@ first, and the value after it. Here is an example: :PROPERTIES: :Title: Goldberg Variations :Composer: J.S. Bach - :Artist: Glen Gould + :Artist: Glen Gould :Publisher: Deutsche Grammphon :NDisks: 1 - :END: + :END: @end example You may define the allowed values for a particular property @samp{:Xyz:} @@ -3955,7 +3955,7 @@ is used in a much wider sense. * Time stamps:: Assigning a time to a tree entry * Creating timestamps:: Commands which insert timestamps * Deadlines and scheduling:: Planning your work -* Clocking work time:: +* Clocking work time:: @end menu @@ -4223,7 +4223,7 @@ format does not @emph{replace} the default format - instead it is put @emph{over} the default format using text properties. This has the following consequences: @itemize @bullet -@item +@item You cannot place the cursor onto a time stamp anymore, only before or after. @item @@ -4493,7 +4493,7 @@ and to use a specific time range you could write@footnote{Note that all parameters must be specified in a single line - the line is broken here only to fit it onto the manual.} @example -#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" +#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" :tend "<2006-08-10 Thu 12:00>" #+END: clocktable @@ -4584,6 +4584,29 @@ file (if not present or @code{nil}) defaults to @code{org-default-notes-file}, the heading to @code{org-remember-default-headline}. +An optional sixth element can specify the context in which the user +wants to be able to select this template. This element can be a list +of major modes, in case the template will be available while invoking +@code{org-remember} from a buffer in one of these modes. If it is a +function, the template will only be selected if the function returns +@code{t}. If this element is @code{t}, then the template will be +selected in any context and if it is @code{nil} the template will +be selected by default -- i.e. when all contextual checks failed. + +So for example: + +@example +(setq org-remember-templates + '(("Todo" ?t "* TODO %?\n %i\n %a" "~/org/TODO.org" "Tasks" (emacs-lisp-mode)) + ("Journal" ?j "* %U %?\n\n %i\n %a" "~/org/JOURNAL.org" my-check) + ("Idea" ?i "* %^@{Title@}\n %i\n %a" "~/org/JOURNAL.org" "New Ideas" t))) +@end example + +The first template will only be available when invoking @code{org-remember} +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 more than one template) and then prepare the buffer like @@ -4635,7 +4658,7 @@ bbdb | %::server %:port %:nick vm, wl, mh, rmail | %:type %:subject %:message-id | %:from %:fromname %:fromaddress | %:to %:toname %:toaddress - | %:fromto @r{(either "to NAME" or "from NAME")@footnote{This will always be the other, not the user. See the variable @code{org-from-is-user-regexp}.}} + | %:fromto @r{(either "to NAME" or "from NAME")@footnote{This will always be the other, not the user. See the variable @code{org-from-is-user-regexp}.}} gnus | %:group, @r{for messages also all email fields} w3, w3m | %:url info | %:file %:node @@ -4777,7 +4800,7 @@ combinations of different views. The extracted information is displayed in a special @emph{agenda buffer}. This buffer is read-only, but provides commands to visit the corresponding locations in the original Org-mode files, and even to -edit these files remotely. +edit these files remotely. Two variables control how the agenda buffer is displayed and whether the window configuration is restored when the agenda exits: @@ -5310,7 +5333,7 @@ Within each category, items are sorted by priority (@pxref{Priorities}), which is composed of the base priority (2000 for priority @samp{A}, 1000 for @samp{B}, and 0 for @samp{C}), plus additional increments for overdue scheduled or deadline items. -@item +@item For the TODO list, items remain in the order of categories, but within each category, sorting takes place according to priority (@pxref{Priorities}). @@ -5657,7 +5680,7 @@ dispatcher (@pxref{Agenda dispatcher}), just like the default commands. * Block agenda:: All the stuff you need in a single buffer * Setting Options:: Changing the rules * Exporting Agenda Views:: Writing agendas to files. -* Extracting Agenda Information for other programs:: +* Extracting Agenda Information for other programs:: @end menu @node Storing searches, Block agenda, Custom agenda views, Custom agenda views @@ -5784,7 +5807,7 @@ right spot in @code{org-agenda-custom-commands}. For example: (org-show-hierarchy-above nil))) ("N" search "" ((org-agenda-files '("~org/notes.org")) - (org-agenda-text-search-extra-files nil))))) + (org-agenda-text-search-extra-files nil))))) @end group @end lisp @@ -5952,7 +5975,7 @@ emacs -eval '(org-batch-store-agenda-views \ @noindent which will create the agenda views restricted to the file @file{~/org/project.org}, without diary entries and with 30 days -extent. +extent. @node Extracting Agenda Information for other programs, , Exporting Agenda Views, Custom agenda views @subsection Extracting Agenda Information for other programs @@ -5980,7 +6003,7 @@ tags/todo match string. For example, to print your local shopping list @samp{NewYork}), you could use @example -emacs -batch -l ~/.emacs \ +emacs -batch -l ~/.emacs \ -eval '(org-batch-agenda "+shop-NewYork")' | lpr @end example @@ -6328,7 +6351,7 @@ warning. If there is an active region, only the region will be exported. If the selected region is a single tree, the tree head will become the document title. If the tree head entry has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be used for the -export. +export. @kindex C-c C-e v a @item C-c C-e v a Export only the visible part of the document. @@ -6540,7 +6563,7 @@ Org-mode contains a La@TeX{} exporter written by Bastien Guerry. @menu * LaTeX export commands:: How to invoke LaTeX export * Quoting LaTeX code:: Incorporating literal LaTeX code -* Sectioning structure:: +* Sectioning structure:: @end menu @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export @@ -6669,7 +6692,7 @@ Create a single large iCalendar file from all files in The export will honor SUMMARY, DESCRIPTION and LOCATION properties if the selected entries have them. If not, the summary will be derived from the headline, and the description from the body (limited to -@code{org-icalendar-include-body} characters). +@code{org-icalendar-include-body} characters). How this calendar is best read and updated, depends on the application you are using. The FAQ covers this issue. @@ -6685,7 +6708,7 @@ in order to produce better output. * Comment lines:: Some lines will not be exported * Initial text:: Text before the first headline * Footnotes:: Numbers like [1] -* Quoted examples:: Inserting quoted chnuks of text +* Quoted examples:: Inserting quoted chnuks of text * Enhancing text:: Subscripts, symbols and more * Export options:: How to influence the export settings @end menu @@ -6785,7 +6808,7 @@ If a headline starts with the word @samp{QUOTE}, the text below the headline will be typeset as fixed-width, to allow quoting of computer codes etc. @item -Lines starting with @samp{:} are also typeset in fixed-width font. +Lines starting with @samp{:} are also typeset in fixed-width font. @table @kbd @kindex C-c : @item C-c : @@ -6853,7 +6876,7 @@ separator line will be formatted as table header fields. If a headline starts with the word @samp{QUOTE}, the text below the headline will be typeset as fixed-width, to allow quoting of computer codes etc. Lines starting with @samp{:} are also typeset in fixed-width -font. +font. @table @kbd @kindex C-c : @item C-c : @@ -6868,7 +6891,7 @@ quoted text will also be exported in this way. @cindex linebreak, forced -@item +@item A double backslash @emph{at the end of a line} enforces a line break at this position. @@ -7018,22 +7041,20 @@ the two following forms: @lisp ("project-name" :property value :property value ...) -@r{or} - +@r{or} + ("project-name" :components ("project-name" "project-name" ...)) @end lisp -In both cases, projects are configured by specifying property values. A -project defines the set of files that will be published, as well as the -publishing configuration to use when publishing those files. When a -project takes the second form listed above, the individual members of -the ``components'' property are taken to be components of the project, -which group together files requiring different publishing options. When -you publish such a ``meta-project'' all the components will also be -published. - -For now, components are not allowed to have components themselves. +In both cases, projects are configured by specifying property values. +A project defines the set of files that will be published, as well as +the publishing configuration to use when publishing those files. When +a project takes the second form listed above, the individual members +of the ``components'' property are taken to be components of the +project, which group together files requiring different publishing +options. When you publish such a ``meta-project'' all the components +will also publish. @node Sources and destinations, Selecting files, Project alist, Configuration @subsection Sources and destinations for files @@ -7060,13 +7081,13 @@ run @code{make} for updating files to be published. By default, all files with extension @file{.org} in the base directory are considered part of the project. This can be modified by setting the -properties +properties @multitable @columnfractions 0.25 0.75 @item @code{:base-extension} @tab Extension (without the dot!) of source files. This actually is a regular expression. -@item @code{:exclude} +@item @code{:exclude} @tab Regular expression to match file names that should not be published, even though they have been selected on the basis of their extension. @@ -7074,10 +7095,6 @@ extension. @item @code{:include} @tab List of files to be included regardless of @code{:base-extension} and @code{:exclude}. - -@item @code{:recursive} -@tab When non-@code{nil}, the @code{:base-directory} will be recursively -published. @end multitable @node Publishing action, Publishing options, Selecting files, Configuration @@ -7178,7 +7195,7 @@ too. @ref{Complex example} for an example of this usage. Sometime an Org-mode file to be published may contain links that are only valid in your production environment, but not in the publishing -location. In this case, use the property +location. In this case, use the property @multitable @columnfractions 0.4 0.6 @item @code{:link-validation-function} @@ -7239,12 +7256,12 @@ directory on the local machine. @lisp (setq org-publish-project-alist - '(("org" + '(("org" :base-directory "~/org/" :publishing-directory "~/public_html" :section-numbers nil :table-of-contents nil - :style ""))) @end lisp @@ -7281,17 +7298,17 @@ right place on the webserver, and publishing images to it. :headline-levels 3 :section-numbers nil :table-of-contents nil - :style "" :auto-preamble t :auto-postamble nil) - + ("images" :base-directory "~/images/" :base-extension "jpg\\|gif\\|png" :publishing-directory "/ssh:user@@host:~/html/images/" :publishing-function org-publish-attachment) - + ("other" :base-directory "~/other/" :base-extension "css\\|el" @@ -7304,7 +7321,7 @@ right place on the webserver, and publishing images to it. @section Triggering publication Once org-publish is properly configured, you can publish with the -following functions: +following functions: @table @kbd @item C-c C-e C @@ -7470,7 +7487,7 @@ showall @r{no folding at all, show everything} Then there are options for aligning tables upon visiting a file. This is useful in files containing narrowed table columns. The corresponding variable is @code{org-startup-align-all-tables}, with a default value -@code{nil}. +@code{nil}. @cindex @code{align}, STARTUP keyword @cindex @code{noalign}, STARTUP keyword @example @@ -7561,7 +7578,7 @@ tree, or from clock display, remove these highlights. @item If the cursor is in one of the special @code{#+KEYWORD} lines, this triggers scanning the buffer for these lines and updating the -information. +information. @item If the cursor is inside a table, realign the table. This command works even if the automatic table editor has been turned off. @@ -7777,7 +7794,7 @@ La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}. Imenu allows menu access to an index of items in a file. Org-mode supports imenu - all you need to do to get the index is the following: @lisp -(add-hook 'org-mode-hook +(add-hook 'org-mode-hook (lambda () 'imenu-add-to-menubar "Imenu")) @end lisp By default the index is two levels deep - you can modify the depth using @@ -8045,7 +8062,7 @@ You would activate this new link type in @file{.emacs} with @noindent Lets go through the file and see what it does. @enumerate -@item +@item It does @code{(require 'org)} to make sure that @file{org.el} has been loaded. @item @@ -8166,7 +8183,7 @@ number of different solutions: The table could be placed in a block comment if that is supported by the language. For example, in C-mode you could wrap the table between @samp{/*} and @samp{*/} lines. -@item +@item Sometimes it is possible to put the table after some kind of @i{END} statement, for example @samp{\bye} in TeX and @samp{\end@{document@}} in La@TeX{}. @@ -8376,7 +8393,7 @@ Use @code{ORGLST} instead of @code{ORGTBL}. @item The available translation functions for radio lists don't take parameters. -@item +@item `C-c C-c' will work when pressed on the first item of the list. @end itemize From c4b0866e2901b83cbbfbfb3412557989761a6401 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 4 Mar 2008 03:52:01 +0000 Subject: [PATCH 13/13] Added an entry for the template pre-selection feature. --- ORGWEBPAGE/Changes.org | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index 4268976e9..4a4dc6154 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -63,6 +63,27 @@ entries. These can be used in dependency implementations, or to tie clock tables and column view tables to entries. +*** New template option: pre-selection contexts + + - Templates now allow six elements. The last element defines + the contexts in which the template should be offered. It + can be a list of major modes, a function, `t' or `nil'. If + it is a list of major-mode, the template will be available + only when `org-remember' is called from a buffer in one of + these modes. If it is a function, the template will be + offered only if the function returns `t' when called in the + current buffer. A value of `t' for this element means + select this template in any context. `nil' means use this + template by default, when other checks failed. + + (setq org-remember-templates + '(("Org" ?o "* %a\n\n%i%?" "~/org/bzg.org" "Org" my-defun))) + + M-x org-remember RET will present this template only if + calling `my-defun' in the current buffer returns `nil'. + + The (info "(org)Remember templates") for details. + *** Misc - Phil Jackson's org-irc.el is now part of the Org-mode core, @@ -90,7 +111,6 @@ This was a proposal by Adam Spiers. - - `C-c -' has now more functions: + In a table, add a hline as before + In an item list, cycle bullet type as before