Update to Org 9.5-46-gb71474

This commit is contained in:
Kyle Meyer 2021-10-09 16:34:12 -04:00
parent 5d408f1a24
commit bcce93f04c
8 changed files with 168 additions and 65 deletions

View file

@ -1355,9 +1355,8 @@ you, configure the option ~org-table-auto-blank-field~.
Re-align the table, move to the next field. Creates a new row if Re-align the table, move to the next field. Creates a new row if
necessary. necessary.
- {{{kbd(C-c SPC)}}} (~org-table-blank-field~) :: - {{{kbd(M-x org-table-blank-field)}}} ::
#+kindex: C-c SPC
#+findex: org-table-blank-field #+findex: org-table-blank-field
Blank the field at point. Blank the field at point.
@ -16517,16 +16516,16 @@ keywords.
:END: :END:
#+cindex: citation #+cindex: citation
As of Org 9.5, a new library =oc.el= provides tooling to handle The =oc.el= library provides tooling to handle citations in Org via
citations in Org via "citation processors" that offer some or all of "citation processors" that offer some or all of the following
the following capabilities: capabilities:
- "activate" :: Fontification, tooltip preview, etc. - activate :: Fontification, tooltip preview, etc.
- "follow" :: At-point actions on citations via ~org-open-at-point~. - follow :: At-point actions on citations via ~org-open-at-point~.
- "insert" :: Add and edit citations via ~org-cite-insert~. - insert :: Add and edit citations via ~org-cite-insert~.
- "export" :: Via different libraries for different target formats. - export :: Via different libraries for different target formats.
The user can configure these with ~org-cite-active-processor~, The user can configure these with ~org-cite-activate-processor~,
~org-cite-follow-processor~, ~org-cite-insert-processor~, and ~org-cite-follow-processor~, ~org-cite-insert-processor~, and
~org-cite-export-processors~ respectively. ~org-cite-export-processors~ respectively.
@ -16544,8 +16543,10 @@ more "bibliography" keywords.
#+bibliography: "/some/file/with spaces/in its name.bib" #+bibliography: "/some/file/with spaces/in its name.bib"
#+end_example #+end_example
#+kindex: C-c C-x @
#+findex: org-cite-insert
One can then insert and edit citations using ~org-cite-insert~, called One can then insert and edit citations using ~org-cite-insert~, called
with {{{kbd(M-x org-cite-insert)}}}. with {{{kbd(C-c C-x @)}}}.
A /citation/ requires one or more citation /key(s)/, elements A /citation/ requires one or more citation /key(s)/, elements
identifying a reference in the bibliography. identifying a reference in the bibliography.
@ -16554,9 +16555,10 @@ identifying a reference in the bibliography.
- Each key starts with the character =@=. - Each key starts with the character =@=.
- Each key can be qualified by a /prefix/ (e.g. "see ") and/or a - Each key can be qualified by a /prefix/ (e.g.\nbsp{}"see ") and/or
/suffix/ (e.g. "p. 123"), giving informations useful or necessary fo a /suffix/ (e.g.\nbsp{}"p.\nbsp{}123"), giving informations useful or necessary
the comprehension of the citation but not included in the reference. fo the comprehension of the citation but not included in the
reference.
- A single citation can cite more than one reference ; the keys are - A single citation can cite more than one reference ; the keys are
separated by semicolons ; the formatting of such citation groups is separated by semicolons ; the formatting of such citation groups is
@ -16564,11 +16566,9 @@ identifying a reference in the bibliography.
- One can also specify a stylistic variation for the citations by - One can also specify a stylistic variation for the citations by
inserting a =/= and a style name between the =cite= keyword and the inserting a =/= and a style name between the =cite= keyword and the
colon ; this usially makes sense only for the author-year styles. colon; this usually makes sense only for the author-year styles.
#+begin_example : [cite/style:common prefix ;prefix @key suffix; ... ; common suffix]
[cite/style:common prefix ;prefix @key suffix; ... ; common suffix]
#+end_example
The only mandatory elements are: The only mandatory elements are:
@ -16583,7 +16583,7 @@ Org currently includes the following export processors:
- Two processors can export to a variety of formats, including =latex= - Two processors can export to a variety of formats, including =latex=
(and therefore =pdf=), =html=, =odt= and plain (UTF8) text: (and therefore =pdf=), =html=, =odt= and plain (UTF8) text:
- basic :: a basic export processors, well adapted to situations - basic :: a basic export processor, well adapted to situations
where backward compatibility is not a requirement and formatting where backward compatibility is not a requirement and formatting
needs are minimal; needs are minimal;
@ -16593,45 +16593,42 @@ Org currently includes the following export processors:
- In contrast, two other processors target LaTeX and LaTeX-derived - In contrast, two other processors target LaTeX and LaTeX-derived
formats exclusively: formats exclusively:
- natbib :: this export processor uses =bibtex=, the historical - natbib :: this export processor uses BibTeX, the historical
bibliographic processor used with LaTeX, thus allowing the use of bibliographic processor used with LaTeX, thus allowing the use of
data and style files compatible with this processor (including a data and style files compatible with this processor (including
large number of publishers' styles). It uses citation commands a large number of publishers' styles). It uses citation commands
implemented in the LaTeX package =natbib=, allowing more stylistic implemented in the LaTeX package =natbib=, allowing more stylistic
variants that LaTeX's =\cite= command. variants that LaTeX's =\cite= command.
- biblatex :: this backend allows the use of data and formats - biblatex :: this backend allows the use of data and formats
prepared for =biblatex=, an alternate bibliographic processor used prepared for BibLaTeX, an alternate bibliographic processor used
with LaTeX, which overcomes some serious =bibtex= limitations, but with LaTeX, which overcomes some serious BibTeX limitations, but
has not (yet?) been widely adopted by publishers. has not (yet?)\nbsp{}been widely adopted by publishers.
The =#+cite_export:= keyword specifies the export processor and the The =CITE_EXPORT= keyword specifies the export processor and the
citation (and possibly reference) style(s); for example (all arguments citation (and possibly reference) style(s); for example (all arguments
are optional) are optional)
#+begin_example : #+cite_export: basic author author-year
#+cite_export: basic author author-year
#+end_example
#+texinfo: @noindent
specifies the "basic" export processor with citations inserted as specifies the "basic" export processor with citations inserted as
author's name and references indexed by author's names and year; author's name and references indexed by author's names and year;
#+begin_example : #+cite_export: csl /some/path/to/vancouver-brackets.csl
#+cite_export: csl /some/path/to/vancouver-brackets.csl
#+end_example
#+texinfo: @noindent
specifies the "csl" processor and CSL style, which in this case specifies the "csl" processor and CSL style, which in this case
defines numeric citations and numeric references according to the defines numeric citations and numeric references according to the
=Vancouver= specification (as style used in many medical journals), =Vancouver= specification (as style used in many medical journals),
following a typesetting variation putting citations between brackets; following a typesetting variation putting citations between brackets;
#+begin_example : #+cite_export: natbib kluwer
#+cite_export: natbib kluwer
#+end_example
specifies the "natbib" export processor with a label citation style #+texinfo: @noindent
specifies the =natbib= export processor with a label citation style
conformant to the Harvard style and the specification of the conformant to the Harvard style and the specification of the
Wolkers-Kluwer publisher; since it relies on the =bibtex= processor of Wolkers-Kluwer publisher; since it relies on the ~bibtex~ processor of
your LaTeX installation, it won't export to anything but PDF. your LaTeX installation, it won't export to anything but PDF.
* Working with Source Code * Working with Source Code

View file

@ -165,15 +165,11 @@ INFO is the export state, as a property list."
(org-cite-biblatex--atomic-arguments (list r) info)) (org-cite-biblatex--atomic-arguments (list r) info))
(org-cite-get-references citation) (org-cite-get-references citation)
"") "")
;; According to biblatex manual, left braces or brackets ;; According to BibLaTeX manual, left braces or brackets
;; following a multicite command could be parsed as other ;; following a multicite command could be parsed as other
;; arguments. So we look ahead and insert a \relax if ;; arguments. So we stop any further parsing by inserting
;; needed. ;; a \relax unconditionally.
(and (let ((next (org-export-get-next-element citation info))) "\\relax")))
(and next
(string-match (rx string-start (or "{" "["))
(org-export-data next info))))
"\\relax"))))
(defun org-cite-biblatex--command (citation info base &optional multi no-opt) (defun org-cite-biblatex--command (citation info base &optional multi no-opt)
"Return biblatex command using BASE name for CITATION object. "Return biblatex command using BASE name for CITATION object.
@ -314,6 +310,7 @@ to the document, and set styles."
'((("author" "a") ("caps" "c") ("full" "f") ("caps-full" "cf")) '((("author" "a") ("caps" "c") ("full" "f") ("caps-full" "cf"))
(("locators" "l") ("bare" "b") ("caps" "c") ("bare-caps" "bc")) (("locators" "l") ("bare" "b") ("caps" "c") ("bare-caps" "bc"))
(("noauthor" "na")) (("noauthor" "na"))
(("nocite" "n"))
(("text" "t") ("caps" "c")) (("text" "t") ("caps" "c"))
(("nil") ("bare" "b") ("caps" "c") ("bare-caps" "bc")))) (("nil") ("bare" "b") ("caps" "c") ("bare-caps" "bc"))))

