Lines Matching defs:po

0 ;;; po-mode.el -- major mode for GNU gettext PO files
36 ;; (autoload 'po-mode "po-mode"
38 ;; (setq auto-mode-alist (cons '("\\.po\\'\\|\\.po\\." . po-mode)
44 ;; (autoload 'po-find-file-coding-system "po-compat")
45 ;; (modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\."
46 ;; 'po-find-file-coding-system)
54 (defconst po-mode-version-string "2.02" "\
55 Version number of this version of po-mode.el.")
62 ;; - XEmacs (version 19 and above) -> po-XEMACS = t,
63 ;; - GNU Emacs (version 20 and above) -> po-EMACS20 = t,
67 (setq po-EMACS20 nil po-XEMACS t))
69 (setq po-EMACS20 t po-XEMACS nil))
70 (t (setq po-EMACS20 nil po-XEMACS nil))))
96 (defgroup po nil
100 (defcustom po-auto-edit-with-msgid nil
103 :group 'po)
105 (defcustom po-auto-fuzzy-on-edit nil
108 :group 'po)
110 (defcustom po-auto-select-on-unfuzzy nil
113 :group 'po)
115 (defcustom po-auto-replace-revision-date t
120 :group 'po)
122 (defcustom po-default-file-header "\
140 :group 'po)
142 (defcustom po-translation-project-address
145 Typing \\[po-send-mail] (normally bound to `M') the user will send the PO file
148 :group 'po)
150 (defcustom po-translation-project-mail-label "TP-Robot"
151 "*Subject label when sending the PO file to `po-translation-project-address'.
153 Translation Project Robot at http://www.iro.umontreal.ca/contrib/po/HTML/. If
157 :group 'po)
159 (defcustom po-highlighting (or po-EMACS20 po-XEMACS)
164 :group 'po)
166 (defcustom po-highlight-face 'highlight
174 :group 'po)
176 (defcustom po-team-name-to-code
371 :group 'po)
373 (defcustom po-gzip-uuencode-command "gzip -9 | uuencode -m"
378 :group 'po)
380 (defvar po-subedit-mode-syntax-table
392 (fset 'po-buffer-substring
398 (fset 'po-match-string (symbol-function 'match-string-no-properties))
399 (defun po-match-string (number)
401 (po-buffer-substring (match-beginning number) (match-end number)))))
406 (fset 'po-with-temp-buffer (symbol-function 'with-temp-buffer))
408 (defmacro po-with-temp-buffer (&rest forms)
414 (generate-new-buffer-name " *po-temp*"))))
426 (fset 'po-kill-new (symbol-function 'kill-new))
428 (defun po-kill-new (string)
430 (po-with-temp-buffer
436 (fset 'po-read-event
450 (fset 'po-force-mode-line-update
453 (defun po-force-mode-line-update ()
461 (po-EMACS20
463 (defun po-create-overlay ()
465 The variable 'po-highlight-face' selects the face to use for highlighting."
467 (overlay-put overlay 'face po-highlight-face)
473 (defun po-highlight (overlay start end &optional buffer)
478 (defun po-rehighlight (overlay)
483 (defun po-dehighlight (overlay)
488 (po-XEMACS
490 (defun po-create-overlay ()
496 (set-extent-face extent po-highlight-face)
499 (defun po-highlight (extent start end &optional buffer)
504 (defun po-rehighlight (extent)
509 (defun po-dehighlight (extent)
515 (defun po-create-overlay ()
519 (defun po-highlight (overlay start end &optional buffer)
543 (defun po-rehighlight (overlay)
550 (po-highlight overlay start end buffer))))
552 (defun po-dehighlight (overlay)
587 (defvar po-mode-flag)
591 (defvar po-read-only)
597 (defvar po-start-of-entry)
598 (defvar po-start-of-msgid)
599 (defvar po-start-of-msgstr)
600 (defvar po-end-of-entry)
601 (defvar po-entry-type)
604 (defvar po-translated-counter)
605 (defvar po-fuzzy-counter)
606 (defvar po-untranslated-counter)
607 (defvar po-obsolete-counter)
608 (defvar po-mode-line-string)
620 (defvar po-edited-fields)
623 (defvar po-marker-stack)
628 (defvar po-search-path)
636 (defvar po-reference-alist)
637 (defvar po-reference-cursor)
638 (defvar po-reference-check)
648 (defvar po-keywords)
649 (defvar po-string-contents)
650 (defvar po-string-buffer)
651 (defvar po-string-start)
652 (defvar po-string-end)
653 (defvar po-marking-overlay)
660 (set-translation-domain "po-mode")
662 (defun po-mode-version ()
665 (message (_"Emacs PO mode, version %s") po-mode-version-string))
667 (defconst po-help-display-string
695 (defconst po-mode-menu-layout
698 ["Auto select" po-auto-select-entry
703 ["Any next" po-next-entry
706 ["Next translated" po-next-translated-entry
709 ["Next fuzzy" po-next-fuzzy-entry
712 ["Next obsolete" po-next-obsolete-entry
715 ["Next untranslated" po-next-untranslated-entry
718 ["Last file entry" po-last-entry
723 ["Any previous" po-previous-entry
726 ["Previous translated" po-previous-translated-entry
729 ["Previous fuzzy" po-previous-fuzzy-entry
732 ["Previous obsolete" po-previous-obsolete-entry
735 ["Previous untranslated" po-previous-untranslated-entry
738 ["First file entry" po-first-entry
743 ["Mark and push current" po-push-location
746 ["Pop and return" po-pop-location
749 ["Exchange current/top" po-exchange-location
753 ["Redisplay" po-current-entry
756 ["Current index" po-statistics
760 ["Undo" po-undo
765 ["Edit msgstr" po-edit-msgstr
768 ["Ediff and merge msgstr" po-edit-msgstr-and-ediff
771 ["Cut msgstr" po-kill-msgstr
774 ["Copy msgstr" po-kill-ring-save-msgstr
777 ["Paste msgstr" po-yank-msgstr
782 ["Edit comment" po-edit-comment
785 ["Ediff and merge comment" po-edit-comment-and-ediff
788 ["Cut comment" po-kill-comment
791 ["Copy comment" po-kill-ring-save-comment
794 ["Paste comment" po-yank-comment
798 ["Remove fuzzy mark" po-unfuzzy
801 ["Fuzzy or fade out" po-fade-out-entry
804 ["Init with msgid" po-msgid-to-msgstr
809 ["Other window" po-other-window
814 ["Cycle reference" po-cycle-source-reference t]
815 ["Select reference" po-select-source-reference t]
816 ["Consider path" po-consider-source-path t]
817 ["Ignore path" po-ignore-source-path t]
820 ["To compendium" po-save-entry nil]
821 ["Select, save" po-select-and-save-entry nil]
824 ["Cycle file" po-cycle-auxiliary t]
825 ["Select file" po-select-auxiliary t]
826 ["Consider file" po-consider-as-auxiliary t]
827 ["Ignore file" po-ignore-as-auxiliary t]
830 ["Lookup translation" po-lookup-lexicons nil]
831 ["Add/edit translation" po-edit-lexicon-entry nil]
832 ["Consider lexicon" po-consider-lexicon-file nil]
833 ["Ignore lexicon" po-ignore-lexicon-file nil])
836 ["Find first string" (po-tags-search '(nil)) t]
837 ["Prefer keyword" (po-select-mark-and-mark '(nil)) t]
838 ["Find next string" po-tags-search t]
839 ["Mark preferred" po-mark-translatable t]
840 ["Mark with keyword" po-select-mark-and-mark t]
842 ["Version info" po-mode-version
845 ["Help page" po-help
848 ["Validate" po-validate
851 ["Mail officially" po-send-mail
854 ["Edit out full" po-edit-out-full
858 ["Forceful quit" po-quit
861 ["Soft quit" po-confirm-and-quit
866 (defconst po-subedit-mode-menu-layout
868 ["Ediff and merge translation variants" po-subedit-ediff
871 ["Cycle through auxiliary files" po-subedit-cycle-auxiliary t]
873 ["Abort edit" po-subedit-abort
876 ["Exit edit" po-subedit-exit
881 (defconst po-subedit-message
885 (defvar po-auxiliary-list nil
888 (defvar po-auxiliary-cursor nil
889 "Cursor into the 'po-auxiliary-list'.")
891 (defvar po-compose-mail-function
912 (defvar po-any-msgid-regexp
916 (defvar po-any-msgstr-regexp
921 (defvar po-msgstr-idx-keyword-regexp
925 (defvar po-msgfmt-program "msgfmt"
929 (defconst po-font-lock-keywords
947 ;; (put 'po-mode 'font-lock-keywords 'po-font-lock-keywords))
953 ;; (hilit-set-mode-patterns 'po-mode
962 ;; Emacs 21.2 comes with po-find-file-coding-system. We give preference
964 (if (not (fboundp 'po-find-file-coding-system))
965 (require 'po-compat))
967 (defvar po-mode-abbrev-table nil
969 (define-abbrev-table 'po-mode-abbrev-table ())
971 (defvar po-mode-map
973 (let ((po-mode-map (make-keymap)))
974 (suppress-keymap po-mode-map)
975 (define-key po-mode-map "\C-i" 'po-unfuzzy)
976 (define-key po-mode-map "\C-j" 'po-msgid-to-msgstr)
977 (define-key po-mode-map "\C-m" 'po-edit-msgstr)
978 (define-key po-mode-map " " 'po-auto-select-entry)
979 (define-key po-mode-map "?" 'po-help)
980 (define-key po-mode-map "#" 'po-edit-comment)
981 (define-key po-mode-map "," 'po-tags-search)
982 (define-key po-mode-map "." 'po-current-entry)
983 (define-key po-mode-map "<" 'po-first-entry)
984 (define-key po-mode-map "=" 'po-statistics)
985 (define-key po-mode-map ">" 'po-last-entry)
986 (define-key po-mode-map "a" 'po-cycle-auxiliary)
987 ;;;; (define-key po-mode-map "c" 'po-save-entry)
988 (define-key po-mode-map "f" 'po-next-fuzzy-entry)
989 (define-key po-mode-map "h" 'po-help)
990 (define-key po-mode-map "k" 'po-kill-msgstr)
991 ;;;; (define-key po-mode-map "l" 'po-lookup-lexicons)
992 (define-key po-mode-map "m" 'po-push-location)
993 (define-key po-mode-map "n" 'po-next-entry)
994 (define-key po-mode-map "o" 'po-next-obsolete-entry)
995 (define-key po-mode-map "p" 'po-previous-entry)
996 (define-key po-mode-map "q" 'po-confirm-and-quit)
997 (define-key po-mode-map "r" 'po-pop-location)
998 (define-key po-mode-map "s" 'po-cycle-source-reference)
999 (define-key po-mode-map "t" 'po-next-translated-entry)
1000 (define-key po-mode-map "u" 'po-next-untranslated-entry)
1001 (define-key po-mode-map "v" 'po-mode-version)
1002 (define-key po-mode-map "w" 'po-kill-ring-save-msgstr)
1003 (define-key po-mode-map "x" 'po-exchange-location)
1004 (define-key po-mode-map "y" 'po-yank-msgstr)
1005 (define-key po-mode-map "A" 'po-consider-as-auxiliary)
1006 (define-key po-mode-map "E" 'po-edit-out-full)
1007 (define-key po-mode-map "F" 'po-previous-fuzzy-entry)
1008 (define-key po-mode-map "K" 'po-kill-comment)
1009 ;;;; (define-key po-mode-map "L" 'po-consider-lexicon-file)
1010 (define-key po-mode-map "M" 'po-send-mail)
1011 (define-key po-mode-map "O" 'po-previous-obsolete-entry)
1012 (define-key po-mode-map "T" 'po-previous-translated-entry)
1013 (define-key po-mode-map "U" 'po-previous-untranslated-entry)
1014 (define-key po-mode-map "Q" 'po-quit)
1015 (define-key po-mode-map "S" 'po-consider-source-path)
1016 (define-key po-mode-map "V" 'po-validate)
1017 (define-key po-mode-map "W" 'po-kill-ring-save-comment)
1018 (define-key po-mode-map "Y" 'po-yank-comment)
1019 (define-key po-mode-map "_" 'po-undo)
1020 (define-key po-mode-map "0" 'po-other-window)
1021 (define-key po-mode-map "\177" 'po-fade-out-entry)
1022 (define-key po-mode-map "\C-c\C-a" 'po-select-auxiliary)
1023 (define-key po-mode-map "\C-c\C-e" 'po-edit-msgstr-and-ediff)
1024 (define-key po-mode-map [?\C-c?\C-#] 'po-edit-comment-and-ediff)
1025 (define-key po-mode-map "\C-c\C-C" 'po-edit-comment-and-ediff)
1026 (define-key po-mode-map "\M-," 'po-mark-translatable)
1027 (define-key po-mode-map "\M-." 'po-select-mark-and-mark)
1028 ;;;; (define-key po-mode-map "\M-c" 'po-select-and-save-entry)
1029 ;;;; (define-key po-mode-map "\M-l" 'po-edit-lexicon-entry)
1030 (define-key po-mode-map "\M-s" 'po-select-source-reference)
1031 (define-key po-mode-map "\M-A" 'po-ignore-as-auxiliary)
1032 ;;;; (define-key po-mode-map "\M-L" 'po-ignore-lexicon-file)
1033 (define-key po-mode-map "\M-S" 'po-ignore-source-path)
1034 po-mode-map)
1037 (defun po-mode ()
1041 \\{po-mode-map}
1042 Turning on PO mode calls the value of the variable 'po-mode-hook',
1047 (setq major-mode 'po-mode
1049 (use-local-map po-mode-map)
1052 (easy-menu-define po-mode-menu po-mode-map "" po-mode-menu-layout)
1053 (and po-XEMACS (easy-menu-add po-mode-menu))))
1054 (set (make-local-variable 'font-lock-defaults) '(po-font-lock-keywords t))
1056 (set (make-local-variable 'po-read-only) buffer-read-only)
1059 (make-local-variable 'po-start-of-entry)
1060 (make-local-variable 'po-start-of-msgid)
1061 (make-local-variable 'po-start-of-msgstr)
1062 (make-local-variable 'po-end-of-entry)
1063 (make-local-variable 'po-entry-type)
1065 (make-local-variable 'po-translated-counter)
1066 (make-local-variable 'po-fuzzy-counter)
1067 (make-local-variable 'po-untranslated-counter)
1068 (make-local-variable 'po-obsolete-counter)
1069 (make-local-variable 'po-mode-line-string)
1071 (setq po-mode-flag t)
1073 (po-check-file-header)
1074 (po-compute-counters nil)
1076 (set (make-local-variable 'po-edited-fields) nil)
1077 (set (make-local-variable 'po-marker-stack) nil)
1078 (set (make-local-variable 'po-search-path) '(("./") ("../")))
1080 (set (make-local-variable 'po-reference-alist) nil)
1081 (set (make-local-variable 'po-reference-cursor) nil)
1082 (set (make-local-variable 'po-reference-check) 0)
1084 (set (make-local-variable 'po-keywords)
1086 (set (make-local-variable 'po-string-contents) nil)
1087 (set (make-local-variable 'po-string-buffer) nil)
1088 (set (make-local-variable 'po-string-start) nil)
1089 (set (make-local-variable 'po-string-end) nil)
1090 (set (make-local-variable 'po-marking-overlay) (po-create-overlay))
1092 (add-hook 'write-contents-hooks 'po-replace-revision-date)
1094 (run-hooks 'po-mode-hook)
1097 (defvar po-subedit-mode-map
1099 (let ((po-subedit-mode-map (make-keymap)))
1100 (define-key po-subedit-mode-map "\C-c\C-a" 'po-subedit-cycle-auxiliary)
1101 (define-key po-subedit-mode-map "\C-c\C-c" 'po-subedit-exit)
1102 (define-key po-subedit-mode-map "\C-c\C-e" 'po-subedit-ediff)
1103 (define-key po-subedit-mode-map "\C-c\C-k" 'po-subedit-abort)
1104 po-subedit-mode-map)
1110 (make-variable-buffer-local 'po-mode-flag)
1112 (defvar po-mode-line-entry '(po-mode-flag (" " po-mode-line-string))
1116 (or (member po-mode-line-entry mode-line-format)
1122 (setcdr prev-entry (cons po-mode-line-entry (cdr prev-entry)))))
1124 (defun po-update-mode-line-string ()
1126 (setq po-mode-line-string
1127 (concat (format "%dt" po-translated-counter)
1128 (if (> po-fuzzy-counter 0)
1129 (format "+%df" po-fuzzy-counter))
1130 (if (> po-untranslated-counter 0)
1131 (format "+%du" po-untranslated-counter))
1132 (if (> po-obsolete-counter 0)
1133 (format "+%do" po-obsolete-counter))))
1134 (po-force-mode-line-update))
1136 (defun po-type-counter ()
1138 (cond ((eq po-entry-type 'obsolete) 'po-obsolete-counter)
1139 ((eq po-entry-type 'fuzzy) 'po-fuzzy-counter)
1140 ((eq po-entry-type 'translated) 'po-translated-counter)
1141 ((eq po-entry-type 'untranslated) 'po-untranslated-counter)
1144 (defun po-decrease-type-counter ()
1146 (let ((counter (po-type-counter)))
1149 (defun po-increase-type-counter ()
1152 (let ((counter (po-type-counter)))
1154 (po-update-mode-line-string))
1157 (defvar po-fuzzy-regexp)
1158 (defvar po-untranslated-regexp)
1160 (defun po-compute-counters (flag)
1162 (and flag (po-find-span-of-entry))
1163 (setq po-translated-counter 0
1164 po-fuzzy-counter 0
1165 po-untranslated-counter 0
1166 po-obsolete-counter 0)
1170 (po-find-span-of-entry)
1171 (setq current po-start-of-msgstr)
1174 (po-find-span-of-entry)
1175 (if (string-equal (po-get-msgid nil) "")
1176 (goto-char po-end-of-entry))
1180 (while (re-search-forward po-any-msgstr-regexp nil t)
1190 (setq po-obsolete-counter (1+ po-obsolete-counter)))
1191 ((looking-at po-untranslated-regexp)
1192 (setq po-untranslated-counter (1+ po-untranslated-counter)))
1193 (t (setq po-translated-counter (1+ po-translated-counter))))
1200 (while (re-search-forward po-fuzzy-regexp nil t)
1201 (setq po-fuzzy-counter (1+ po-fuzzy-counter)))
1202 (setq po-translated-counter (- po-translated-counter po-fuzzy-counter)))
1209 position total po-translated-counter po-fuzzy-counter
1210 po-untranslated-counter po-obsolete-counter)
1212 (po-update-mode-line-string))
1214 (defun po-redisplay ()
1220 (goto-char po-start-of-msgid))
1222 (defun po-other-window ()
1234 (defun po-check-file-header ()
1237 (let ((buffer-read-only po-read-only)
1240 (if (re-search-forward po-any-msgstr-regexp nil t)
1266 (insert po-default-file-header)
1270 (defun po-replace-revision-date ()
1273 (if (or (eq po-auto-replace-revision-date t)
1274 (and (eq po-auto-replace-revision-date 'ask)
1279 (let* ((buffer-read-only po-read-only)
1298 (defun po-find-span-of-entry ()
1304 (if (re-search-backward po-any-msgstr-regexp nil t)
1310 (re-search-forward po-any-msgstr-regexp)
1316 (setq po-start-of-entry (match-end 0))
1320 (setq po-start-of-msgstr (match-beginning 0)
1321 po-end-of-entry (match-end 0))
1322 (if (re-search-forward po-any-msgstr-regexp nil t)
1325 (setq po-start-of-msgstr (match-beginning 0)
1326 po-end-of-entry (match-end 0)))
1330 (goto-char po-start-of-msgstr)
1331 (setq po-start-of-entry
1332 (if (re-search-backward po-any-msgstr-regexp nil t)
1336 (setq po-start-of-msgstr (match-beginning 0)
1337 po-end-of-entry (match-end 0))
1340 (goto-char po-start-of-msgstr)
1341 (setq po-start-of-entry
1342 (if (re-search-backward po-any-msgstr-regexp nil t)
1346 (setq po-start-of-entry (point-min))
1347 (goto-char po-start-of-entry)
1349 (re-search-forward po-any-msgstr-regexp)
1350 (setq po-start-of-msgstr (match-beginning 0)
1351 po-end-of-entry (match-end 0)))
1353 (goto-char po-start-of-entry)
1354 (re-search-forward po-any-msgid-regexp)
1355 (setq po-start-of-msgid (match-beginning 0))
1357 (setq po-entry-type
1360 (goto-char po-start-of-entry)
1361 (if (re-search-forward po-fuzzy-regexp po-start-of-msgid t)
1363 (goto-char po-start-of-msgstr)
1364 (if (looking-at po-untranslated-regexp)
1370 (defun po-add-attribute (name)
1373 (let ((buffer-read-only po-read-only))
1374 (goto-char po-start-of-entry)
1375 (if (re-search-forward "\n#[,!] .*" po-start-of-msgid t)
1388 (defun po-delete-attribute (name)
1391 (let ((buffer-read-only po-read-only))
1392 (goto-char po-start-of-entry)
1393 (if (re-search-forward "\n#[,!] .*" po-start-of-msgid t)
1405 (defun po-say-location-depth ()
1407 (let ((depth (length po-marker-stack)))
1412 (defun po-push-location ()
1415 (po-find-span-of-entry)
1417 (goto-char po-start-of-msgid)
1418 (setq po-marker-stack (cons (point-marker) po-marker-stack)))
1419 (po-say-location-depth))
1421 (defun po-pop-location ()
1424 (if po-marker-stack
1426 (goto-char (car po-marker-stack))
1427 (setq po-marker-stack (cdr po-marker-stack))
1428 (po-current-entry)
1429 (po-say-location-depth))
1432 (defun po-exchange-location ()
1435 (if po-marker-stack
1437 (po-find-span-of-entry)
1438 (goto-char po-start-of-msgid)
1440 (goto-char (car po-marker-stack))
1441 (setq po-marker-stack (cons location (cdr po-marker-stack))))
1442 (po-current-entry)
1443 (po-say-location-depth))
1446 (defun po-current-entry ()
1449 (po-find-span-of-entry)
1450 (po-redisplay))
1452 (defun po-first-entry-with-regexp (regexp)
1459 (po-current-entry))
1463 (defun po-last-entry-with-regexp (regexp)
1468 (po-current-entry)
1472 (defun po-next-entry-with-regexp (regexp wrap)
1475 (po-find-span-of-entry)
1477 (goto-char po-end-of-entry)
1481 (po-current-entry))
1485 (re-search-forward regexp po-start-of-entry t)))
1488 (po-current-entry)
1493 (defun po-previous-entry-with-regexp (regexp wrap)
1496 (po-find-span-of-entry)
1498 (goto-char po-start-of-entry)
1500 (po-current-entry)
1504 (re-search-backward regexp po-end-of-entry t)))
1506 (po-current-entry)
1513 (defun po-first-entry ()
1516 (po-first-entry-with-regexp po-any-msgstr-regexp))
1518 (defun po-last-entry ()
1521 (po-last-entry-with-regexp po-any-msgstr-regexp))
1523 (defun po-next-entry ()
1526 (po-next-entry-with-regexp po-any-msgstr-regexp nil))
1528 (defun po-previous-entry ()
1531 (po-previous-entry-with-regexp po-any-msgstr-regexp nil))
1535 (defvar po-after-entry-regexp
1539 (defvar po-untranslated-regexp
1540 (concat "^msgstr[ \t]*\"\"\n" po-after-entry-regexp)
1543 (defun po-next-untranslated-entry ()
1546 (po-next-entry-with-regexp po-untranslated-regexp t))
1548 (defun po-previous-untranslated-entry ()
1551 (po-previous-entry-with-regexp po-untranslated-regexp t))
1553 (defun po-msgid-to-msgstr ()
1556 (po-find-span-of-entry)
1557 (if (or (eq po-entry-type 'untranslated)
1558 (eq po-entry-type 'obsolete)
1560 (po-set-msgstr (po-get-msgid nil)))
1565 (defvar po-obsolete-msgstr-regexp
1569 (defun po-next-obsolete-entry ()
1572 (po-next-entry-with-regexp po-obsolete-msgstr-regexp t))
1574 (defun po-previous-obsolete-entry ()
1577 (po-previous-entry-with-regexp po-obsolete-msgstr-regexp t))
1581 (defvar po-fuzzy-regexp "^#[,!] .*fuzzy"
1585 (defun po-next-fuzzy-entry ()
1588 (po-next-entry-with-regexp po-fuzzy-regexp t))
1590 (defun po-previous-fuzzy-entry ()
1593 (po-previous-entry-with-regexp po-fuzzy-regexp t))
1595 (defun po-unfuzzy ()
1598 (po-find-span-of-entry)
1599 (cond ((eq po-entry-type 'fuzzy)
1600 (po-decrease-type-counter)
1601 (po-delete-attribute "fuzzy")
1602 (po-current-entry)
1603 (po-increase-type-counter)))
1604 (if po-auto-select-on-unfuzzy
1605 (po-auto-select-entry))
1606 (po-update-mode-line-string))
1610 (defun po-next-translated-entry ()
1613 (if (= po-translated-counter 0)
1615 (po-next-entry-with-regexp po-any-msgstr-regexp t)
1616 (po-find-span-of-entry)
1617 (while (not (eq po-entry-type 'translated))
1618 (po-next-entry-with-regexp po-any-msgstr-regexp t)
1619 (po-find-span-of-entry))))
1621 (defun po-previous-translated-entry ()
1624 (if (= po-translated-counter 0)
1626 (po-previous-entry-with-regexp po-any-msgstr-regexp t)
1627 (po-find-span-of-entry)
1628 (while (not (eq po-entry-type 'translated))
1629 (po-previous-entry-with-regexp po-untranslated-regexp t)
1630 (po-find-span-of-entry))))
1634 (defun po-auto-select-entry ()
1641 (po-find-span-of-entry)
1642 (goto-char po-end-of-entry)
1643 (if (and (= po-untranslated-counter 0)
1644 (= po-fuzzy-counter 0)
1645 (= po-obsolete-counter 0))
1648 (if (re-search-forward po-any-msgstr-regexp nil t)
1653 (let ((goal (if (eq po-entry-type 'translated)
1655 po-entry-type)))
1659 (if (and (> po-untranslated-counter 0)
1660 (re-search-forward po-untranslated-regexp nil t))
1668 (if (and (> po-fuzzy-counter 0)
1669 (re-search-forward po-fuzzy-regexp nil t))
1677 (if (and (> po-obsolete-counter 0)
1678 (re-search-forward po-obsolete-msgstr-regexp nil t))
1685 (po-current-entry))
1690 (defun po-extract-unquoted (buffer start end)
1700 (po-extract-part-unquoted buffer start end))
1702 (defun po-extract-part-unquoted (buffer start end)
1705 (po-with-temp-buffer
1733 (defun po-eval-requoted (form prefix obsolete)
1739 (po-with-temp-buffer
1774 (defun po-get-msgid (kill)
1777 (let ((string (po-extract-unquoted (current-buffer)
1778 po-start-of-msgid po-start-of-msgstr)))
1779 (if kill (po-kill-new string))
1782 (defun po-get-msgstr (kill)
1785 (let ((string (po-extract-unquoted (current-buffer)
1786 po-start-of-msgstr po-end-of-entry)))
1787 (if kill (po-kill-new string))
1790 (defun po-set-msgid (form)
1798 (let ((string (po-eval-requoted form "msgid" (eq po-entry-type 'obsolete))))
1800 (goto-char po-start-of-entry)
1801 (re-search-forward po-any-msgid-regexp po-start-of-msgstr)
1802 (and (not (string-equal (po-match-string 0) string))
1803 (let ((buffer-read-only po-read-only))
1805 (goto-char po-start-of-msgid)
1806 (po-find-span-of-entry)
1809 (defun po-set-msgstr (form)
1817 (let ((string (po-eval-requoted form "msgstr" (eq po-entry-type 'obsolete)))
1820 (goto-char po-start-of-entry)
1822 (if (re-search-forward po-msgstr-idx-keyword-regexp
1823 po-end-of-entry t)
1826 (re-search-forward po-any-msgstr-regexp po-end-of-entry)
1827 (and (not (string-equal (po-match-string 0) string))
1828 (let ((buffer-read-only po-read-only))
1829 (po-decrease-type-counter)
1837 (goto-char po-start-of-msgid)
1838 (po-find-span-of-entry)
1839 (po-increase-type-counter)
1842 (defun po-kill-ring-save-msgstr ()
1845 (po-find-span-of-entry)
1846 (po-get-msgstr t))
1848 (defun po-kill-msgstr ()
1851 (po-kill-ring-save-msgstr)
1852 (po-set-msgstr ""))
1854 (defun po-yank-msgstr ()
1857 (po-find-span-of-entry)
1858 (po-set-msgstr (if (eq last-command 'yank) '(yank-pop 1) '(yank)))
1861 (defun po-fade-out-entry ()
1865 (po-find-span-of-entry)
1867 (cond ((eq po-entry-type 'translated)
1868 (po-decrease-type-counter)
1869 (po-add-attribute "fuzzy")
1870 (po-current-entry)
1871 (po-increase-type-counter))
1873 ((or (eq po-entry-type 'fuzzy)
1874 (eq po-entry-type 'untranslated))
1877 (po-decrease-type-counter)
1880 (narrow-to-region po-start-of-entry po-end-of-entry)
1881 (let ((buffer-read-only po-read-only))
1887 (po-current-entry)
1888 (po-increase-type-counter)))
1891 ((and (eq po-entry-type 'obsolete)
1892 (po-check-for-pending-edit po-start-of-msgid)
1893 (po-check-for-pending-edit po-start-of-msgstr))
1894 (po-decrease-type-counter)
1895 (po-update-mode-line-string)
1896 (po-get-msgstr t)
1897 (let ((buffer-read-only po-read-only))
1898 (delete-region po-start-of-entry po-end-of-entry))
1899 (goto-char po-start-of-entry)
1900 (if (re-search-forward po-any-msgstr-regexp nil t)
1902 (re-search-backward po-any-msgstr-regexp nil t))
1903 (po-current-entry)
1909 (defvar po-active-comment-regexp
1913 (defvar po-obsolete-comment-regexp
1917 (defun po-get-comment (kill-flag)
1921 (obsolete (eq po-entry-type 'obsolete)))
1923 (goto-char po-start-of-entry)
1924 (if (re-search-forward (if obsolete po-obsolete-comment-regexp
1925 po-active-comment-regexp)
1926 po-end-of-entry t)
1927 (po-with-temp-buffer
1938 (defun po-set-comment (form)
1943 (let ((obsolete (eq po-entry-type 'obsolete))
1945 (po-with-temp-buffer
1959 (goto-char po-start-of-entry)
1961 (if obsolete po-obsolete-comment-regexp po-active-comment-regexp)
1962 po-end-of-entry t)
1963 (if (not (string-equal (po-match-string 0) string))
1964 (let ((buffer-read-only po-read-only))
1967 (let ((buffer-read-only po-read-only))
1969 (po-current-entry))
1971 (defun po-kill-ring-save-comment ()
1974 (po-find-span-of-entry)
1975 (po-get-comment t))
1977 (defun po-kill-comment ()
1980 (po-kill-ring-save-comment)
1981 (po-set-comment "")
1982 (po-redisplay))
1984 (defun po-yank-comment ()
1987 (po-find-span-of-entry)
1988 (po-set-comment (if (eq last-command 'yank) '(yank-pop 1) '(yank)))
1990 (po-redisplay))
1999 (defvar po-subedit-back-pointer)
2001 (defun po-clean-out-killed-edits ()
2003 (let ((cursor po-edited-fields))
2010 (and overlay (po-dehighlight overlay)))
2011 (setq po-edited-fields (delete slot po-edited-fields)))))))
2013 (defun po-check-all-pending-edits ()
2015 (po-clean-out-killed-edits)
2016 (or (null po-edited-fields)
2017 (let ((slot (car po-edited-fields)))
2021 (and overlay (po-rehighlight overlay)))
2022 (message po-subedit-message)
2025 (defun po-check-for-pending-edit (position)
2027 (po-clean-out-killed-edits)
2030 (let ((slot (assoc marker po-edited-fields)))
2036 (and overlay (po-rehighlight overlay)))
2037 (message po-subedit-message)))
2040 (defun po-edit-out-full ()
2043 (if (and (po-check-all-pending-edits)
2046 (setq buffer-read-only po-read-only)
2048 (message (_"Type 'M-x po-mode RET' once done")))))
2050 (defun po-ediff-quit ()
2058 (define-key ediff-mode-map "Q" 'po-ediff-quit)))
2060 (defun po-ediff-buffers-exit-recursive (b1 b2 oldbuf end)
2067 For more info cf. `po-subedit-ediff'."
2076 (defun po-subedit-ediff ()
2078 `po-subedit-ediff' calls `po-ediff-buffers-exit-recursive' to edit translation
2089 `recursive-edit', or call \\[po-ediff-quit] (`Q') in the ediff control panel."
2092 (buf1 " *po-msgstr-1") ; default if first marker is missing
2094 (back-pointer po-subedit-back-pointer)
2129 (po-ediff-buffers-exit-recursive buf1 buf2 oldbuf end-2)
2134 (defun po-subedit-abort ()
2138 (back-pointer po-subedit-back-pointer)
2147 (and overlay-info (po-dehighlight overlay-info))
2149 (setq po-edited-fields (delete back-pointer po-edited-fields)))))
2151 (defun po-subedit-exit ()
2158 (run-hooks 'po-subedit-exit-hook)
2160 (po-subedit-abort)
2161 (po-find-span-of-entry)
2162 (cond ((= (point) po-start-of-msgid)
2163 (po-set-comment string)
2164 (po-redisplay))
2165 ((= (point) po-start-of-msgstr)
2166 (let ((replaced (po-set-msgstr string)))
2168 po-auto-fuzzy-on-edit
2169 (eq po-entry-type 'translated))
2171 (po-decrease-type-counter)
2172 (po-add-attribute "fuzzy")
2173 (po-current-entry)
2174 (po-increase-type-counter)))))
2177 (defun po-edit-string (string type expand-tabs)
2180 Run functions on po-subedit-mode-hook."
2182 (set-marker marker (cond ((eq type 'comment) po-start-of-msgid)
2183 ((eq type 'msgstr) po-start-of-msgstr)))
2184 (if (po-check-for-pending-edit marker)
2190 (if (and (eq type 'msgstr) po-highlighting)
2192 ;; (goto-char (1- po-start-of-msgstr))
2195 (goto-char po-start-of-entry)
2196 (re-search-forward po-any-msgid-regexp nil t)
2200 (setq overlay (po-create-overlay))
2201 (po-highlight overlay (point) end buffer))))
2203 po-edited-fields (cons slot po-edited-fields))
2205 (set (make-local-variable 'po-subedit-back-pointer) slot)
2209 (setq local-abbrev-table po-mode-abbrev-table)
2214 (use-local-map po-subedit-mode-map)
2217 (easy-menu-define po-subedit-mode-menu po-subedit-mode-map ""
2218 po-subedit-mode-menu-layout)
2219 (and po-XEMACS (easy-menu-add po-subedit-mode-menu))))
2220 (set-syntax-table po-subedit-mode-syntax-table)
2221 (run-hooks 'po-subedit-mode-hook)
2222 (message po-subedit-message)))))
2224 (defun po-edit-comment ()
2227 (po-find-span-of-entry)
2228 (po-edit-string (po-get-comment nil) 'comment nil))
2230 (defun po-edit-comment-and-ediff ()
2232 This function calls `po-edit-msgstr' and `po-subedit-ediff'; for more info
2233 read `po-subedit-ediff' documentation."
2235 (po-edit-comment)
2236 (po-subedit-ediff))
2238 (defun po-edit-msgstr ()
2241 (po-find-span-of-entry)
2242 (po-edit-string (if (and po-auto-edit-with-msgid
2243 (eq po-entry-type 'untranslated))
2244 (po-get-msgid nil)
2245 (po-get-msgstr nil))
2249 (defun po-edit-msgstr-and-ediff ()
2251 This function calls `po-edit-msgstr' and `po-subedit-ediff'; for more info
2252 read `po-subedit-ediff' documentation."
2254 (po-edit-msgstr)
2255 (po-subedit-ediff))
2260 (defun po-normalize-old-style (explain)
2265 (buffer-read-only po-read-only))
2278 (defun po-normalize-field (field explain)
2284 (while (re-search-forward po-any-msgstr-regexp nil t)
2288 (po-find-span-of-entry)
2289 (cond ((eq field 'msgid) (po-set-msgid (po-get-msgid nil)))
2290 ((eq field 'msgstr) (po-set-msgstr (po-get-msgstr nil))))
2291 (goto-char po-end-of-entry)
2297 (defsubst po-normalise () (po-normalize))
2299 (defun po-normalize ()
2302 (po-normalize-old-style (_"pass 1/3"))
2303 (po-normalize-field t (_"pass 2/3"))
2304 (po-normalize-field nil (_"pass 3/3"))
2306 (if (not (= po-end-of-entry (point-max)))
2307 (let ((buffer-read-only po-read-only))
2308 (kill-region po-end-of-entry (point-max))))
2311 (po-compute-counters nil))
2316 (defun po-show-auxiliary-list ()
2318 (if po-auxiliary-list
2319 (let ((cursor po-auxiliary-cursor)
2324 (setq cursor po-auxiliary-list)
2325 (while (not (eq cursor po-auxiliary-cursor))
2331 (defun po-consider-as-auxiliary ()
2334 (if (member (list buffer-file-name) po-auxiliary-list)
2336 (setq po-auxiliary-list
2337 (nconc po-auxiliary-list (list (list buffer-file-name))))
2338 (or po-auxiliary-cursor
2339 (setq po-auxiliary-cursor po-auxiliary-list)))
2340 (po-show-auxiliary-list))
2342 (defun po-ignore-as-auxiliary ()
2345 (setq po-auxiliary-list (delete (list buffer-file-name) po-auxiliary-list)
2346 po-auxiliary-cursor po-auxiliary-list)
2347 (po-show-auxiliary-list))
2349 (defun po-seek-equivalent-translation (name string)
2365 (po-find-span-of-entry)
2368 (buffer-substring po-start-of-msgstr po-end-of-entry)
2374 (po-find-span-of-entry)
2375 (if po-highlighting
2377 (goto-char po-start-of-entry)
2378 (re-search-forward po-any-msgstr-regexp nil t)
2383 (po-highlight po-marking-overlay (point) end))))
2384 (goto-char po-start-of-msgid))
2386 (po-find-span-of-entry)
2390 (defun po-cycle-auxiliary ()
2393 (po-find-span-of-entry)
2394 (if po-auxiliary-list
2395 (let ((string (buffer-substring po-start-of-msgid po-start-of-msgstr))
2396 (cursor po-auxiliary-cursor)
2401 (po-seek-equivalent-translation name string))
2403 po-auxiliary-cursor cursor))
2405 (setq cursor po-auxiliary-list)
2409 (po-seek-equivalent-translation name string))
2411 po-auxiliary-cursor cursor))
2416 (defun po-subedit-cycle-auxiliary ()
2419 (let* ((entry-marker (nth 0 po-subedit-back-pointer))
2423 (po-cycle-auxiliary)
2426 (defun po-select-auxiliary ()
2431 (po-find-span-of-entry)
2432 (if po-auxiliary-list
2433 (let ((string (buffer-substring po-start-of-msgid po-start-of-msgstr))
2435 po-auxiliary-list nil t)
2436 po-auxiliary-list))))
2437 (po-consider-as-auxiliary)
2438 (or (po-seek-equivalent-translation name string)
2444 (defun po-show-source-path ()
2446 (if po-search-path
2447 (let ((cursor po-search-path)
2455 (defun po-consider-source-path (directory)
2458 (setq po-search-path (cons (list (if (string-match "/$" directory)
2461 po-search-path))
2462 (setq po-reference-check 0)
2463 (po-show-source-path))
2465 (defun po-ignore-source-path ()
2468 (setq po-search-path
2470 po-search-path nil t))
2471 po-search-path))
2472 (setq po-reference-check 0)
2473 (po-show-source-path))
2475 (defun po-ensure-source-references ()
2477 (po-find-span-of-entry)
2478 (if (= po-start-of-entry po-reference-check)
2480 (setq po-reference-alist nil)
2482 (goto-char po-start-of-entry)
2483 (if (re-search-forward "^#:" po-start-of-msgid t)
2487 (setq name (po-match-string 2)
2488 line (po-match-string 3)
2489 path po-search-path)
2498 (setq po-reference-alist
2502 po-reference-alist)))))))
2503 (setq po-reference-alist (nreverse po-reference-alist)
2504 po-reference-cursor po-reference-alist
2505 po-reference-check po-start-of-entry)))
2507 (defun po-show-source-context (triplet)
2514 (cursor po-reference-alist))
2519 po-reference-cursor cursor)
2525 (defun po-cycle-source-reference ()
2529 (po-ensure-source-references)
2530 (if po-reference-cursor
2531 (po-show-source-context
2532 (car (if (eq last-command 'po-cycle-source-reference)
2533 (or (cdr po-reference-cursor) po-reference-alist)
2534 po-reference-cursor)))
2537 (defun po-select-source-reference ()
2540 (po-ensure-source-references)
2541 (if po-reference-alist
2542 (po-show-source-context
2544 (completing-read (_"Which source context? ") po-reference-alist nil t)
2545 po-reference-alist))
2556 (defvar po-find-string-function)
2557 (defvar po-mark-string-function)
2559 ;; Dynamically set within po-tags-search for po-tags-loop-operate.
2560 (defvar po-current-po-buffer)
2561 (defvar po-current-po-keywords)
2563 (defun po-tags-search (restart)
2570 (if po-highlighting
2571 (po-dehighlight po-marking-overlay))
2572 (setq po-string-contents nil)
2574 (let ((po-current-po-buffer (current-buffer))
2575 (po-current-po-keywords po-keywords))
2576 (pop-to-buffer po-string-buffer)
2578 (eq (car tags-loop-operate) 'po-tags-loop-operate))
2579 ;; Continue last po-tags-search.
2581 ;; Start or restart po-tags-search all over.
2582 (setq tags-loop-scan '(po-tags-loop-scan)
2583 tags-loop-operate '(po-tags-loop-operate))
2585 (select-window (get-buffer-window po-current-po-buffer)))
2586 (if po-string-contents
2588 (buffer po-string-buffer)
2589 (start po-string-start)
2590 (end po-string-end))
2602 (and po-highlighting
2603 (po-highlight po-marking-overlay start end buffer)))))
2605 (defun po-tags-loop-scan ()
2609 ;; tags module to revisit files fully. po-tags-loop-operate sets point at
2613 (defun po-tags-loop-operate ()
2616 (po-preset-string-functions)
2620 (setq data (apply po-find-string-function po-current-po-keywords nil))
2623 (po-with-temp-buffer
2645 (set-buffer po-current-po-buffer)
2646 (setq po-string-contents (nth 0 data)
2647 po-string-buffer buffer
2648 po-string-start (nth 1 data)
2649 po-string-end (nth 2 data))))
2654 (defun po-mark-found-string (keyword)
2656 (if (not po-string-contents)
2658 (and po-highlighting (po-dehighlight po-marking-overlay))
2659 (let ((contents po-string-contents)
2660 (buffer po-string-buffer)
2661 (start po-string-start)
2662 (end po-string-end)
2668 (apply po-mark-string-function start end keyword nil))
2670 (let ((buffer-read-only po-read-only))
2673 (buffer-file-name po-string-buffer)
2676 (insert (po-eval-requoted contents "msgid" nil) "msgstr \"\"\n"))
2677 (setq po-untranslated-counter (1+ po-untranslated-counter))
2678 (po-update-mode-line-string))
2679 (setq po-string-contents nil)))
2681 (defun po-mark-translatable ()
2684 (po-mark-found-string "_"))
2686 (defun po-select-mark-and-mark (arg)
2693 (setq po-keywords (cons keyword (delete keyword po-keywords))))
2694 (or po-string-contents (error (_"No such string")))
2695 (let* ((default (car (car po-keywords)))
2698 po-keywords nil t )))
2700 (po-mark-found-string keyword))))
2705 (defun po-preset-string-functions ()
2709 '(po-find-awk-string . po-mark-awk-string))
2711 '(po-find-c-string . po-mark-c-string))
2713 '(po-find-emacs-lisp-string . po-mark-emacs-lisp-string))
2715 '(po-find-python-string . po-mark-python-string))
2718 '(po-find-bash-string . po-mark-bash-string))
2719 (t '(po-find-unknown-string . po-mark-unknown-string)))))
2720 (or (boundp 'po-find-string-function)
2721 (set (make-local-variable 'po-find-string-function) (car pair)))
2722 (or (boundp 'po-mark-string-function)
2723 (set (make-local-variable 'po-mark-string-function) (cdr pair)))))
2725 (defun po-find-unknown-string (keywords)
2729 (defun po-mark-unknown-string (start end keyword)
2736 (defun po-find-awk-string (keywords)
2771 (if (member (list (po-buffer-substring
2778 (list (po-extract-unquoted (current-buffer) start end) start end))))
2780 (defun po-mark-awk-string (start end keyword)
2797 (defun po-find-bash-string (keywords)
2828 (list (po-extract-unquoted (current-buffer) start end) start end))))
2830 (defun po-mark-bash-string (start end keyword)
2858 (defun po-find-c-string (keywords)
2899 (if (member (list (po-buffer-substring (point)
2913 (list (po-extract-unquoted (current-buffer) start end) start end))))
2915 (defun po-mark-c-string (start end keyword)
2929 (defun po-find-emacs-lisp-string (keywords)
2954 (member (list (po-buffer-substring (point)
2964 (list (po-extract-unquoted (current-buffer) start end) start end))))
2966 (defun po-mark-emacs-lisp-string (start end keyword)
2979 (defun po-find-python-string (keywords)
2992 (po-skip-over-python-string))
2995 (po-skip-over-python-string))
3001 contents (po-skip-over-python-string)
3014 (if (member (list (po-buffer-substring (point)
3023 (defun po-skip-over-python-string ()
3084 (po-extract-part-unquoted (current-buffer)
3089 (defun po-mark-python-string (start end keyword)
3109 (defun po-help ()
3112 (po-with-temp-buffer
3113 (insert po-help-display-string)
3119 (po-read-event))))
3121 (defun po-undo ()
3124 (let ((buffer-read-only po-read-only))
3126 (po-compute-counters nil))
3128 (defun po-statistics ()
3131 (po-compute-counters t))
3133 (defun po-validate ()
3148 (compile-command (concat po-msgfmt-program
3151 (po-msgfmt-version-check)
3154 (defvar po-msgfmt-version-checked nil)
3155 (defun po-msgfmt-version-check ()
3157 (po-with-temp-buffer
3160 po-msgfmt-version-checked
3165 (call-process po-msgfmt-program
3185 (setq po-msgfmt-version-checked t))
3189 (defun po-guess-archive-name ()
3196 (re-search-forward po-any-msgstr-regexp)
3204 (setq package (po-match-string 2)
3205 version (po-match-string 3)))
3211 (string-match "^[^\\.]*\\.po\\'" filename))
3212 (;; TP Robot compatible `filename': PACKAGE-VERSION.LL.po
3214 "-\\(.*\\)\\.[^\\.]*\\.po\\'") filename)
3215 (if (not (equal version (po-match-string 1 filename)))
3219 (po-match-string 1 filename) version))))
3221 (if (stringp po-team-name-to-code)
3222 (setq team po-team-name-to-code)
3227 (let ((name (po-match-string 1)))
3229 (let ((pair (assoc name po-team-name-to-code)))
3238 (concat package "-" version "." team ".po"))))
3240 (defun po-guess-team-address ()
3245 (re-search-forward po-any-msgstr-regexp)
3250 (setq team (po-match-string 2)))
3253 (po-match-string 1))))
3255 (defun po-send-mail ()
3262 (po-guess-team-address)
3263 po-translation-project-address)))
3265 (apply po-compose-mail-function address
3270 (or (zerop po-untranslated-counter)
3273 po-untranslated-counter)))
3274 (or (zerop po-fuzzy-counter)
3277 po-fuzzy-counter)))
3278 (or (zerop po-obsolete-counter)
3281 po-obsolete-counter))))
3283 (name (po-guess-archive-name))
3287 (apply po-compose-mail-function address
3290 (format "%s %s" po-translation-project-mail-label name))
3299 (concat po-gzip-uuencode-command " " name ".gz") t))))))
3302 (defun po-confirm-and-quit ()
3306 (if (po-check-all-pending-edits)
3309 (> po-untranslated-counter 0)
3310 (> po-fuzzy-counter 0)
3311 (> po-obsolete-counter 0)
3313 (po-quit))
3316 (defun po-quit ()
3321 (if (po-check-all-pending-edits)
3329 (po-validate)
3334 ;; 'po-quit' command will be later required to exit for true.
3338 (or (> po-untranslated-counter 0)
3339 (> po-fuzzy-counter 0)
3340 (> po-obsolete-counter 0))
3345 (po-auto-select-entry)))
3354 (provide 'po-mode)
3356 ;;; po-mode.el ends here