Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode

This commit is contained in:
Carsten Dominik 2008-03-04 06:30:59 +01:00
commit 5f2051ec22
6 changed files with 217 additions and 95 deletions

View File

@ -1,5 +1,15 @@
2008-03-03 Carsten Dominik <dominik@science.uva.nl>
2008-03-04 Bastien Guerry <bzg@altern.org>
* 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 <bzg@altern.org>
* org-publish.el (org-publish-delete-dups): Aliases for
`delete-dups'.
2008-03-03 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-toggle-region-items): New function.
(org-toggle-region-headings): New function.

View File

@ -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

View File

@ -50,7 +50,10 @@
;;
;;; Code:
(require 'cl)
(eval-when-compile
(require 'cl))
(require 'org)
(require 'erc)
(require 'erc-log)

View File

@ -335,6 +335,25 @@ 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
;; Delete-dups is not in Emacs <22
(if (fboundp 'delete-dups)
(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
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
@ -346,12 +365,12 @@ 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)
(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))
@ -364,7 +383,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-dups
(append without-component
(car (mapcar (lambda(p) (org-publish-expand-components p))
with-component))))))
@ -372,7 +391,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-dups
(mapcar (lambda(c) (assoc c org-publish-project-alist))
components))))
@ -414,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)))
@ -538,17 +557,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
(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)

63
org.el
View File

@ -1543,6 +1543,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:
@ -1587,7 +1595,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 '("")))
@ -1596,7 +1604,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")
@ -1605,7 +1613,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.
@ -13580,13 +13594,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)
@ -13826,6 +13872,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)
@ -13849,7 +13899,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)

View File

@ -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
@ -7024,16 +7047,14 @@ the two following forms:
@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
@ -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