From bb209cd5ab819c72784de7278092705e59ff41d5 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 2 Oct 2021 14:27:55 -0400 Subject: [PATCH] Update to Org 9.5-30-g10dc9d The plan is to cut the Org 9.5.1 release and include it in Emacs 28.1, but in the meantime regularly sync changes from Org's bugfix branch to emacs-28. This sync includes files from Org 9.5's new etc/csl/ directory that should have been synced in bf9ec3d91a (Update to Org 9.5, 2021-09-29). --- etc/org/csl/README | 10 + etc/org/csl/chicago-author-date.csl | 658 ++++++++++++++++++++++++++++ etc/org/csl/locales-en-US.xml | 357 +++++++++++++++ lisp/org/ob-gnuplot.el | 2 +- lisp/org/ob-julia.el | 42 +- lisp/org/oc-csl.el | 24 +- lisp/org/org-macs.el | 9 +- lisp/org/org-src.el | 19 +- lisp/org/org-version.el | 2 +- lisp/org/org.el | 1 + 10 files changed, 1074 insertions(+), 50 deletions(-) create mode 100644 etc/org/csl/README create mode 100644 etc/org/csl/chicago-author-date.csl create mode 100644 etc/org/csl/locales-en-US.xml diff --git a/etc/org/csl/README b/etc/org/csl/README new file mode 100644 index 00000000000..a9212207ccf --- /dev/null +++ b/etc/org/csl/README @@ -0,0 +1,10 @@ +These data files are used by Org's oc-csl.el library. + +LICENSE INFORMATION + +chicago-author-date.csl +locales-en-US.xml + + Both of these files are part of the Citation Style Language (CSL) + project () and are released under the + Creative Commons Attribution-ShareAlike 3.0 Unported license. diff --git a/etc/org/csl/chicago-author-date.csl b/etc/org/csl/chicago-author-date.csl new file mode 100644 index 00000000000..8c133354b38 --- /dev/null +++ b/etc/org/csl/chicago-author-date.csl @@ -0,0 +1,658 @@ + + diff --git a/etc/org/csl/locales-en-US.xml b/etc/org/csl/locales-en-US.xml new file mode 100644 index 00000000000..be78c5e81fd --- /dev/null +++ b/etc/org/csl/locales-en-US.xml @@ -0,0 +1,357 @@ + + + + + Andrew Dunning + + + Sebastian Karcher + + + Rintze M. Zelle + + This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License + 2015-10-10T23:31:02+00:00 + + + + + + + + + + + + + + accessed + and + and others + anonymous + anon. + at + available at + by + circa + c. + cited + + edition + editions + + ed. + et al. + forthcoming + from + ibid. + in + in press + internet + interview + letter + no date + n.d. + online + presented at the + + reference + references + + + ref. + refs. + + retrieved + scale + version + + + AD + BC + + + “ + ” + ‘ + ’ + – + + + th + st + nd + rd + th + th + th + + + first + second + third + fourth + fifth + sixth + seventh + eighth + ninth + tenth + + + + book + books + + + chapter + chapters + + + column + columns + + + figure + figures + + + folio + folios + + + number + numbers + + + line + lines + + + note + notes + + + opus + opera + + + page + pages + + + page + pages + + + paragraph + paragraphs + + + part + parts + + + section + sections + + + sub verbo + sub verbis + + + verse + verses + + + volume + volumes + + + + + bk. + bks. + + + chap. + chaps. + + + col. + cols. + + + fig. + figs. + + + fol. + fols. + + + no. + nos. + + + l. + ll. + + + n. + nn. + + + op. + opp. + + + p. + pp. + + + p. + pp. + + + para. + paras. + + + pt. + pts. + + + sec. + secs. + + + s.v. + s.vv. + + + v. + vv. + + + vol. + vols. + + + + + ¶ + ¶¶ + + + § + §§ + + + + + director + directors + + + editor + editors + + + editor + editors + + + illustrator + illustrators + + + translator + translators + + + editor & translator + editors & translators + + + + + dir. + dirs. + + + ed. + eds. + + + ed. + eds. + + + ill. + ills. + + + tran. + trans. + + + ed. & tran. + eds. & trans. + + + + by + directed by + edited by + edited by + illustrated by + interview by + to + by + translated by + edited & translated by + + + dir. by + ed. by + ed. by + illus. by + trans. by + ed. & trans. by + + + January + February + March + April + May + June + July + August + September + October + November + December + + + Jan. + Feb. + Mar. + Apr. + May + Jun. + Jul. + Aug. + Sep. + Oct. + Nov. + Dec. + + + Spring + Summer + Autumn + Winter + + diff --git a/lisp/org/ob-gnuplot.el b/lisp/org/ob-gnuplot.el index 3c84e4da14f..8c4a5957b99 100644 --- a/lisp/org/ob-gnuplot.el +++ b/lisp/org/ob-gnuplot.el @@ -290,7 +290,7 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE." (orgtbl-to-generic table (org-combine-plists - '(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field) + '(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field :raw t :backend ascii) params))))) data-file) diff --git a/lisp/org/ob-julia.el b/lisp/org/ob-julia.el index 434b414b614..4fae0d142b2 100644 --- a/lisp/org/ob-julia.el +++ b/lisp/org/ob-julia.el @@ -90,18 +90,13 @@ This function is called by `org-babel-execute-src-block'." (graphics-file (and (member "graphics" (assq :result-params params)) (org-babel-graphical-output-file params))) (colnames-p (unless graphics-file (cdr (assq :colnames params)))) - ;; (rownames-p (unless graphics-file (cdr (assq :rownames params)))) (full-body (org-babel-expand-body:julia body params graphics-file)) (result (org-babel-julia-evaluate session full-body result-type result-params (or (equal "yes" colnames-p) (org-babel-pick-name - (cdr (assq :colname-names params)) colnames-p)) - ;; (or (equal "yes" rownames-p) - ;; (org-babel-pick-name - ;; (cdr (assq :rowname-names params)) rownames-p)) - ))) + (cdr (assq :colname-names params)) colnames-p))))) (if graphics-file nil result)))) (defun org-babel-normalize-newline (result) @@ -135,12 +130,7 @@ This function is called by `org-babel-execute-src-block'." "Return list of julia statements assigning the block's variables." (let ((vars (org-babel--get-vars params))) (mapcar - (lambda (pair) - (org-babel-julia-assign-elisp - (car pair) (cdr pair) - ;; (equal "yes" (cdr (assq :colnames params))) - ;; (equal "yes" (cdr (assq :rownames params))) - )) + (lambda (pair) (org-babel-julia-assign-elisp (car pair) (cdr pair))) (mapcar (lambda (i) (cons (car (nth i vars)) @@ -156,7 +146,7 @@ This function is called by `org-babel-execute-src-block'." (concat "\"" (mapconcat #'identity (split-string s "\"") "\"\"") "\"") (format "%S" s))) -(defun org-babel-julia-assign-elisp (name value) ;; colnames-p rownames-p +(defun org-babel-julia-assign-elisp (name value) "Construct julia code assigning the elisp VALUE to a variable named NAME." (if (listp value) (let* ((lengths (mapcar #'length (cl-remove-if-not #'sequencep value))) @@ -164,11 +154,7 @@ This function is called by `org-babel-execute-src-block'." (min (if lengths (apply #'min lengths) 0))) ;; Ensure VALUE has an orgtbl structure (depth of at least 2). (unless (listp (car value)) (setq value (list value))) - (let ((file (orgtbl-to-csv value '(:fmt org-babel-julia-quote-csv-field))) - ;; (header (if (or (eq (nth 1 value) 'hline) colnames-p) - ;; "TRUE" "FALSE")) - ;; (row-names (if rownames-p "1" "NULL")) - ) + (let ((file (orgtbl-to-csv value '(:fmt org-babel-julia-quote-csv-field)))) (if (= max min) (format "%s = begin using CSV @@ -188,7 +174,7 @@ end" (let ((session (or session "*Julia*")) (ess-ask-for-ess-directory (and (bound-and-true-p ess-ask-for-ess-directory) - (not (cdr (assq :dir params)))))) + (not (cdr (assq :dir params)))))) (if (org-babel-comint-buffer-livep session) session ;; FIXME: Depending on `display-buffer-alist', (julia) may end up @@ -209,14 +195,6 @@ end" (buffer-name)))) (current-buffer)))))) - ; (defun org-babel-julia-associate-session (session) - ; "Associate julia code buffer with a julia session. - ; Make SESSION be the inferior ESS process associated with the - ; current code buffer." - ; (setq ess-local-process-name - ; (process-name (get-buffer-process session))) - ; (ess-make-buffer-current)) - (defun org-babel-julia-graphical-output-file (params) "Name of file to which julia should send graphical output." (and (member "graphics" (cdr (assq :result-params params))) @@ -259,16 +237,16 @@ end" end") (defun org-babel-julia-evaluate - (session body result-type result-params column-names-p) ;; row-names-p + (session body result-type result-params column-names-p) "Evaluate julia code in BODY." (if session (org-babel-julia-evaluate-session - session body result-type result-params column-names-p) ;; row-names-p + session body result-type result-params column-names-p) (org-babel-julia-evaluate-external-process - body result-type result-params column-names-p))) ;; row-names-p + body result-type result-params column-names-p))) (defun org-babel-julia-evaluate-external-process - (body result-type result-params column-names-p) ;; row-names-p + (body result-type result-params column-names-p) "Evaluate BODY in external julia process. If RESULT-TYPE equals 'output then return standard output as a string. If RESULT-TYPE equals 'value then return the value of the @@ -292,7 +270,7 @@ last statement in BODY, as elisp." (output (org-babel-eval org-babel-julia-command body)))) (defun org-babel-julia-evaluate-session - (session body result-type result-params column-names-p) ;; row-names-p + (session body result-type result-params column-names-p) "Evaluate BODY in SESSION. If RESULT-TYPE equals 'output then return standard output as a string. If RESULT-TYPE equals 'value then return the value of the diff --git a/lisp/org/oc-csl.el b/lisp/org/oc-csl.el index b847fbbc4f6..3d138807592 100644 --- a/lisp/org/oc-csl.el +++ b/lisp/org/oc-csl.el @@ -186,15 +186,21 @@ Used only when `second-field-align' is activated by the used CSL style." ;;; Internal variables (defconst org-cite-csl--etc-dir - (let* ((oc-root (file-name-directory (locate-library "oc"))) - (oc-etc-dir-1 (expand-file-name "../etc/csl/" oc-root))) - ;; package.el and straight will put all of org-mode/lisp/ in org-mode/. - ;; This will cause .. to resolve to the directory above Org. - ;; To make life easier for people using package.el or straight, we can - ;; check to see if ../etc/csl exists, and if it doesn't try ./etc/csl. - (if (file-exists-p oc-etc-dir-1) oc-etc-dir-1 - (expand-file-name "etc/csl/" oc-root))) - "Directory \"etc/\" from repository.") + (let ((oc-root (file-name-directory (locate-library "oc")))) + (cond + ;; First check whether it looks like we're running from the main + ;; Org repository. + ((let ((csl-org (expand-file-name "../etc/csl/" oc-root))) + (and (file-directory-p csl-org) csl-org))) + ;; Next look for the directory alongside oc.el because package.el + ;; and straight will put all of org-mode/lisp/ in org-mode/. + ((let ((csl-pkg (expand-file-name "etc/csl/" oc-root))) + (and (file-directory-p csl-pkg) csl-pkg))) + ;; Finally fall back the location used by shared system installs + ;; and when running directly from Emacs repository. + (t + (expand-file-name "org/csl/" data-directory)))) + "Directory containing CSL-related data files.") (defconst org-cite-csl--fallback-locales-dir org-cite-csl--etc-dir "Fallback CSL locale files directory.") diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el index a8fb79ea3cd..0779c3a82c8 100644 --- a/lisp/org/org-macs.el +++ b/lisp/org/org-macs.el @@ -326,17 +326,19 @@ it for output." ;;; Indentation -(defun org-do-remove-indentation (&optional n) +(defun org-do-remove-indentation (&optional n skip-fl) "Remove the maximum common indentation from the buffer. When optional argument N is a positive integer, remove exactly -that much characters from indentation, if possible. Return nil -if it fails." +that much characters from indentation, if possible. When +optional argument SKIP-FL is non-nil, skip the first +line. Return nil if it fails." (catch :exit (goto-char (point-min)) ;; Find maximum common indentation, if not specified. (let ((n (or n (let ((min-ind (point-max))) (save-excursion + (when skip-fl (forward-line)) (while (re-search-forward "^[ \t]*\\S-" nil t) (let ((ind (current-indentation))) (if (zerop ind) (throw :exit nil) @@ -344,6 +346,7 @@ if it fails." min-ind)))) (if (zerop n) (throw :exit nil) ;; Remove exactly N indentation, but give up if not possible. + (when skip-fl (forward-line)) (while (not (eobp)) (let ((ind (progn (skip-chars-forward " \t") (current-column)))) (cond ((eolp) (delete-region (line-beginning-position) (point))) diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index 91a3d415dfa..8d02cf43450 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -38,6 +38,7 @@ (require 'org-keys) (declare-function org-mode "org" ()) +(declare-function org--get-expected-indentation "org" (element contentsp)) (declare-function org-element-at-point "org-element" ()) (declare-function org-element-class "org-element" (datum &optional parent)) (declare-function org-element-context "org-element" (&optional element)) @@ -327,7 +328,8 @@ a cons cell (LINE . COLUMN) or symbol `end'. See also (if (>= pos end) 'end (org-with-wide-buffer (goto-char (max beg pos)) - (cons (count-lines beg (line-beginning-position)) + (cons (count-lines (save-excursion (goto-char beg) (line-beginning-position)) + (line-beginning-position)) ;; Column is relative to the end of line to avoid problems of ;; comma escaping or colons appended in front of the line. (- (point) (min end (line-end-position))))))) @@ -445,6 +447,7 @@ Assume point is in the corresponding edit buffer." org-src--content-indentation 0)))) (use-tabs? (and (> org-src--tab-width 0) t)) + (preserve-fl (eq org-src--source-type 'latex-fragment)) (source-tab-width org-src--tab-width) (contents (org-with-wide-buffer (let ((eol (line-end-position))) @@ -466,7 +469,8 @@ Assume point is in the corresponding edit buffer." ;; Add INDENTATION-OFFSET to every line in buffer, ;; unless indentation is meant to be preserved. (when (> indentation-offset 0) - (while (not (eobp)) + (when preserve-fl (forward-line)) + (while (not (eobp)) (skip-chars-forward " \t") (when (or (not (eolp)) ; not a blank line (and (eq (point) (marker-position marker)) ; current line @@ -518,7 +522,13 @@ Leave point in edit buffer." (source-tab-width (if indent-tabs-mode tab-width 0)) (type (org-element-type datum)) (block-ind (org-with-point-at (org-element-property :begin datum) - (current-indentation))) + (cond + ((save-excursion (skip-chars-backward " \t") (bolp)) + (current-indentation)) + ((org-element-property :parent datum) + (org--get-expected-indentation + (org-element-property :parent datum) nil)) + (t (current-indentation))))) (content-ind org-edit-src-content-indentation) (blank-line (save-excursion (beginning-of-line) (looking-at-p "^[[:space:]]*$"))) @@ -548,7 +558,8 @@ Leave point in edit buffer." (insert contents) (remove-text-properties (point-min) (point-max) '(display nil invisible nil intangible nil)) - (unless preserve-ind (org-do-remove-indentation)) + (let ((lf (eq type 'latex-fragment))) + (unless preserve-ind (org-do-remove-indentation (and lf block-ind) lf))) (set-buffer-modified-p nil) (setq buffer-file-name nil) ;; Initialize buffer. diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index ef363dc3901..5bccbe497cc 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")) + (let ((org-git-version "release_9.5-30-g10dc9d")) org-git-version)) (provide 'org-version) diff --git a/lisp/org/org.el b/lisp/org/org.el index 723de649429..bc0ea24bee7 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -5113,6 +5113,7 @@ stacked delimiters is N. Escaping delimiters is not possible." '(invisible t)) (add-text-properties (match-beginning 3) (match-end 3) '(invisible t))) + (goto-char (match-end 0)) (throw :exit t)))))))) (defun org-emphasize (&optional char) -- 2.39.5