]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Allow po-mode to be called on nonexisting or empty files.
authorBruno Haible <bruno@clisp.org>
Mon, 11 Mar 2002 13:56:07 +0000 (13:56 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:07:49 +0000 (12:07 +0200)
misc/ChangeLog
misc/po-mode.el

index 6449a0e4e85317f1d2e4840474c7955b1e2d7e6f..817133c98ddc29d4cb8f94a2733ebb5bec2a1159 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-09  Karl Eichwalder  <ke@suse.de>
+
+       * po-mode.el (po-find-file-coding-system-guts): Don't try to
+       detect the coding system when filename does not exists.
+       (po-compute-counters): Search for "^msgid" not 'po-next-entry' if
+       we don't know for sure any entry will follow at all.
+
 2002-02-18  Karl Eichwalder  <ke@suse.de>
 
        * po-mode.el (po-mode): Provide it.
index a1114ccfb774bad9a856f2eef65c10b11e265b56..6d4f2be182453f1131aa567cb5beaef9ca225e9a 100644 (file)
@@ -49,7 +49,7 @@
 
 ;;; Code:
 \f
-(defconst po-mode-version-string "1.90" "\
+(defconst po-mode-version-string "1.91" "\
 Version number of this version of po-mode.el.")
 
 ;;; Emacs portability matters - part I.
@@ -964,7 +964,8 @@ Content-Type into a Mule coding system.")
        "\
 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)
+       (and (file-exists-p filename)
+            (eq operation 'insert-file-contents)
             (po-with-temp-buffer
               (let ((coding-system-for-read 'no-conversion))
                  (let* ((charset (or (po-find-charset filename)
@@ -1197,33 +1198,34 @@ Then, update the mode line counters."
       ;; While counting, skip the header entry, for consistency with msgfmt.
       (po-find-span-of-entry)
       (if (string-equal (po-get-msgid nil) "")
-         (if (po-next-entry)
-             (progn
-               ;; Start counting
-               (while (re-search-forward po-any-msgstr-regexp nil t)
-                 (and (= (% total 20) 0)
-                      (if flag
-                          (message (_"Position %d/%d") position total)
-                        (message (_"Position %d") total)))
-                 (setq here (point))
-                 (goto-char (match-beginning 0))
-                 (setq total (1+ total))
-                 (and flag (eq (point) current) (setq position total))
-                 (cond ((eq (following-char) ?#)
-                        (setq po-obsolete-counter (1+ po-obsolete-counter)))
-                       ((looking-at po-untranslated-regexp)
-                        (setq po-untranslated-counter (1+ po-untranslated-counter)))
-                       (t (setq po-translated-counter (1+ po-translated-counter))))
-                 (goto-char here))
-
-               ;; Make another pass just for the fuzzy entries, kind of kludgey.
-               ;; FIXME: Counts will be wrong if untranslated entries are fuzzy, yet
-               ;; this should not normally happen.
-               (goto-char (point-min))
-               (while (re-search-forward po-fuzzy-regexp nil t)
-                 (setq po-fuzzy-counter (1+ po-fuzzy-counter)))
-               (setq po-translated-counter (- po-translated-counter po-fuzzy-counter)))
-           '())))
+         (goto-char po-end-of-entry))
+      (if (re-search-forward "^msgid" (point-max) t)
+         (progn
+           ;; Start counting
+           (while (re-search-forward po-any-msgstr-regexp nil t)
+             (and (= (% total 20) 0)
+                  (if flag
+                      (message (_"Position %d/%d") position total)
+                    (message (_"Position %d") total)))
+             (setq here (point))
+             (goto-char (match-beginning 0))
+             (setq total (1+ total))
+             (and flag (eq (point) current) (setq position total))
+             (cond ((eq (following-char) ?#)
+                    (setq po-obsolete-counter (1+ po-obsolete-counter)))
+                   ((looking-at po-untranslated-regexp)
+                    (setq po-untranslated-counter (1+ po-untranslated-counter)))
+                   (t (setq po-translated-counter (1+ po-translated-counter))))
+             (goto-char here))
+
+           ;; Make another pass just for the fuzzy entries, kind of kludgey.
+           ;; FIXME: Counts will be wrong if untranslated entries are fuzzy, yet
+           ;; this should not normally happen.
+           (goto-char (point-min))
+           (while (re-search-forward po-fuzzy-regexp nil t)
+             (setq po-fuzzy-counter (1+ po-fuzzy-counter)))
+           (setq po-translated-counter (- po-translated-counter po-fuzzy-counter)))
+       '()))
 
     ;; Push the results out.
     (if flag