From aa0637c22ff1465a19d4007f1e9d16cc0df9972c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 30 Jun 2022 13:06:21 +0200 Subject: [PATCH] Delete some Emacs 24 compat code Org mode supports Emacs 26 or newer: https://orgmode.org/worg/org-maintenance.html#emacs-compatibility * lisp/org-compat.el (org-set-transient-map) (org-font-lock-ensure): Delete compat aliases. Update callers. (org-define-error): Redefine as obsolete function alias for `define-error'. Update callers. (string-suffix-p): Delete compatibility definition. * lisp/org-fold-core.el (org-fold-core--seq-partition): Delete private function and update callers to use `seq-partition'. * lisp/org-macs.el (org-without-partial-completion): Move from here... * lisp/org-compat.el (org-without-partial-completion): ...to here. Redefine as obsolete function alias for `progn'. --- lisp/org-clock.el | 2 +- lisp/org-compat.el | 38 ++------------------------------------ lisp/org-fold-core.el | 22 ++-------------------- lisp/org-goto.el | 2 +- lisp/org-macs.el | 13 ------------- lisp/org-src.el | 2 +- lisp/org-table.el | 6 +++--- lisp/org.el | 4 ++-- lisp/ox-html.el | 2 +- lisp/ox-odt.el | 2 +- lisp/ox-org.el | 2 +- lisp/ox.el | 2 +- 12 files changed, 16 insertions(+), 81 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 7d99e5087..e0b2d3ce6 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2122,7 +2122,7 @@ fontified, and then returned." (org-mode) (org-create-dblock props) (org-update-dblock) - (org-font-lock-ensure) + (font-lock-ensure) (forward-line 2) (buffer-substring (point) (progn (re-search-forward "^[ \t]*#\\+END" nil t) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 10c125a2c..d8104e7e7 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -904,12 +904,6 @@ context. See the individual commands for more information." ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data)) (w32-get-clipboard-data)))) -;; `set-transient-map' is only in Emacs >= 24.4 -(defalias 'org-set-transient-map - (if (fboundp 'set-transient-map) - 'set-transient-map - 'set-temporary-overlay-map)) - ;;; Region compatibility @@ -961,13 +955,6 @@ Pass COLUMN and FORCE to `move-to-column'." string) (apply 'kill-new string args)) -;; `font-lock-ensure' is only available from 24.4.50 on -(defalias 'org-font-lock-ensure - (if (fboundp 'font-lock-ensure) - #'font-lock-ensure - (lambda (&optional _beg _end) - (with-no-warnings (font-lock-fontify-buffer))))) - ;; `file-local-name' was added in Emacs 26.1. (defalias 'org-babel-local-file-name (if (fboundp 'file-local-name) @@ -994,29 +981,8 @@ Pass COLUMN and FORCE to `move-to-column'." (defun org-release () "N/A") (defun org-git-version () "N/A !!check installation!!")))))) - - -;;; Functions for Emacs < 24.4 compatibility - -(defun org-define-error (name message) - "Define NAME as a new error signal. -MESSAGE is a string that will be output to the echo area if such -an error is signaled without being caught by a `condition-case'. -Implements `define-error' for older emacsen." - (if (fboundp 'define-error) (define-error name message) - (put name 'error-conditions - (copy-sequence (cons name (get 'error 'error-conditions)))))) - -(unless (fboundp 'string-suffix-p) - ;; From Emacs subr.el. - (defun string-suffix-p (suffix string &optional ignore-case) - "Return non-nil if SUFFIX is a suffix of STRING. -If IGNORE-CASE is non-nil, the comparison is done without paying -attention to case differences." - (let ((start-pos (- (length string) (length suffix)))) - (and (>= start-pos 0) - (eq t (compare-strings suffix nil nil - string start-pos nil ignore-case)))))) +(define-obsolete-function-alias 'org-define-error #'define-error "9.6") +(define-obsolete-function-alias 'org-without-partial-completion 'progn "9.6") ;;; Integration with and fixes for other packages diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index 88072852d..68a777de9 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -1304,25 +1304,7 @@ property, unfold the region if the :fragile function returns non-nil." ;; Move to next fold. (setq pos (org-fold-core-next-folding-state-change spec pos local-to)))))))))))) -;;; Hanlding killing/yanking of folded text - -;; Backward compatibility with Emacs 24. -(defun org-fold-core--seq-partition (list n) - "Return list of elements of LIST grouped into sub-sequences of length N. -The last list may contain less than N elements. If N is a -negative integer or 0, nil is returned." - (if (fboundp 'seq-partition) - (seq-partition list n) - (unless (< n 1) - (let ((result '())) - (while list - (let (part) - (dotimes (_ n) - (when list (push (car list) part))) - (push part result)) - (dotimes (_ n) - (setq list (cdr list)))) - (nreverse result))))) +;;; Handling killing/yanking of folded text ;; By default, all the text properties of the killed text are ;; preserved, including the folding text properties. This can be @@ -1386,7 +1368,7 @@ The arguments and return value are as specified for `filter-buffer-substring'." ;; Yes, it is a hack. ;; The below gives us string representation as a list. ;; Note that we need to remove unreadable values, like markers (#<...>). - (org-fold-core--seq-partition + (seq-partition (cdr (let ((data (read (replace-regexp-in-string "^#(" "(" (replace-regexp-in-string diff --git a/lisp/org-goto.el b/lisp/org-goto.el index 6162b7dde..4eb361558 100644 --- a/lisp/org-goto.el +++ b/lisp/org-goto.el @@ -155,7 +155,7 @@ When nil, you can use these keybindings to navigate the buffer: (when (eq (lookup-key isearch-mode-map keys) 'isearch-printing-char) (isearch-mode t) (isearch-process-search-char (string-to-char keys)) - (org-font-lock-ensure)))) + (font-lock-ensure)))) (defun org-goto-ret (&optional _arg) "Finish `org-goto' by going to the new location." diff --git a/lisp/org-macs.el b/lisp/org-macs.el index da68d8b8f..e46e025d2 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -70,19 +70,6 @@ ,@body) (set-buffer-modified-p ,was-modified))))) -;; FIXME: `partial-completion-mode' is obsolete since Emacs 24.1. -(defmacro org-without-partial-completion (&rest body) - (declare (debug (body))) - `(if (and (boundp 'partial-completion-mode) - partial-completion-mode - (fboundp 'partial-completion-mode)) - (unwind-protect - (progn - (partial-completion-mode -1) - ,@body) - (partial-completion-mode 1)) - ,@body)) - (defmacro org-with-point-at (pom &rest body) "Move to buffer and point of point-or-marker POM for the duration of BODY." (declare (debug (form body)) (indent 1)) diff --git a/lisp/org-src.el b/lisp/org-src.el index 58e5b252a..970663e6d 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -636,7 +636,7 @@ as `org-src-fontify-natively' is non-nil." ;; Add string and a final space to ensure property change. (insert string " ")) (unless (eq major-mode lang-mode) (funcall lang-mode)) - (org-font-lock-ensure) + (font-lock-ensure) (let ((pos (point-min)) next) (while (setq next (next-property-change pos)) ;; Handle additional properties from font-lock, so as to diff --git a/lisp/org-table.el b/lisp/org-table.el index 54e2df20b..e84c2090f 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -4079,7 +4079,7 @@ COLUMNS is a sorted list of column numbers. BEG and END are, respectively, the beginning position and the end position of the table." (org-with-wide-buffer - (org-font-lock-ensure beg end) + (font-lock-ensure beg end) (dolist (c columns) (goto-char beg) (let ((align nil) @@ -4201,7 +4201,7 @@ beginning and end position of the current table." (org-table-expand begin end) ;; Make sure invisible characters in the table are at the right ;; place since column widths take them into account. - (org-font-lock-ensure begin end) + (font-lock-ensure begin end) (org-table--shrink-columns (sort columns #'<) begin end)))) ;;;###autoload @@ -4333,7 +4333,7 @@ FIELD is a string. WIDTH is a number. ALIGN is either \"c\", (org-table-save-field ;; Make sure invisible characters in the table are at the right ;; place since column widths take them into account. - (org-font-lock-ensure beg end) + (font-lock-ensure beg end) (move-marker org-table-aligned-begin-marker beg) (move-marker org-table-aligned-end-marker end) (goto-char beg) diff --git a/lisp/org.el b/lisp/org.el index 8b090ac0b..3bba06d18 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5751,7 +5751,7 @@ needs to be inserted at a specific position in the font-lock sequence.") (insert s) (let ((org-odd-levels-only odd-levels)) (org-mode) - (org-font-lock-ensure) + (font-lock-ensure) (if org-link-descriptive (org-link-display-format (buffer-string)) @@ -14129,7 +14129,7 @@ days in order to avoid rounding problems." "Convert a timestamp string S into a number of seconds." (float-time (org-time-string-to-time s))) -(org-define-error 'org-diary-sexp-no-match "Unable to match diary sexp") +(define-error 'org-diary-sexp-no-match "Unable to match diary sexp") (defun org-time-string-to-absolute (s &optional daynr prefer buffer pos) "Convert time stamp S to an absolute day number. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 66d1c5c60..1a239bb01 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2223,7 +2223,7 @@ is the language used for CODE, as a string, or nil." (funcall lang-mode) (insert code) ;; Fontify buffer. - (org-font-lock-ensure) + (font-lock-ensure) ;; Remove formatting on newline characters. (save-excursion (let ((beg (point-min)) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 5483c4504..7e4ae357e 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -3087,7 +3087,7 @@ and prefix with \"OrgSrc\". For example, (with-temp-buffer (insert code) (funcall lang-mode) - (org-font-lock-ensure) + (font-lock-ensure) (buffer-string)))) (fontifier (if use-htmlfontify-p 'org-odt-htmlfontify-string 'org-odt--encode-plain-text)) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index 96d22d178..011d37616 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -328,7 +328,7 @@ Return output file name." (work-buffer (or visitingp (find-file-noselect filename))) newbuf) (with-current-buffer work-buffer - (org-font-lock-ensure) + (font-lock-ensure) (org-fold-show-all) (setq newbuf (htmlize-buffer))) (with-current-buffer newbuf diff --git a/lisp/ox.el b/lisp/ox.el index c75357b97..8420db7fc 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -4151,7 +4151,7 @@ meant to be translated with `org-export-data' or alike." ;; `org-export-data' for further processing, depending on ;; `org-export-with-broken-links' value. -(org-define-error 'org-link-broken "Unable to resolve link; aborting") +(define-error 'org-link-broken "Unable to resolve link; aborting") (defun org-export-custom-protocol-maybe (link desc backend &optional info) "Try exporting LINK object with a dedicated function. -- 2.30.2