From bcce93f04c2df6a5bb5dd1a8e611de734d24aee7 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 9 Oct 2021 16:34:12 -0400 Subject: [PATCH] Update to Org 9.5-46-gb71474 --- doc/misc/org.org | 71 ++++++++++++++++----------------- lisp/org/oc-biblatex.el | 13 +++--- lisp/org/oc.el | 52 ++++++++++++++++-------- lisp/org/ol-man.el | 86 ++++++++++++++++++++++++++++++++++++++++ lisp/org/org-footnote.el | 5 ++- lisp/org/org-lint.el | 2 +- lisp/org/org-version.el | 2 +- lisp/org/org.el | 2 +- 8 files changed, 168 insertions(+), 65 deletions(-) create mode 100644 lisp/org/ol-man.el diff --git a/doc/misc/org.org b/doc/misc/org.org index 7b1277c7a2e..5977f091610 100644 --- a/doc/misc/org.org +++ b/doc/misc/org.org @@ -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 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 Blank the field at point. @@ -16517,16 +16516,16 @@ keywords. :END: #+cindex: citation -As of Org 9.5, a new library =oc.el= provides tooling to handle -citations in Org via "citation processors" that offer some or all of -the following capabilities: +The =oc.el= library provides tooling to handle citations in Org via +"citation processors" that offer some or all of the following +capabilities: -- "activate" :: Fontification, tooltip preview, etc. -- "follow" :: At-point actions on citations via ~org-open-at-point~. -- "insert" :: Add and edit citations via ~org-cite-insert~. -- "export" :: Via different libraries for different target formats. +- activate :: Fontification, tooltip preview, etc. +- follow :: At-point actions on citations via ~org-open-at-point~. +- insert :: Add and edit citations via ~org-cite-insert~. +- 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-export-processors~ respectively. @@ -16544,8 +16543,10 @@ more "bibliography" keywords. #+bibliography: "/some/file/with spaces/in its name.bib" #+end_example +#+kindex: C-c C-x @ +#+findex: org-cite-insert 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 identifying a reference in the bibliography. @@ -16554,9 +16555,10 @@ identifying a reference in the bibliography. - Each key starts with the character =@=. -- Each key can be qualified by a /prefix/ (e.g. "see ") and/or a - /suffix/ (e.g. "p. 123"), giving informations useful or necessary fo - the comprehension of the citation but not included in the reference. +- Each key can be qualified by a /prefix/ (e.g.\nbsp{}"see ") and/or + a /suffix/ (e.g.\nbsp{}"p.\nbsp{}123"), giving informations useful or necessary + fo the comprehension of the citation but not included in the + reference. - A single citation can cite more than one reference ; the keys are 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 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] -#+end_example +: [cite/style:common prefix ;prefix @key suffix; ... ; common suffix] 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= (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 needs are minimal; @@ -16593,45 +16593,42 @@ Org currently includes the following export processors: - In contrast, two other processors target LaTeX and LaTeX-derived 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 - data and style files compatible with this processor (including a - large number of publishers' styles). It uses citation commands + data and style files compatible with this processor (including + a large number of publishers' styles). It uses citation commands implemented in the LaTeX package =natbib=, allowing more stylistic variants that LaTeX's =\cite= command. - biblatex :: this backend allows the use of data and formats - prepared for =biblatex=, an alternate bibliographic processor used - with LaTeX, which overcomes some serious =bibtex= limitations, but - has not (yet?) been widely adopted by publishers. + prepared for BibLaTeX, an alternate bibliographic processor used + with LaTeX, which overcomes some serious BibTeX limitations, but + 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 are optional) -#+begin_example -#+cite_export: basic author author-year -#+end_example +: #+cite_export: basic author author-year +#+texinfo: @noindent specifies the "basic" export processor with citations inserted as author's name and references indexed by author's names and year; -#+begin_example -#+cite_export: csl /some/path/to/vancouver-brackets.csl -#+end_example +: #+cite_export: csl /some/path/to/vancouver-brackets.csl +#+texinfo: @noindent specifies the "csl" processor and CSL style, which in this case defines numeric citations and numeric references according to the =Vancouver= specification (as style used in many medical journals), following a typesetting variation putting citations between brackets; -#+begin_example -#+cite_export: natbib kluwer -#+end_example +: #+cite_export: natbib kluwer -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 -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. * Working with Source Code diff --git a/lisp/org/oc-biblatex.el b/lisp/org/oc-biblatex.el index f517e391398..daf56e792a6 100644 --- a/lisp/org/oc-biblatex.el +++ b/lisp/org/oc-biblatex.el @@ -165,15 +165,11 @@ INFO is the export state, as a property list." (org-cite-biblatex--atomic-arguments (list r) info)) (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 - ;; arguments. So we look ahead and insert a \relax if - ;; needed. - (and (let ((next (org-export-get-next-element citation info))) - (and next - (string-match (rx string-start (or "{" "[")) - (org-export-data next info)))) - "\\relax")))) + ;; arguments. So we stop any further parsing by inserting + ;; a \relax unconditionally. + "\\relax"))) (defun org-cite-biblatex--command (citation info base &optional multi no-opt) "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")) (("locators" "l") ("bare" "b") ("caps" "c") ("bare-caps" "bc")) (("noauthor" "na")) + (("nocite" "n")) (("text" "t") ("caps" "c")) (("nil") ("bare" "b") ("caps" "c") ("bare-caps" "bc")))) diff --git a/lisp/org/oc.el b/lisp/org/oc.el index bbf2195fbd8..2f741768f88 100644 --- a/lisp/org/oc.el +++ b/lisp/org/oc.el @@ -89,7 +89,6 @@ (declare-function org-element-type "org-element" (element)) (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-previous-element "org-export" (blob info &optional n)) (declare-function org-export-raw-string "org-export" (s)) @@ -152,10 +151,10 @@ triplet following the pattern (NAME BIBLIOGRAPHY-STYLE CITATION-STYLE) There, NAME is the name of a registered citation processor providing export -functionality, as a symbol. BIBLIOGRAPHY-STYLE (resp. CITATION-STYLE) is the -desired default style to use when printing a bibliography (resp. exporting a -citation), as a string or nil. Both BIBLIOGRAPHY-STYLE and CITATION-STYLE are -optional. NAME is mandatory. +functionality, as a symbol. BIBLIOGRAPHY-STYLE (respectively CITATION-STYLE) +is the desired default style to use when printing a bibliography (respectively +exporting a citation), as a string or nil. Both BIBLIOGRAPHY-STYLE and +CITATION-STYLE are optional. NAME is mandatory. 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, @@ -502,8 +501,8 @@ This function assumes S precedes CITATION." (defun org-cite--move-punct-before (punct citation s info) "Move punctuation PUNCT before CITATION object. -String S contains PUNCT. The function assumes S follows CITATION. -Parse tree is modified by side-effect." +String S contains PUNCT. INFO is the export state, as a property list. +The function assumes S follows CITATION. Parse tree is modified by side-effect." (if (equal s punct) (org-element-extract-element s) ;it would be empty anyway (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 ;; `org-element-map' is going to enter it anyway. ((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 - (org-export-get-footnote-definition datum info))))) + (let ((label (org-element-property :label datum))) + (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)))) (funcall search-cites (plist-get info :parse-tree)) (let ((result (nreverse cites))) @@ -877,13 +887,16 @@ modified by side-effect." 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. When nil, it defaults to `org-cite-punctuation-marks'. Parse tree is modified by side-effect. 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 (pcase-let* ((rule (or rule (org-cite--get-note-rule info))) (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' ;; property to the object before, if any. (org-cite--set-previous-post-blank cite blanks info) - ;; We want to be sure any non-note citation is preceded by - ;; a space. This is particularly important when using + ;; Make sure there is a space between a quotation mark and + ;; a citation. This is particularly important when using ;; `adaptive' note rule. See `org-cite-note-rules'. - (unless (org-cite-inside-footnote-p cite t) - (org-cite--set-previous-post-blank cite 1 info)) + (let ((previous (org-export-get-previous-element cite info))) + (when (and (org-string-nw-p previous) + (string-suffix-p "\"" previous)) + (org-cite--set-previous-post-blank cite 1 info))) (pcase replacement ;; String. ((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) (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))) (cond ;; 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") (if (eq (org-element-class context) 'object) (point) (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) (> (point) (+ (org-element-property :begin context) (current-indentation) diff --git a/lisp/org/ol-man.el b/lisp/org/ol-man.el new file mode 100644 index 00000000000..0d9ac7c8c71 --- /dev/null +++ b/lisp/org/ol-man.el @@ -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 +;; Maintainer: Bastien Guerry +;; 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 . +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; 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§ion=all" link)) + (desc (or description link))) + (cond + ((eq format 'html) (format "%s" 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 diff --git a/lisp/org/org-footnote.el b/lisp/org/org-footnote.el index c8c4dae8003..fcc7579bad5 100644 --- a/lisp/org/org-footnote.el +++ b/lisp/org/org-footnote.el @@ -281,7 +281,10 @@ otherwise." (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \r\t\n") (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. ((eq (org-element-class context) 'element) nil) ;; Just before object is fine. diff --git a/lisp/org/org-lint.el b/lisp/org/org-lint.el index 5c64c5a5c94..da5e6ae7995 100644 --- a/lisp/org/org-lint.el +++ b/lisp/org/org-lint.el @@ -350,7 +350,7 @@ called with one argument, the key used for comparison." (lambda (datum name) (goto-char (org-element-property :begin datum)) (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)) (lambda (key) (format "Duplicate NAME \"%s\"" key)))) diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index 5bccbe497cc..9948008774d 100644 --- a/lisp/org/org-version.el +++ b/lisp/org/org-version.el @@ -11,7 +11,7 @@ Inserted by installing Org mode or when a release is made." (defun org-git-version () "The Git version of Org mode. 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)) (provide 'org-version) diff --git a/lisp/org/org.el b/lisp/org/org.el index bc0ea24bee7..c2a37e6cdd1 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -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." (interactive) (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)) (message "Saving all Org buffers... done")) -- 2.39.2