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'.
This commit is contained in:
Stefan Kangas 2022-06-30 13:06:21 +02:00 committed by Ihor Radchenko
parent 2d52741088
commit 0ed0dea229
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
12 changed files with 16 additions and 81 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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."

View File

@ -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))

View File

@ -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

View File

@ -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)

View File

@ -5749,7 +5749,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))
@ -14127,7 +14127,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.

View File

@ -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))

View File

@ -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))

View File

@ -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

View File

@ -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.