From f05b8a939b7ad57e9526510d510ff24484dcb520 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 6 Nov 2021 14:10:47 -0400 Subject: [PATCH 1/6] Update to Org 9.5-68-g77e2ec --- lisp/org/oc-basic.el | 58 +++++++++++++++++++++++------------------ lisp/org/oc-csl.el | 18 ++++++++----- lisp/org/oc-natbib.el | 6 +---- lisp/org/oc.el | 22 +++++++++++++++- lisp/org/org-macro.el | 2 +- lisp/org/org-version.el | 2 +- 6 files changed, 68 insertions(+), 40 deletions(-) diff --git a/lisp/org/oc-basic.el b/lisp/org/oc-basic.el index c51c7d301e4..7b09db5f8b4 100644 --- a/lisp/org/oc-basic.el +++ b/lisp/org/oc-basic.el @@ -325,15 +325,19 @@ This is used for disambiguation." ((= n 27) (throw :complete (cons 0 (cons 0 result)))) (t nil)))))))) -(defun org-cite-basic--get-year (entry-or-key info) +(defun org-cite-basic--get-year (entry-or-key info &optional no-suffix) "Return year associated to ENTRY-OR-KEY. ENTRY-OR-KEY is either an association list, as returned by -`org-cite-basic--get-entry', or a string representing a citation key. INFO is -the export state, as a property list. +`org-cite-basic--get-entry', or a string representing a citation +key. INFO is the export state, as a property list. -Unlike `org-cite-basic--get-field', this function disambiguates author-year -patterns." +Year is obtained from the \"year\" field, if available, or from +the \"date\" field if it starts with a year pattern. + +Unlike `org-cite-basic--get-field', this function disambiguates +author-year patterns by adding a letter suffix to the year when +necessary, unless optional argument NO-SUFFIX is non-nil." ;; The cache is an association list with the following structure: ;; ;; (AUTHOR-YEAR . KEY-SUFFIX-ALIST). @@ -345,7 +349,16 @@ patterns." ;; the cite key, as a string, and SUFFIX is the generated suffix ;; string, or the empty string. (let* ((author (org-cite-basic--get-field 'author entry-or-key info 'raw)) - (year (org-cite-basic--get-field 'year entry-or-key info 'raw)) + (year + (or (org-cite-basic--get-field 'year entry-or-key info 'raw) + (let ((date + (org-cite-basic--get-field 'date entry-or-key info t))) + (and (stringp date) + (string-match (rx string-start + (group (= 4 digit)) + (or string-end (not digit))) + date) + (match-string 1 date))))) (cache-key (cons author year)) (key (pcase entry-or-key @@ -359,11 +372,13 @@ patterns." (plist-put info :cite-basic/author-date-cache (cons value cache)) year)) (`(,_ . ,alist) - (concat year - (or (cdr (assoc key alist)) - (let ((new (org-cite-basic--number-to-suffix (1- (length alist))))) - (push (cons key new) alist) - new))))))) + (let ((suffix + (or (cdr (assoc key alist)) + (let ((new (org-cite-basic--number-to-suffix + (1- (length alist))))) + (push (cons key new) alist) + new)))) + (if no-suffix year (concat year suffix))))))) (defun org-cite-basic--print-entry (entry style &optional info) "Format ENTRY according to STYLE string. @@ -371,7 +386,6 @@ ENTRY is an alist, as returned by `org-cite-basic--get-entry'. Optional argument INFO is the export state, as a property list." (let ((author (org-cite-basic--get-field 'author entry info)) (title (org-cite-basic--get-field 'title entry info)) - (year (org-cite-basic--get-field 'year entry info)) (from (or (org-cite-basic--get-field 'publisher entry info) (org-cite-basic--get-field 'journal entry info) @@ -379,10 +393,12 @@ Optional argument INFO is the export state, as a property list." (org-cite-basic--get-field 'school entry info)))) (pcase style ("plain" - (org-cite-concat - author ". " title (and from (list ", " from)) ", " year ".")) + (let ((year (org-cite-basic--get-year entry info 'no-suffix))) + (org-cite-concat + author ". " title (and from (list ", " from)) ", " year "."))) ("numeric" - (let ((n (org-cite-basic--key-number (cdr (assq 'id entry)) info))) + (let ((n (org-cite-basic--key-number (cdr (assq 'id entry)) info)) + (year (org-cite-basic--get-year entry info 'no-suffix))) (org-cite-concat (format "[%d] " n) author ", " (org-cite-emphasize 'italic title) @@ -603,15 +619,7 @@ export communication channel, as a property list." ;; When using this style on citations with multiple references, ;; use global affixes and ignore local ones. (`(,(or "numeric" "nb") . ,_) - (let* ((references (org-cite-get-references citation)) - (prefix - (or (org-element-property :prefix citation) - (and (= 1 (length references)) - (org-element-property :prefix (car references))))) - (suffix - (or (org-element-property :suffix citation) - (and (= 1 (length references)) - (org-element-property :suffix (car references)))))) + (pcase-let ((`(,prefix . ,suffix) (org-cite-main-affixes citation))) (org-export-data (org-cite-concat "(" prefix (org-cite-basic--citation-numbers citation info) suffix ")") @@ -712,7 +720,7 @@ reference. Values are the cite key." org-cite-basic-author-column-end nil ?\s) (make-string org-cite-basic-author-column-end ?\s))) org-cite-basic-column-separator - (let ((date (org-cite-basic--get-field 'year key nil t))) + (let ((date (org-cite-basic--get-year key nil 'no-suffix))) (format "%4s" (or date ""))) org-cite-basic-column-separator (org-cite-basic--get-field 'title key nil t)))) diff --git a/lisp/org/oc-csl.el b/lisp/org/oc-csl.el index 94de97e33a1..7cd63c3ff3a 100644 --- a/lisp/org/oc-csl.el +++ b/lisp/org/oc-csl.el @@ -487,21 +487,25 @@ INFO is the export state, as a property list." (let ((global-prefix (org-element-property :prefix citation))) (when global-prefix (let* ((first (car cites)) - (prefix (org-element-property :prefix first))) - (org-element-put-property - first :prefix (org-cite-concat global-prefix prefix))))) + (prefix-item (assq 'prefix first))) + (setcdr prefix-item + (concat (org-element-interpret-data global-prefix) + " " + (cdr prefix-item)))))) ;; Global suffix is appended to the suffix of the last reference. (let ((global-suffix (org-element-property :suffix citation))) (when global-suffix (let* ((last (org-last cites)) - (suffix (org-element-property :suffix last))) - (org-element-put-property - last :suffix (org-cite-concat suffix global-suffix))))) + (suffix-item (assq 'suffix last))) + (setcdr suffix-item + (concat (cdr suffix-item) + " " + (org-element-interpret-data global-suffix)))))) ;; Check if CITATION needs wrapping, i.e., it should be wrapped in ;; a footnote, but isn't yet. (when (and (not footnote) (org-cite-csl--note-style-p info)) (org-cite-adjust-note citation info) - (org-cite-wrap-citation citation info)) + (setq footnote (org-cite-wrap-citation citation info))) ;; Return structure. (apply #'citeproc-citation-create `(:note-index diff --git a/lisp/org/oc-natbib.el b/lisp/org/oc-natbib.el index 13cac9ed0b9..bf086f36dff 100644 --- a/lisp/org/oc-natbib.el +++ b/lisp/org/oc-natbib.el @@ -119,11 +119,7 @@ If \"natbib\" package is already required in the document, e.g., through (defun org-cite-natbib--build-optional-arguments (citation info) "Build optional arguments for citation command. CITATION is the citation object. INFO is the export state, as a property list." - (let* ((origin (pcase (org-cite-get-references citation) - (`(,reference) reference) - (_ citation))) - (suffix (org-element-property :suffix origin)) - (prefix (org-element-property :prefix origin))) + (pcase-let ((`(,prefix . ,suffix) (org-cite-main-affixes citation))) (concat (and prefix (format "[%s]" (org-trim (org-export-data prefix info)))) (cond (suffix (format "[%s]" (org-trim (org-export-data suffix info)))) diff --git a/lisp/org/oc.el b/lisp/org/oc.el index dcda8d7d084..41fd688c060 100644 --- a/lisp/org/oc.el +++ b/lisp/org/oc.el @@ -638,6 +638,24 @@ in the current buffer. Positions include leading \"@\" character." (re-search-forward org-element-citation-key-re end t) (cons (match-beginning 0) (match-end 0))))) +(defun org-cite-main-affixes (citation) + "Return main affixes for CITATION object. + +Some export back-ends only support a single pair of affixes per +citation, even if it contains multiple keys. This function +decides what affixes are the most appropriate. + +Return a pair (PREFIX . SUFFIX) where PREFIX and SUFFIX are +parsed data." + (let ((source + ;; When there are multiple references, use global affixes. + ;; Otherwise, local affixes have priority. + (pcase (org-cite-get-references citation) + (`(,reference) reference) + (_ citation)))) + (cons (org-element-property :prefix source) + (org-element-property :suffix source)))) + (defun org-cite-supported-styles (&optional processors) "List of supported citation styles and variants. @@ -872,7 +890,9 @@ When non-nil, the return value if the footnote container." INFO is the export state, as a property list. White space before the citation, if any, are removed. The parse tree is -modified by side-effect." +modified by side-effect. + +Return newly created footnote object." (let ((footnote (list 'footnote-reference (list :label nil diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el index 1259430ae44..c38a07b69af 100644 --- a/lisp/org/org-macro.el +++ b/lisp/org/org-macro.el @@ -173,7 +173,7 @@ a file, \"input-file\" and \"modification-time\"." modtime)))))))) ;; Install generic macros. '(("keyword" . (lambda (arg1 &rest _) - (org-macro--find-keyword-value arg1))) + (org-macro--find-keyword-value arg1 t))) ("n" . (lambda (&optional arg1 arg2 &rest _) (org-macro--counter-increment arg1 arg2))) ("property" . (lambda (arg1 &optional arg2 &rest _) diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index 55f186b4712..6427f30072e 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-59-g52e6f1")) + (let ((org-git-version "release_9.5-68-g77e2ec")) org-git-version)) (provide 'org-version) From 6243a43ac2b575435efb65d9bdbb15980ea14d78 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 6 Nov 2021 19:25:42 +0100 Subject: [PATCH 2/6] Fix search string generation in nnimap-make-thread-query * lisp/gnus/nnimap.el (nnimap-make-thread-query): Remove text properties before constructing the search string (bug#49926). --- lisp/gnus/nnimap.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 059101c8907..6b627a4b756 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -2287,7 +2287,7 @@ Return the server's response to the SELECT or EXAMINE command." nnimap-incoming-split-list))) (defun nnimap-make-thread-query (header) - (let* ((id (mail-header-id header)) + (let* ((id (substring-no-properties (mail-header-id header))) (refs (split-string (or (mail-header-references header) ""))) From d85cf33e494f4e9ada2a9359247e88775e92e7c0 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 6 Nov 2021 20:59:28 +0100 Subject: [PATCH 3/6] Escape '%' in filenames to fix flymake warnings * lisp/progmodes/flymake.el (flymake--log-1): Escape '%' in filenames for 'warning-type-format' so they are not interpreted as a %-sequence by 'format' later. (Bug#51549) --- lisp/progmodes/flymake.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index bcb43c1faf1..403925c8557 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -266,7 +266,9 @@ If set to nil, don't suppress any zero counters." (warning-type-format (format " [%s %s]" (or sublog 'flymake) - (current-buffer)))) + ;; Handle file names with "%" correctly. (Bug#51549) + (string-replace "%" "%%" + (buffer-name (current-buffer)))))) (display-warning (list 'flymake sublog) (apply #'format-message msg args) (if (numberp level) From 54b726c81571551fe81f85ba3ec928b8358f2846 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 7 Nov 2021 09:34:30 +0200 Subject: [PATCH 4/6] ; * etc/PROBLEMS: More specific recipe for WebKit-related crashes. --- etc/PROBLEMS | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/PROBLEMS b/etc/PROBLEMS index bb5f3b76c1e..1f62146c1cf 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -184,7 +184,11 @@ This could happen if the version of WebKitGTK installed on your system is buggy, and errors out trying to start a subprocess through Bubblewrap sandboxing. You can avoid the crash by setting the environment variables SNAP, SNAP_NAME and SNAP_REVISION, which will -make WebKit use GLib to launch subprocesses instead. +make WebKit use GLib to launch subprocesses instead. For example, +invoke Emacs like this (where "..." stands for the command-line +arguments you need to pass to Emacs): + + $ SNAP=1 SNAP_NAME=1 SNAP_REVISION=1 emacs ... ** Emacs crashes when you try to view a file with complex characters. From 21de5e7b2e55d98aab9750abac6f70243fd1b61d Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 7 Nov 2021 17:02:46 +0200 Subject: [PATCH 5/6] Fix compilation MinGW warnings * src/w32.h (prepare_standard_handles, reset_standard_handles): Fix prototypes. Reported by Andy Moreton in https://lists.gnu.org/archive/html/emacs-devel/2021-11/msg00597.html. --- src/w32.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/w32.h b/src/w32.h index ffa145b1484..5aba0aed9a6 100644 --- a/src/w32.h +++ b/src/w32.h @@ -155,11 +155,11 @@ extern unsigned int w32_get_short_filename (const char *, char *, int); /* Prepare our standard handles for proper inheritance by child processes. */ extern void prepare_standard_handles (int in, int out, - int err, HANDLE handles[4]); + int err, HANDLE handles[3]); /* Reset our standard handles to their original state. */ extern void reset_standard_handles (int in, int out, - int err, HANDLE handles[4]); + int err, HANDLE handles[3]); /* Return the string resource associated with KEY of type TYPE. */ extern LPBYTE w32_get_resource (const char * key, LPDWORD type); From 7fdb2ae412d4b727c6075ff3988836841b052120 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 7 Nov 2021 18:03:23 +0100 Subject: [PATCH 6/6] Add some unit tests for 'abbreviate-file-name' * test/lisp/files-tests.el (files-tests-abbreviate-file-name-homedir) (files-tests-abbreviate-file-name-directory-abbrev-alist): New tests. --- test/lisp/files-tests.el | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index b283a512a42..9547ac2b695 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1342,6 +1342,39 @@ name (Bug#28412)." (should (file-directory-p (concat (file-name-as-directory dest2) "a"))) (delete-directory dir 'recursive))) +(ert-deftest files-tests-abbreviate-file-name-homedir () + ;; Check homedir abbreviation. + (let* ((homedir temporary-file-directory) + (process-environment (cons (format "HOME=%s" homedir) + process-environment)) + (abbreviated-home-dir nil)) + (should (equal "~/foo/bar" + (abbreviate-file-name (concat homedir "foo/bar"))))) + ;; Check that homedir abbreviation doesn't occur when homedir is just /. + (let* ((homedir "/") + (process-environment (cons (format "HOME=%s" homedir) + process-environment)) + (abbreviated-home-dir nil)) + (should (equal "/foo/bar" + (abbreviate-file-name (concat homedir "foo/bar")))))) + +(ert-deftest files-tests-abbreviate-file-name-directory-abbrev-alist () + ;; Check `directory-abbrev-alist' abbreviation. + (let ((directory-abbrev-alist '(("\\`/nowhere/special" . "/nw/sp")))) + (should (equal "/nw/sp/here" + (abbreviate-file-name "/nowhere/special/here")))) + ;; Check homedir and `directory-abbrev-alist' abbreviation. + (let* ((homedir temporary-file-directory) + (process-environment (cons (format "HOME=%s" homedir) + process-environment)) + (abbreviated-home-dir nil) + (directory-abbrev-alist + `((,(concat "\\`" (regexp-quote homedir) "nowhere/special") + . ,(concat homedir "nw/sp"))))) + (should (equal "~/nw/sp/here" + (abbreviate-file-name + (concat homedir "nowhere/special/here")))))) + (ert-deftest files-tests-abbreviated-home-dir () "Test that changing HOME does not confuse `abbreviate-file-name'. See ."