Browse Source

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'.
Stefan Kangas 3 years ago
parent
commit
0ed0dea229
12 changed files with 16 additions and 81 deletions
  1. 1 1
      lisp/org-clock.el
  2. 2 36
      lisp/org-compat.el
  3. 2 20
      lisp/org-fold-core.el
  4. 1 1
      lisp/org-goto.el
  5. 0 13
      lisp/org-macs.el
  6. 1 1
      lisp/org-src.el
  7. 3 3
      lisp/org-table.el
  8. 2 2
      lisp/org.el
  9. 1 1
      lisp/ox-html.el
  10. 1 1
      lisp/ox-odt.el
  11. 1 1
      lisp/ox-org.el
  12. 1 1
      lisp/ox.el

+ 1 - 1
lisp/org-clock.el

@@ -2122,7 +2122,7 @@ fontified, and then returned."
     (org-mode)
     (org-mode)
     (org-create-dblock props)
     (org-create-dblock props)
     (org-update-dblock)
     (org-update-dblock)
-    (org-font-lock-ensure)
+    (font-lock-ensure)
     (forward-line 2)
     (forward-line 2)
     (buffer-substring (point) (progn
     (buffer-substring (point) (progn
 				(re-search-forward "^[ \t]*#\\+END" nil t)
 				(re-search-forward "^[ \t]*#\\+END" nil t)

+ 2 - 36
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))
         ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
          (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
 ;;; Region compatibility
 
 
@@ -961,13 +955,6 @@ Pass COLUMN and FORCE to `move-to-column'."
                           string)
                           string)
   (apply 'kill-new string args))
   (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.
 ;; `file-local-name' was added in Emacs 26.1.
 (defalias 'org-babel-local-file-name
 (defalias 'org-babel-local-file-name
   (if (fboundp 'file-local-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-release () "N/A")
            (defun org-git-version () "N/A !!check installation!!"))))))
            (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
 ;;; Integration with and fixes for other packages

+ 2 - 20
lisp/org-fold-core.el

@@ -1304,25 +1304,7 @@ property, unfold the region if the :fragile function returns non-nil."
                    ;; Move to next fold.
                    ;; Move to next fold.
                    (setq pos (org-fold-core-next-folding-state-change spec pos local-to))))))))))))
                    (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
 ;; By default, all the text properties of the killed text are
 ;; preserved, including the folding text properties.  This can be
 ;; 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.
                  ;; Yes, it is a hack.
                  ;; The below gives us string representation as a list.
                  ;; The below gives us string representation as a list.
                  ;; Note that we need to remove unreadable values, like markers (#<...>).
                  ;; 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
                   (cdr (let ((data (read (replace-regexp-in-string
                                           "^#(" "("
                                           "^#(" "("
                                           (replace-regexp-in-string
                                           (replace-regexp-in-string

+ 1 - 1
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)
     (when (eq (lookup-key isearch-mode-map keys) 'isearch-printing-char)
       (isearch-mode t)
       (isearch-mode t)
       (isearch-process-search-char (string-to-char keys))
       (isearch-process-search-char (string-to-char keys))
-      (org-font-lock-ensure))))
+      (font-lock-ensure))))
 
 
 (defun org-goto-ret (&optional _arg)
 (defun org-goto-ret (&optional _arg)
   "Finish `org-goto' by going to the new location."
   "Finish `org-goto' by going to the new location."

+ 0 - 13
lisp/org-macs.el

@@ -70,19 +70,6 @@
 	     ,@body)
 	     ,@body)
 	 (set-buffer-modified-p ,was-modified)))))
 	 (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)
 (defmacro org-with-point-at (pom &rest body)
   "Move to buffer and point of point-or-marker POM for the duration of BODY."
   "Move to buffer and point of point-or-marker POM for the duration of BODY."
   (declare (debug (form body)) (indent 1))
   (declare (debug (form body)) (indent 1))

+ 1 - 1
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.
 	    ;; Add string and a final space to ensure property change.
 	    (insert string " "))
 	    (insert string " "))
 	  (unless (eq major-mode lang-mode) (funcall lang-mode))
 	  (unless (eq major-mode lang-mode) (funcall lang-mode))
