+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.
(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)
"^\\(#~[ \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.")
(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)
(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
(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)))