>From 7c287eff074bdfd29b1aa752a9b0eb4468002553 Mon Sep 17 00:00:00 2001 From: Eliza Velasquez Date: Sat, 15 Jul 2023 03:38:24 -0700 Subject: [PATCH 2/2] po-mode.el: Fix flymake/byte compiler warnings --- gettext-tools/emacs/po-mode.el | 103 ++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/gettext-tools/emacs/po-mode.el b/gettext-tools/emacs/po-mode.el index 6f79e963d..893ebdaa0 100644 --- a/gettext-tools/emacs/po-mode.el +++ b/gettext-tools/emacs/po-mode.el @@ -60,9 +60,9 @@ ;; msgstr[1] line, so that the translator just needs to press RET to edit ;; that. ;; - If msgstr[1] is empty but msgstr[0] is not, it would be ergonomic if the -;; contents of msgstr[0] would be copied. (Not sure if this should happen +;; contents of msgstr[0] would be copied. (Not sure if this should happen ;; at the end of the editing msgstr[0] or at the beginning of the editing -;; of msgstr[1].) Reason: These two strings are usually very similar. +;; of msgstr[1].) Reason: These two strings are usually very similar. ;;; Code: @@ -78,13 +78,13 @@ Version number of this version of po-mode.el.") (defsubst set-translation-domain (string) nil)) (or (fboundp 'translate-string) (defsubst translate-string (string) string))) -(defsubst _ (string) (translate-string string)) -(defsubst N_ (string) string) +(defalias '_ #'translate-string) +(defalias 'N_ #'identity) ;;; Customisation. (defgroup po nil - "Major mode for editing PO files" + "Major mode for editing PO files." :group 'i18n) (defcustom po-auto-edit-with-msgid nil @@ -171,8 +171,8 @@ to get mangled." (defcustom po-highlight-face 'highlight "*The face used for PO mode highlighting. For Emacses with overlays. -Possible values are 'highlight', 'modeline', 'secondary-selection', -'region', and 'underline'. +Possible values are `highlight', `modeline', `secondary-selection', +`region', and `underline'. This variable can be set by the user to whatever face they desire. It's most convenient if the cursor color and highlight color are slightly different." @@ -465,7 +465,7 @@ If a string instead of an alist, it is a team code to use unconditionnally." (defcustom po-gzip-uuencode-command "gzip -9 | uuencode -m" "*The filter to use for preparing a mail invoice of the PO file. Normally \"gzip -9 | uuencode -m\", remove the -9 for lesser compression, -or remove the -m if you are not using the GNU version of 'uuencode'." +or remove the -m if you are not using the GNU version of `uuencode'." :type 'string :group 'po) @@ -495,7 +495,7 @@ automatically buffer-local wherever it is set." (defun po-create-overlay () "Create and return a deleted overlay structure. -The variable 'po-highlight-face' selects the face to use for highlighting." +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 @@ -781,7 +781,7 @@ M-S Ignore path M-A Ignore PO file *M-L Ignore lexicon "List of auxiliary PO files, in completing read format.") (defvar po-auxiliary-cursor nil - "Cursor into the 'po-auxiliary-list'.") + "Cursor into the `po-auxiliary-list'.") (defvar po-compose-mail-function #'compose-mail-other-window "Function to start composing an electronic message.") @@ -1152,10 +1152,11 @@ Can be customized with the `po-auto-update-file-header' variable." (defun po-find-span-of-entry () "Find the extent of the PO file entry where the cursor is. -Set variables po-start-of-entry, po-start-of-msgctxt, po-start-of-msgid, -po-start-of-msgid_plural, po-start-of-msgstr-block, po-end-of-entry, and -po-entry-type to meaningful values. po-entry-type may be set to: obsolete, -fuzzy, untranslated, or translated." +Set variables `po-start-of-entry', `po-start-of-msgctxt', +`po-start-of-msgid', `po-start-of-msgid_plural', +`po-start-of-msgstr-block', `po-end-of-entry', and +`po-entry-type' to meaningful values. `po-entry-type' may be set +to: obsolete, fuzzy, untranslated, or translated." (let ((here (point))) (if (re-search-backward po-any-msgstr-block-regexp nil t) (progn @@ -1457,8 +1458,9 @@ If WRAP is not nil, the search may wrap around the buffer." ;; Fuzzy entries. (defvar po-fuzzy-regexp "^#, .*fuzzy" - "Regexp matching the string inserted by msgmerge for translations -which does not match exactly.") + "Regexp matching fuzzy entries. +A fuzzy entry is a message flagged by msgmerge for updated +translations which do not match exactly.") (defun po-next-fuzzy-entry () "Find the next fuzzy entry, wrapping around if necessary." @@ -1688,7 +1690,7 @@ Evaluating FORM should insert the wanted string in the current buffer. If FORM is itself a string, then this string is used for insertion. The string is properly requoted before the replacement occurs. -Returns 'nil' if the buffer has not been modified, for if the new msgid +Returns nil if the buffer has not been modified, for if the new msgid described by FORM is merely identical to the msgid already in place." (let ((string (po-eval-requoted form "msgid" (eq po-entry-type 'obsolete)))) (save-excursion @@ -1707,7 +1709,7 @@ Evaluating FORM should insert the wanted string in the current buffer. If FORM is itself a string, then this string is used for insertion. The string is properly requoted before the replacement occurs. -Returns 'nil' if the buffer has not been modified, for if the new msgstr +Returns nil if the buffer has not been modified, for if the new msgstr described by FORM is merely identical to the msgstr already in place." (let ((string (po-eval-requoted form (po-get-msgstr-flavor) @@ -1871,8 +1873,8 @@ The string is properly recommented before the replacement occurs." ;;; Deleting the "previous untranslated" comment. (defun po-previous-untranslated-region-for (rx) - "Return the list of previous untranslated regions (at most one) for the -given regular expression RX." + "Return list of previous untranslated regions for regex RX. +The list contains at most one entry." (save-excursion (goto-char po-start-of-entry) (if (re-search-forward rx po-start-of-msgctxt t) @@ -1887,8 +1889,9 @@ given regular expression RX." (po-previous-untranslated-region-for po-any-previous-msgid_plural-regexp))) (defun po-delete-previous-untranslated () - "Delete the previous msgctxt, msgid, msgid_plural fields (marked as #| -comments) from the current entry." + "Delete the previous untranslated strings from the current entry. +Previously untranslated strings are marked as \"#|\" comments and +include msgctxt, msgid, and msgid_plural fields." (interactive) (po-find-span-of-entry) (let ((buffer-read-only po-read-only)) @@ -1897,8 +1900,10 @@ comments) from the current entry." (po-redisplay)) (defun po-maybe-delete-previous-untranslated () - "Delete the previous msgctxt, msgid, msgid_plural fields (marked as #| -comments) from the current entry, if the user gives the permission." + "Maybe delete previous untranslated strings in the current entry. +This function prompts the user for confirmation before deletion. +Previously untranslated strings are marked as \"#|\" comments and +include msgctxt, msgid, and msgid_plural fields." (po-find-span-of-entry) (let ((previous-regions (po-previous-untranslated-regions))) (if previous-regions @@ -1997,7 +2002,7 @@ comments) from the current entry, if the user gives the permission." "Ediff buffer B1 and B2, pop back to OLDBUF and replace the old variants. This function will delete the first two variants in OLDBUF, call `ediff-buffers' to compare both strings and replace the two variants in -OLDBUF with the contents of B2. +OLDBUF with the contents of B2. END marks the end of the two variants. Once done kill B1 and B2. For more info cf. `po-subedit-ediff'." @@ -2113,8 +2118,8 @@ When done with the `ediff' session press \\[exit-recursive-edit] exit to (defun po-edit-string (string type expand-tabs) "Prepare a pop up buffer for editing STRING, which is of a given TYPE. -TYPE may be 'comment or 'msgstr. If EXPAND-TABS, expand tabs to spaces. -Run functions on po-subedit-mode-hook." +TYPE may be \\='comment or \\='msgstr. If EXPAND-TABS, expand +tabs to spaces. Run functions on po-subedit-mode-hook." (let ((marker (make-marker))) (set-marker marker (cond ((eq type 'comment) po-start-of-msgid) ((eq type 'msgstr) po-start-of-msgstr-form))) @@ -2228,7 +2233,7 @@ To minibuffer messages sent while normalizing, add the EXPLAIN string." (message (_"Normalizing %d...done") counter))) ;; Normalize, but the British way! :-) -(defsubst po-normalise () (po-normalize)) +(defalias 'po-normalise #'po-normalize) (defun po-normalize () "Normalize all entries in the PO file." @@ -2281,11 +2286,11 @@ To minibuffer messages sent while normalizing, add the EXPLAIN string." (po-show-auxiliary-list)) (defun po-seek-equivalent-translation (name string) - "Search a PO file NAME for a 'msgid' STRING having a non-empty 'msgstr'. -STRING is the full quoted msgid field, including the 'msgid' keyword. When -found, display the file over the current window, with the 'msgstr' field -possibly highlighted, the cursor at start of msgid, then return 't'. -Otherwise, move nothing, and just return 'nil'." + "Search a PO file NAME for a `msgid' STRING having a non-empty `msgstr'. +STRING is the full quoted msgid field, including the `msgid' keyword. When +found, display the file over the current window, with the `msgstr' field +possibly highlighted, the cursor at start of msgid, then return t. +Otherwise, move nothing, and just return nil." (let ((current (current-buffer)) (buffer (find-file-noselect name))) (set-buffer buffer) @@ -2322,7 +2327,7 @@ Otherwise, move nothing, and just return 'nil'." found))) (defun po-cycle-auxiliary () - "Select the next auxiliary file having an entry with same 'msgid'." + "Select the next auxiliary file having an entry with same `msgid'." (interactive) (po-find-span-of-entry) (if po-auxiliary-list @@ -2360,7 +2365,7 @@ Otherwise, move nothing, and just return 'nil'." (defun po-select-auxiliary () "Select one of the available auxiliary files and locate an equivalent entry. -If an entry having the same 'msgid' cannot be found, merely select the file +If an entry having the same `msgid' cannot be found, merely select the file without moving its cursor." (interactive) (po-find-span-of-entry) @@ -2442,7 +2447,8 @@ without moving its cursor." (defun po-show-source-context (triplet) "Show the source context given a TRIPLET which is (PROMPT FILE LINE)." (find-file-other-window (car (cdr triplet))) - (goto-line (car (cdr (cdr triplet)))) + (goto-char (point-min)) + (forward-line (1- (car (cdr (cdr triplet))))) (other-window 1) (let ((maximum 0) position @@ -2497,7 +2503,7 @@ If the command is repeated many times in a row, cycle through contexts." (defun po-tags-search (restart) "Find an unmarked translatable string through all files in tags table. Disregard some simple strings which are most probably non-translatable. -With prefix argument, restart search at first file." +With prefix argument RESTART, restart search at first file." (interactive "P") (require 'etags) ;; Ensure there is no highlighting, in case the search fails. @@ -2575,8 +2581,7 @@ Disregard some simple strings which are most probably non-translatable." (if data ;; Save information for marking functions. (let ((buffer (current-buffer))) - (save-excursion - (set-buffer po-current-po-buffer) + (with-current-buffer po-current-po-buffer (setq po-string-contents (nth 0 data) po-string-buffer buffer po-string-start (nth 1 data) @@ -2596,8 +2601,7 @@ Disregard some simple strings which are most probably non-translatable." (end po-string-end) line string) ;; Mark string in program sources. - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (setq line (count-lines (point-min) start)) (apply po-mark-string-function start end keyword nil)) ;; Add PO file entry. @@ -2618,9 +2622,10 @@ Disregard some simple strings which are most probably non-translatable." (po-mark-found-string "_")) (defun po-select-mark-and-mark (arg) - "Mark last found string in program sources as translatable, ask for keyword, -using completion. With prefix argument, just ask the name of a preferred -keyword for subsequent commands, also added to possible completions." + "Mark last found string in program sources as translatable. +This asks for a keyword using completion. With prefix argument +ARG, just ask the name of a preferred keyword for subsequent +commands, also added to possible completions." (interactive "P") (if arg (let ((keyword (list (read-from-minibuffer (_"Keyword: "))))) @@ -2655,11 +2660,13 @@ These variables are locally set in source buffer only when nil." (setq po-mark-string-function (cdr pair))))) (defun po-find-unknown-string (keywords) - "Dummy function to skip over a file, finding no string in it." + "Dummy function to skip over a file, finding no string in it. +KEYWORDS is ignored." nil) (defun po-mark-unknown-string (start end keyword) - "Dummy function to mark a given string. May not be called." + "Dummy function to mark a given string. Raise error if called. +START, END, and KEYWORD are ignored." (error (_"Dummy function called"))) ;;; Awk mode specifics. @@ -3060,7 +3067,7 @@ Leave point after marked string." (po-compute-counters t)) (defun po-validate () - "Use 'msgfmt' for validating the current PO file contents." + "Use `msgfmt' for validating the current PO file contents." (interactive) ;; The 'compile' subsystem is autoloaded through a call to (compile ...). ;; We need to initialize it outside of any binding. Without this statement, @@ -3083,7 +3090,7 @@ Leave point after marked string." (defvar po-msgfmt-version-checked nil) (defun po-msgfmt-version-check () - "'msgfmt' from GNU gettext 0.10.36 or greater is required." + "`msgfmt' from GNU gettext 0.10.36 or greater is required." (with-temp-buffer (or ;; Don't bother checking again. -- 2.40.1