View file

@ -89,7 +89,6 @@
(declare-function org-element-type "org-element" (element)) (declare-function org-element-type "org-element" (element))
(declare-function org-export-derived-backend-p "org-export" (backend &rest backends)) (declare-function org-export-derived-backend-p "org-export" (backend &rest backends))
(declare-function org-export-get-footnote-definition "org-export" (footnote-reference info))
(declare-function org-export-get-next-element "org-export" (blob info &optional n)) (declare-function org-export-get-next-element "org-export" (blob info &optional n))
(declare-function org-export-get-previous-element "org-export" (blob info &optional n)) (declare-function org-export-get-previous-element "org-export" (blob info &optional n))
(declare-function org-export-raw-string "org-export" (s)) (declare-function org-export-raw-string "org-export" (s))
@ -152,10 +151,10 @@ triplet following the pattern
(NAME BIBLIOGRAPHY-STYLE CITATION-STYLE) (NAME BIBLIOGRAPHY-STYLE CITATION-STYLE)
There, NAME is the name of a registered citation processor providing export There, NAME is the name of a registered citation processor providing export
functionality, as a symbol. BIBLIOGRAPHY-STYLE (resp. CITATION-STYLE) is the functionality, as a symbol. BIBLIOGRAPHY-STYLE (respectively CITATION-STYLE)
desired default style to use when printing a bibliography (resp. exporting a is the desired default style to use when printing a bibliography (respectively
citation), as a string or nil. Both BIBLIOGRAPHY-STYLE and CITATION-STYLE are exporting a citation), as a string or nil. Both BIBLIOGRAPHY-STYLE and
optional. NAME is mandatory. CITATION-STYLE are optional. NAME is mandatory.
The export process selects the citation processor associated to the current The export process selects the citation processor associated to the current
export back-end, or the most specific back-end the current one is derived from, export back-end, or the most specific back-end the current one is derived from,
@ -502,8 +501,8 @@ This function assumes S precedes CITATION."
(defun org-cite--move-punct-before (punct citation s info) (defun org-cite--move-punct-before (punct citation s info)
"Move punctuation PUNCT before CITATION object. "Move punctuation PUNCT before CITATION object.
String S contains PUNCT. The function assumes S follows CITATION. String S contains PUNCT. INFO is the export state, as a property list.
Parse tree is modified by side-effect." The function assumes S follows CITATION. Parse tree is modified by side-effect."
(if (equal s punct) (if (equal s punct)
(org-element-extract-element s) ;it would be empty anyway (org-element-extract-element s) ;it would be empty anyway
(org-element-set-element s (substring s (length punct)))) (org-element-set-element s (substring s (length punct))))
@ -799,9 +798,20 @@ INFO is the export communication channel, as a property list."
;; Do not force entering inline definitions, since ;; Do not force entering inline definitions, since
;; `org-element-map' is going to enter it anyway. ;; `org-element-map' is going to enter it anyway.
((guard (eq 'inline (org-element-property :type datum)))) ((guard (eq 'inline (org-element-property :type datum))))
;; Find definition for current standard
;; footnote reference. Unlike to
;; `org-export-get-footnote-definition', do
;; not cache results as they would contain
;; un-processed citation objects.
(_ (_
(funcall search-cites (let ((label (org-element-property :label datum)))
(org-export-get-footnote-definition datum info))))) (funcall
search-cites
(org-element-map data 'footnote-definition
(lambda (d)
(and
(equal label (org-element-property :label d))
(or (org-element-contents d) "")))))))))
info nil 'footnote-definition t)))) info nil 'footnote-definition t))))
(funcall search-cites (plist-get info :parse-tree)) (funcall search-cites (plist-get info :parse-tree))
(let ((result (nreverse cites))) (let ((result (nreverse cites)))
@ -877,13 +887,16 @@ modified by side-effect."
INFO is the export state, as a property list. INFO is the export state, as a property list.
Optional argument RULE is the punctuation rule used, as a triplet. When nil,
rule is determined according to `org-cite-note-rules', which see.
Optional argument PUNCT is a list of punctuation marks to be considered. Optional argument PUNCT is a list of punctuation marks to be considered.
When nil, it defaults to `org-cite-punctuation-marks'. When nil, it defaults to `org-cite-punctuation-marks'.
Parse tree is modified by side-effect. Parse tree is modified by side-effect.
Note: when calling both `org-cite-adjust-note' and `org-cite-wrap-citation' on Note: when calling both `org-cite-adjust-note' and `org-cite-wrap-citation' on
the same object, call `org-cite-adjust-punctuation' first." the same object, call `org-cite-adjust-note' first."
(when org-cite-adjust-note-numbers (when org-cite-adjust-note-numbers
(pcase-let* ((rule (or rule (org-cite--get-note-rule info))) (pcase-let* ((rule (or rule (org-cite--get-note-rule info)))
(punct-re (regexp-opt (or punct org-cite-punctuation-marks))) (punct-re (regexp-opt (or punct org-cite-punctuation-marks)))
@ -1274,11 +1287,13 @@ by side-effect."
;; Before removing the citation, transfer its `:post-blank' ;; Before removing the citation, transfer its `:post-blank'
;; property to the object before, if any. ;; property to the object before, if any.
(org-cite--set-previous-post-blank cite blanks info) (org-cite--set-previous-post-blank cite blanks info)
;; We want to be sure any non-note citation is preceded by ;; Make sure there is a space between a quotation mark and
;; a space. This is particularly important when using ;; a citation. This is particularly important when using
;; `adaptive' note rule. See `org-cite-note-rules'. ;; `adaptive' note rule. See `org-cite-note-rules'.
(unless (org-cite-inside-footnote-p cite t) (let ((previous (org-export-get-previous-element cite info)))
(org-cite--set-previous-post-blank cite 1 info)) (when (and (org-string-nw-p previous)
(string-suffix-p "\"" previous))
(org-cite--set-previous-post-blank cite 1 info)))
(pcase replacement (pcase replacement
;; String. ;; String.
((pred stringp) ((pred stringp)
@ -1384,7 +1399,8 @@ ARG is the prefix argument received when calling `org-open-at-point', or nil."
;;; Meta-command for citation insertion (insert capability) ;;; Meta-command for citation insertion (insert capability)
(defun org-cite--allowed-p (context) (defun org-cite--allowed-p (context)
"Non-nil when a citation can be inserted at point." "Non-nil when a citation can be inserted at point.
CONTEXT is the element or object at point, as returned by `org-element-context'."
(let ((type (org-element-type context))) (let ((type (org-element-type context)))
(cond (cond
;; No citation in attributes, except in parsed ones. ;; No citation in attributes, except in parsed ones.
@ -1430,7 +1446,11 @@ ARG is the prefix argument received when calling `org-open-at-point', or nil."
(skip-chars-backward " \r\t\n") (skip-chars-backward " \r\t\n")
(if (eq (org-element-class context) 'object) (point) (if (eq (org-element-class context) 'object) (point)
(line-beginning-position 2))))) (line-beginning-position 2)))))
;; At the start of a list item is fine, as long as the bullet is unaffected. ;; At the beginning of a footnote definition, right after the
;; label, is OK.
((eq type 'footnote-definition) (looking-at (rx space)))
;; At the start of a list item is fine, as long as the bullet is
;; unaffected.
((eq type 'item) ((eq type 'item)
(> (point) (+ (org-element-property :begin context) (> (point) (+ (org-element-property :begin context)
(current-indentation) (current-indentation)

86
lisp/org/ol-man.el Normal file
View file

@ -0,0 +1,86 @@
;;; ol-man.el --- Links to man pages -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Maintainer: Bastien Guerry <bzg@gnu.org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;;
;; This file is part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
(require 'ol)
(org-link-set-parameters "man"
:follow #'org-man-open
:export #'org-man-export
:store #'org-man-store-link)
(defcustom org-man-command 'man
"The Emacs command to be used to display a man page."
:group 'org-link
:type '(choice (const man) (const woman)))
(defun org-man-open (path _)
"Visit the manpage on PATH.
PATH should be a topic that can be thrown at the man command.
If PATH contains extra ::STRING which will use `occur' to search
matched strings in man buffer."
(string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path)
(let* ((command (match-string 1 path))
(search (match-string 2 path)))
(funcall org-man-command command)
(when search
(with-current-buffer (concat "*Man " command "*")
(goto-char (point-min))
(search-forward search)))))
(defun org-man-store-link ()
"Store a link to a README file."
(when (memq major-mode '(Man-mode woman-mode))
;; This is a man page, we do make this link
(let* ((page (org-man-get-page-name))
(link (concat "man:" page))
(description (format "Manpage for %s" page)))
(org-link-store-props
:type "man"
:link link
:description description))))
(defun org-man-get-page-name ()
"Extract the page name from the buffer name."
;; This works for both `Man-mode' and `woman-mode'.
(if (string-match " \\(\\S-+\\)\\*" (buffer-name))
(match-string 1 (buffer-name))
(error "Cannot create link to this man page")))
(defun org-man-export (link description format)
"Export a man page link from Org files."
(let ((path (format "http://man.he.net/?topic=%s&section=all" link))
(desc (or description link)))
(cond
((eq format 'html) (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
((eq format 'latex) (format "\\href{%s}{%s}" path desc))
((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
((eq format 'ascii) (format "%s (%s)" desc path))
((eq format 'md) (format "[%s](%s)" desc path))
(t path))))
(provide 'ol-man)
;;; ol-man.el ends here

View file

@ -281,7 +281,10 @@ otherwise."
(save-excursion (goto-char (org-element-property :end context)) (save-excursion (goto-char (org-element-property :end context))
(skip-chars-backward " \r\t\n") (skip-chars-backward " \r\t\n")
(if (eq (org-element-class context) 'object) (point) (if (eq (org-element-class context) 'object) (point)
(1+ (line-beginning-position 2)))))) (line-beginning-position 2)))))
;; At the beginning of a footnote definition, right after the
;; label, is OK.
((eq type 'footnote-definition) (looking-at (rx space)))
;; Other elements are invalid. ;; Other elements are invalid.
((eq (org-element-class context) 'element) nil) ((eq (org-element-class context) 'element) nil)
;; Just before object is fine. ;; Just before object is fine.

View file

@ -350,7 +350,7 @@ called with one argument, the key used for comparison."
(lambda (datum name) (lambda (datum name)
(goto-char (org-element-property :begin datum)) (goto-char (org-element-property :begin datum))
(re-search-forward (re-search-forward
(format "^[ \t]*#\\+[A-Za-z]+: +%s *$" (regexp-quote name))) (format "^[ \t]*#\\+[A-Za-z]+:[ \t]*%s[ \t]*$" (regexp-quote name)))
(match-beginning 0)) (match-beginning 0))
(lambda (key) (format "Duplicate NAME \"%s\"" key)))) (lambda (key) (format "Duplicate NAME \"%s\"" key))))

View file

@ -11,7 +11,7 @@ Inserted by installing Org mode or when a release is made."
(defun org-git-version () (defun org-git-version ()
"The Git version of Org mode. "The Git version of Org mode.
Inserted by installing Org or when a release is made." Inserted by installing Org or when a release is made."
(let ((org-git-version "release_9.5-30-g10dc9d")) (let ((org-git-version "release_9.5-46-gb71474"))
org-git-version)) org-git-version))
(provide 'org-version) (provide 'org-version)

View file

@ -15362,7 +15362,7 @@ The value is a list, with zero or more of the symbols `effort', `appt',
"Save all Org buffers without user confirmation." "Save all Org buffers without user confirmation."
(interactive) (interactive)
(message "Saving all Org buffers...") (message "Saving all Org buffers...")
(save-some-buffers t (lambda () (derived-mode-p 'org-mode))) (save-some-buffers t (lambda () (and (derived-mode-p 'org-mode) t)))
(when (featurep 'org-id) (org-id-locations-save)) (when (featurep 'org-id) (org-id-locations-save))
(message "Saving all Org buffers... done")) (message "Saving all Org buffers... done"))