-	  (org-font-lock-ensure)
+          (font-lock-ensure)
 	  (let ((pos (point-min)) next)
 	  (let ((pos (point-min)) next)
 	    (while (setq next (next-property-change pos))
 	    (while (setq next (next-property-change pos))
 	      ;; Handle additional properties from font-lock, so as to
 	      ;; Handle additional properties from font-lock, so as to

+ 3 - 3
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
 respectively, the beginning position and the end position of the
 table."
 table."
   (org-with-wide-buffer
   (org-with-wide-buffer
-   (org-font-lock-ensure beg end)
+   (font-lock-ensure beg end)
    (dolist (c columns)
    (dolist (c columns)
      (goto-char beg)
      (goto-char beg)
      (let ((align nil)
      (let ((align nil)
@@ -4201,7 +4201,7 @@ beginning and end position of the current table."
      (org-table-expand begin end)
      (org-table-expand begin end)
      ;; Make sure invisible characters in the table are at the right
      ;; Make sure invisible characters in the table are at the right
      ;; place since column widths take them into account.
      ;; 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))))
      (org-table--shrink-columns (sort columns #'<) begin end))))
 
 
 ;;;###autoload
 ;;;###autoload
@@ -4333,7 +4333,7 @@ FIELD is a string.  WIDTH is a number.  ALIGN is either \"c\",
     (org-table-save-field
     (org-table-save-field
      ;; Make sure invisible characters in the table are at the right
      ;; Make sure invisible characters in the table are at the right
      ;; place since column widths take them into account.
      ;; 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-begin-marker beg)
      (move-marker org-table-aligned-end-marker end)
      (move-marker org-table-aligned-end-marker end)
      (goto-char beg)
      (goto-char beg)

+ 2 - 2
lisp/org.el

@@ -5749,7 +5749,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
     (insert s)
     (insert s)
     (let ((org-odd-levels-only odd-levels))
     (let ((org-odd-levels-only odd-levels))
       (org-mode)
       (org-mode)
-      (org-font-lock-ensure)
+      (font-lock-ensure)
       (if org-link-descriptive
       (if org-link-descriptive
           (org-link-display-format
           (org-link-display-format
            (buffer-string))
            (buffer-string))
@@ -14127,7 +14127,7 @@ days in order to avoid rounding problems."
   "Convert a timestamp string S into a number of seconds."
   "Convert a timestamp string S into a number of seconds."
   (float-time (org-time-string-to-time s)))
   (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)
 (defun org-time-string-to-absolute (s &optional daynr prefer buffer pos)
   "Convert time stamp S to an absolute day number.
   "Convert time stamp S to an absolute day number.

+ 1 - 1
lisp/ox-html.el

@@ -2223,7 +2223,7 @@ is the language used for CODE, as a string, or nil."
 		    (funcall lang-mode)
 		    (funcall lang-mode)
 		    (insert code)
 		    (insert code)
 		    ;; Fontify buffer.
 		    ;; Fontify buffer.
-		    (org-font-lock-ensure)
+                    (font-lock-ensure)
 		    ;; Remove formatting on newline characters.
 		    ;; Remove formatting on newline characters.
 		    (save-excursion
 		    (save-excursion
 		      (let ((beg (point-min))
 		      (let ((beg (point-min))

+ 1 - 1
lisp/ox-odt.el

@@ -3087,7 +3087,7 @@ and prefix with \"OrgSrc\".  For example,
 		 (with-temp-buffer
 		 (with-temp-buffer
 		   (insert code)
 		   (insert code)
 		   (funcall lang-mode)
 		   (funcall lang-mode)
-		   (org-font-lock-ensure)
+                   (font-lock-ensure)
 		   (buffer-string))))
 		   (buffer-string))))
 	 (fontifier (if use-htmlfontify-p 'org-odt-htmlfontify-string
 	 (fontifier (if use-htmlfontify-p 'org-odt-htmlfontify-string
 		      'org-odt--encode-plain-text))
 		      'org-odt--encode-plain-text))

+ 1 - 1
lisp/ox-org.el

@@ -328,7 +328,7 @@ Return output file name."
 	   (work-buffer (or visitingp (find-file-noselect filename)))
 	   (work-buffer (or visitingp (find-file-noselect filename)))
 	   newbuf)
 	   newbuf)
       (with-current-buffer work-buffer
       (with-current-buffer work-buffer
-        (org-font-lock-ensure)
+        (font-lock-ensure)
         (org-fold-show-all)
         (org-fold-show-all)
         (setq newbuf (htmlize-buffer)))
         (setq newbuf (htmlize-buffer)))
       (with-current-buffer newbuf
       (with-current-buffer newbuf

+ 1 - 1
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-data' for further processing, depending on
 ;; `org-export-with-broken-links' value.
 ;; `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)
 (defun org-export-custom-protocol-maybe (link desc backend &optional info)
   "Try exporting LINK object with a dedicated function.
   "Try exporting LINK object with a dedicated function.