From f2e63d27ff88ecf65cdaa1325b00f52b5b46e864 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 30 Mar 2019 14:23:41 +0100 Subject: [PATCH] po-mode: Remove support for Emacs versions < 22. Emacs 22 is the oldest version still in use, see . * gettext-tools/emacs/po-compat.el: Remove conditional code for Emacs < 22. * gettext-tools/emacs/po-mode.el: Likewise. (po-rehighlight): Remove function. (po-check-all-pending-edits, po-check-for-pending-edit): Update. * gettext-tools/emacs/start-po.el: Update comment. --- gettext-tools/emacs/po-compat.el | 136 ++++++++++++------------------- gettext-tools/emacs/po-mode.el | 118 ++++----------------------- gettext-tools/emacs/start-po.el | 4 +- 3 files changed, 68 insertions(+), 190 deletions(-) diff --git a/gettext-tools/emacs/po-compat.el b/gettext-tools/emacs/po-compat.el index a50e4105f..438318e7f 100644 --- a/gettext-tools/emacs/po-compat.el +++ b/gettext-tools/emacs/po-compat.el @@ -36,35 +36,6 @@ ;;; Emacs portability matters. -;; Identify which Emacs variety is being used. -;; This file supports: -;; - GNU Emacs (version 20 and above) -> po-EMACS20 = t, -;; - GNU Emacs (version 19) -> no flag. -(eval-and-compile - (cond ((and (string-lessp "19" emacs-version) (featurep 'faces)) - (setq po-EMACS20 t)) - (t (setq po-EMACS20 nil)))) - -;; Handle missing 'with-temp-buffer' function. -(eval-and-compile - (if (fboundp 'with-temp-buffer) - (fset 'po-with-temp-buffer (symbol-function 'with-temp-buffer)) - - (defmacro po-with-temp-buffer (&rest forms) - "Create a temporary buffer, and evaluate FORMS there like 'progn'." - (let ((curr-buffer (make-symbol "curr-buffer")) - (temp-buffer (make-symbol "temp-buffer"))) - `(let ((,curr-buffer (current-buffer)) - (,temp-buffer (get-buffer-create - (generate-new-buffer-name " *po-temp*")))) - (unwind-protect - (progn - (set-buffer ,temp-buffer) - ,@forms) - (set-buffer ,curr-buffer) - (and (buffer-name ,temp-buffer) - (kill-buffer ,temp-buffer)))))))) - (defconst po-content-type-charset-alist '(; Note: Emacs 21 doesn't support all encodings, thus the missing entries. ("ASCII" . undecided) @@ -92,24 +63,24 @@ ;("ISO_8859-13" . ??) ;("ISO-8859-14" . ??) ;("ISO_8859-14" . ??) - ("ISO-8859-15" . iso-8859-15) ; requires Emacs 21 - ("ISO_8859-15" . iso-8859-15) ; requires Emacs 21 + ("ISO-8859-15" . iso-8859-15) + ("ISO_8859-15" . iso-8859-15) ("KOI8-R" . koi8-r) ;("KOI8-U" . ??) ;("KOI8-T" . ??) - ("CP437" . cp437) ; requires Emacs 20 - ("CP775" . cp775) ; requires Emacs 20 - ("CP850" . cp850) ; requires Emacs 20 - ("CP852" . cp852) ; requires Emacs 20 - ("CP855" . cp855) ; requires Emacs 20 + ("CP437" . cp437) + ("CP775" . cp775) + ("CP850" . cp850) + ("CP852" . cp852) + ("CP855" . cp855) ;("CP856" . ??) - ("CP857" . cp857) ; requires Emacs 20 - ("CP861" . cp861) ; requires Emacs 20 - ("CP862" . cp862) ; requires Emacs 20 - ("CP864" . cp864) ; requires Emacs 20 - ("CP865" . cp865) ; requires Emacs 20 - ("CP866" . cp866) ; requires Emacs 21 - ("CP869" . cp869) ; requires Emacs 20 + ("CP857" . cp857) + ("CP861" . cp861) + ("CP862" . cp862) + ("CP864" . cp864) + ("CP865" . cp865) + ("CP866" . cp866) + ("CP869" . cp869) ;("CP874" . ??) ;("CP922" . ??) ;("CP932" . ??) @@ -119,16 +90,15 @@ ;("CP1046" . ??) ;("CP1124" . ??) ;("CP1129" . ??) - ("CP1250" . cp1250) ; requires Emacs 20 - ("CP1251" . cp1251) ; requires Emacs 20 + ("CP1250" . cp1250) + ("CP1251" . cp1251) ("CP1252" . iso-8859-1) ; approximation - ("CP1253" . cp1253) ; requires Emacs 20 + ("CP1253" . cp1253) ("CP1254" . iso-8859-9) ; approximation ("CP1255" . iso-8859-8) ; approximation ;("CP1256" . ??) - ("CP1257" . cp1257) ; requires Emacs 20 - ("GB2312" . cn-gb-2312) ; also named 'gb2312' in Emacs 21 - ; also named 'euc-cn' in Emacs 20 or Emacs 21 + ("CP1257" . cp1257) + ("GB2312" . cn-gb-2312) ; also named 'gb2312' and 'euc-cn' ("EUC-JP" . euc-jp) ("EUC-KR" . euc-kr) ;("EUC-TW" . ??) @@ -138,10 +108,10 @@ ;("GB18030" . ??) ("SHIFT_JIS" . shift_jis) ;("JOHAB" . ??) - ("TIS-620" . tis-620) ; requires Emacs 20 or Emacs 21 - ("VISCII" . viscii) ; requires Emacs 20 or Emacs 21 + ("TIS-620" . tis-620) + ("VISCII" . viscii) ;("GEORGIAN-PS" . ??) - ("UTF-8" . utf-8) ; requires Mule-UCS in Emacs 20, or Emacs 21 + ("UTF-8" . utf-8) ) "How to convert a GNU libc/libiconv canonical charset name as seen in Content-Type into a Mule coding system.") @@ -178,45 +148,39 @@ Content-Type into a Mule coding system.") ;;;###autoload (autoload 'po-find-file-coding-system "po-compat") -(eval-and-compile - (if po-EMACS20 - (defun po-find-file-coding-system-guts (operation filename) - "\ +(defun po-find-file-coding-system-guts (operation filename) + "\ Return a Mule (DECODING . ENCODING) pair, according to PO file charset. Called through file-coding-system-alist, before the file is visited for real." - (and (eq operation 'insert-file-contents) - (file-exists-p filename) - (po-with-temp-buffer - (let* ((coding-system-for-read 'no-conversion) - (charset (or (po-find-charset filename) "ascii")) - (charset-upper (upcase charset)) - (charset-lower (downcase charset)) - (candidate - (cdr (assoc charset-upper po-content-type-charset-alist))) - (try-symbol (or candidate (intern-soft charset-lower))) - (try-string - (if try-symbol (symbol-name try-symbol) charset-lower))) - (list (cond ((and try-symbol (coding-system-p try-symbol)) - try-symbol) - ((and po-EMACS20 - (not (string-lessp "23" emacs-version)) - (string-match "\\`cp[1-9][0-9][0-9]?\\'" - try-string) - (assoc (substring try-string 2) - (cp-supported-codepages))) - (codepage-setup (substring try-string 2)) - (intern try-string)) - (t - 'no-conversion)))))))) + (and (eq operation 'insert-file-contents) + (file-exists-p filename) + (po-with-temp-buffer + (let* ((coding-system-for-read 'no-conversion) + (charset (or (po-find-charset filename) "ascii")) + (charset-upper (upcase charset)) + (charset-lower (downcase charset)) + (candidate + (cdr (assoc charset-upper po-content-type-charset-alist))) + (try-symbol (or candidate (intern-soft charset-lower))) + (try-string + (if try-symbol (symbol-name try-symbol) charset-lower))) + (list (cond ((and try-symbol (coding-system-p try-symbol)) + try-symbol) + ((and (not (string-lessp "23" emacs-version)) + (string-match "\\`cp[1-9][0-9][0-9]?\\'" + try-string) + (assoc (substring try-string 2) + (cp-supported-codepages))) + (codepage-setup (substring try-string 2)) + (intern try-string)) + (t + 'no-conversion))))))) - (if po-EMACS20 - (defun po-find-file-coding-system (arg-list) - "\ +(defun po-find-file-coding-system (arg-list) + "\ Return a Mule (DECODING . ENCODING) pair, according to PO file charset. Called through file-coding-system-alist, before the file is visited for real." - (po-find-file-coding-system-guts (car arg-list) (car (cdr arg-list))))) - - ) + (po-find-file-coding-system-guts (car arg-list) (car (cdr arg-list)))) (provide 'po-compat) diff --git a/gettext-tools/emacs/po-mode.el b/gettext-tools/emacs/po-mode.el index 33ed6b9f6..326b3d739 100644 --- a/gettext-tools/emacs/po-mode.el +++ b/gettext-tools/emacs/po-mode.el @@ -63,21 +63,12 @@ ;;; Code: -(defconst po-mode-version-string "2.25" "\ +(defconst po-mode-version-string "2.26" "\ Version number of this version of po-mode.el.") ;;; Emacs portability matters - part I. ;;; Here is the minimum for customization to work. See part II. -;; Identify which Emacs variety is being used. -;; This file supports: -;; - GNU Emacs (version 20 and above) -> po-EMACS20 = t, -;; - GNU Emacs (version 19) -> no flag. -(eval-and-compile - (cond ((and (string-lessp "19" emacs-version) (featurep 'faces)) - (setq po-EMACS20 t)) - (t (setq po-EMACS20 nil)))) - ;; Experiment with Emacs LISP message internationalisation. (eval-and-compile (or (fboundp 'set-translation-domain) @@ -180,7 +171,7 @@ to this email address." :type 'string :group 'po) -(defcustom po-highlighting po-EMACS20 +(defcustom po-highlighting t "*Highlight text whenever appropriate, when non-nil. However, on older Emacses, a yet unexplained highlighting bug causes files to get mangled." @@ -562,100 +553,27 @@ or remove the -m if you are not using the GNU version of 'uuencode'." ;; Handle portable highlighting. Code has been adapted (OK... stolen! :-) ;; from 'ispell.el'. -(eval-and-compile - (cond - (po-EMACS20 - (defun po-create-overlay () - "Create and return a deleted overlay structure. +(defun po-create-overlay () + "Create and return a deleted overlay structure. The variable 'po-highlight-face' selects the face to use for highlighting." - (let ((overlay (make-overlay (point) (point)))) - (overlay-put overlay 'face po-highlight-face) - ;; The fun thing is that a deleted overlay retains its face, and is - ;; movable. - (delete-overlay overlay) - overlay)) + (let ((overlay (make-overlay (point) (point)))) + (overlay-put overlay 'face po-highlight-face) + ;; The fun thing is that a deleted overlay retains its face, and is + ;; movable. + (delete-overlay overlay) + overlay)) - (defun po-highlight (overlay start end &optional buffer) - "Use OVERLAY to highlight the string from START to END. +(defun po-highlight (overlay start end &optional buffer) + "Use OVERLAY to highlight the string from START to END. If limits are not relative to the current buffer, use optional BUFFER." - (move-overlay overlay start end (or buffer (current-buffer)))) + (move-overlay overlay start end (or buffer (current-buffer)))) - (defun po-rehighlight (overlay) - "Ensure OVERLAY is highlighted." - ;; There is nothing to do, as GNU Emacs allows multiple highlights. - nil) - - (defun po-dehighlight (overlay) - "Display normally the last string which OVERLAY highlighted. +(defun po-dehighlight (overlay) + "Display normally the last string which OVERLAY highlighted. The current buffer should be in PO mode, when this function is called." - (delete-overlay overlay))) + (delete-overlay overlay)) - (t - - (defun po-create-overlay () - "Create and return a deleted overlay structure." - (cons (make-marker) (make-marker))) - - (defun po-highlight (overlay start end &optional buffer) - "Use OVERLAY to highlight the string from START to END. -If limits are not relative to the current buffer, use optional BUFFER. -No doubt that highlighting, when Emacs does not allow it, is a kludge." - (save-excursion - (and buffer (set-buffer buffer)) - (let ((modified (buffer-modified-p)) - (buffer-read-only nil) - (inhibit-quit t) - (buffer-undo-list t) - (text (buffer-substring start end))) - (goto-char start) - (delete-region start end) - (insert-char ? (- end start)) - (sit-for 0) - (setq inverse-video (not inverse-video)) - (delete-region start end) - (insert text) - (sit-for 0) - (setq inverse-video (not inverse-video)) - (set-buffer-modified-p modified))) - (set-marker (car overlay) start (or buffer (current-buffer))) - (set-marker (cdr overlay) end (or buffer (current-buffer)))) - - (defun po-rehighlight (overlay) - "Ensure OVERLAY is highlighted." - (let ((buffer (marker-buffer (car overlay))) - (start (marker-position (car overlay))) - (end (marker-position (cdr overlay)))) - (and buffer - (buffer-name buffer) - (po-highlight overlay start end buffer)))) - - (defun po-dehighlight (overlay) - "Display normally the last string which OVERLAY highlighted." - (let ((buffer (marker-buffer (car overlay))) - (start (marker-position (car overlay))) - (end (marker-position (cdr overlay)))) - (if buffer - (save-excursion - (set-buffer buffer) - (let ((modified (buffer-modified-p)) - (buffer-read-only nil) - (inhibit-quit t) - (buffer-undo-list t)) - (let ((text (buffer-substring start end))) - (goto-char start) - (delete-region start end) - (insert-char ? (- end start)) - (sit-for 0) - (delete-region start end) - (insert text) - (sit-for 0) - (set-buffer-modified-p modified))))) - (setcar overlay (make-marker)) - (setcdr overlay (make-marker)))) - - ))) - ;;; Buffer local variables. ;; The following block of declarations has the main purpose of avoiding @@ -2164,8 +2082,6 @@ comments) from the current entry, if the user gives the permission." (let ((slot (car po-edited-fields))) (goto-char (nth 0 slot)) (pop-to-buffer (nth 1 slot)) - (let ((overlay (nth 2 slot))) - (and overlay (po-rehighlight overlay))) (message po-subedit-message) nil))) @@ -2179,8 +2095,6 @@ comments) from the current entry, if the user gives the permission." (progn (goto-char marker) (pop-to-buffer (nth 1 slot)) - (let ((overlay (nth 2 slot))) - (and overlay (po-rehighlight overlay))) (message po-subedit-message))) (not slot)))) diff --git a/gettext-tools/emacs/start-po.el b/gettext-tools/emacs/start-po.el index d6ec5a086..f8770ab3e 100644 --- a/gettext-tools/emacs/start-po.el +++ b/gettext-tools/emacs/start-po.el @@ -1,6 +1,6 @@ ;;; start-po.el --- autoload definitions for viewing and editing PO files -;; Copyright (C) 1995-2004, 2016 Free Software Foundation, Inc. +;; Copyright (C) 1995-2004, 2016, 2019 Free Software Foundation, Inc. ;; ;; This file is part of GNU gettext. ;; @@ -44,7 +44,7 @@ all reachable through 'M-x customize', in group 'Emacs.Editing.I18n.Po'." ;; For viewing PO and POT files. -;; To use the right coding system automatically under Emacs 20 or newer. +;; To use the right coding system automatically. (unless (fboundp 'po-find-file-coding-system) (autoload 'po-find-file-coding-system "po-compat" "\