]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
po-mode: Determine position of "msgid_plural" line in current entry.
authorBruno Haible <bruno@clisp.org>
Sat, 8 May 2010 18:21:27 +0000 (20:21 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 8 May 2010 18:29:17 +0000 (20:29 +0200)
gettext-tools/misc/ChangeLog
gettext-tools/misc/po-mode.el

index a1c9c3e0610684980d18680fc682f9a563af57ca..f066aacab707ab87c2b955b37709186085ddb944 100644 (file)
@@ -1,3 +1,14 @@
+2010-05-08  Noritada Kobayashi  <nori1@dolphin.c.u-tokyo.ac.jp>
+            Bruno Haible  <bruno@clisp.org>
+
+       po-mode: Determine position of "msgid_plural" line in current entry.
+       * po-mode.el (po-start-of-msgid_plural): New variable.
+       (po-any-msgid_plural-regexp): New variable.
+       (po-mode): Make po-start-of-msgid_plural buffer-local.
+       (po-find-span-of-entry): Set also po-start-of-msgid_plural.
+       Based on patch in
+       <http://lists.gnu.org/archive/html/bug-gnu-utils/2008-05/msg00031.html>.
+
 2010-05-08  Bruno Haible  <bruno@clisp.org>
 
        * po-mode.el (po-get-msgstr-flavor): Preserve the point's position.
index 749a23bb818086e43eaffec34c97171c2063a3d4..b76bdf8d81c650575ab8434353b4f72ae2274dc8 100644 (file)
@@ -687,6 +687,7 @@ No doubt that highlighting, when Emacs does not allow it, is a kludge."
 (defvar po-start-of-entry)
 (defvar po-start-of-msgctxt) ; = po-start-of-msgid if there is no msgctxt
 (defvar po-start-of-msgid)
+(defvar po-start-of-msgid_plural) ; = nil if there is no msgid_plural
 (defvar po-start-of-msgstr-block)
 (defvar po-start-of-msgstr-form)
 (defvar po-end-of-msgstr-form)
@@ -1008,6 +1009,10 @@ Initialize or replace current translation with the original message"))])
   "^\\(#~[ \t]*\\)?msgid.*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*"
   "Regexp matching a whole msgid field, whether obsolete or not.")
 
+(defvar po-any-msgid_plural-regexp
+  "^\\(#~[ \t]*\\)?msgid_plural.*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*"
+  "Regexp matching a whole msgid_plural field, whether obsolete or not.")
+
 (defvar po-any-msgstr-block-regexp
   "^\\(#~[ \t]*\\)?msgstr\\([ \t]\\|\\[0\\]\\).*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*\\(\\(#~[ \t]*\\)?msgstr\\[[0-9]\\].*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*\\)*"
   "Regexp matching a whole msgstr or msgstr[] field, whether obsolete or not.")
@@ -1158,6 +1163,7 @@ all reachable through 'M-x customize', in group 'Emacs.Editing.I18n.Po'."
   (make-local-variable 'po-start-of-entry)
   (make-local-variable 'po-start-of-msgctxt)
   (make-local-variable 'po-start-of-msgid)
+  (make-local-variable 'po-start-of-msgid_plural)
   (make-local-variable 'po-start-of-msgstr-block)
   (make-local-variable 'po-end-of-entry)
   (make-local-variable 'po-entry-type)
@@ -1398,10 +1404,10 @@ Position %d/%d; %d translated, %d fuzzy, %d untranslated, %d obsolete")
 
 (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-msgstr-block, PO-END-OF-ENTRY and PO-ENTRY-TYPE to meaningful
-values. Decreasing priority of type interpretation is: 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
@@ -1458,13 +1464,20 @@ untranslated or translated."
     (goto-char po-start-of-entry)
     (re-search-forward po-any-msgid-regexp)
     (setq po-start-of-msgid (match-beginning 0))
+    (save-excursion
+      (goto-char po-start-of-msgid)
+      (setq po-start-of-msgid_plural
+            (if (re-search-forward po-any-msgid_plural-regexp
+                                   po-start-of-msgstr-block t)
+                (match-beginning 0)
+              nil)))
     (save-excursion
       (when (>= here po-start-of-msgstr-block)
         ;; point was somewhere inside of msgstr*
         (goto-char here)
         (end-of-line)
         (re-search-backward "^\\(#~[ \t]*\\)?msgstr"))
-      ;; Detect the bounderies of the msgstr we are interested in.
+      ;; Detect the boundaries of the msgstr we are interested in.
       (re-search-forward po-any-msgstr-form-regexp)
       (setq po-start-of-msgstr-form (match-beginning 0)
             po-end-of-msgstr-form (match-end 0)))