re lexicon
")
  "Help page for PO mode.")

(defconst po-mode-menu-layout
  `("PO"
    ("Moving around"
     ["Auto select" po-auto-select-entry
      :help "Jump to next interesting entry"]
     "---"
     ;; Forward
     ["Any next" po-next-entry
      :help "Jump to next entry"]
     ["Next translated" po-next-translated-entry
      :help "Jump to next translated entry"]
     ["Next fuzzy" po-next-fuzzy-entry
      :help "Jump to next fuzzy entry"]
     ["Next obsolete" po-next-obsolete-entry
      :help "Jump to next obsolete entry"]
     ["Next untranslated" po-next-untranslated-entry
      :help "Jump to next untranslated entry"]
     ["Last file entry" po-last-entry
      :help "Jump to last entry"]
     "---"
     ;; Backward
     ["Any previous" po-previous-entry
      :help "Jump to previous entry"]
     ["Previous translated" po-previous-translated-entry
      :help "Jump to previous translated entry"]
     ["Previous fuzzy" po-previous-fuzzy-entry
      :help "Jump to previous fuzzy entry"]
     ["Previous obsolete" po-previous-obsolete-entry
      :help "Jump to previous obsolete entry"]
     ["Previous untranslated" po-previous-untranslated-entry
      :help "Jump to previous untranslated entry"]
     ["First file entry" po-first-entry
      :help "Jump to first entry"]
     "---"
     ;; "Position stack"
     ["Mark and push current" po-push-location
      :help "Remember current location"]
     ["Pop and return" po-pop-location
      :help "Jump to last remembered location and forget about it"]
     ["Exchange current/top" po-exchange-location
      :help "Jump to last remembered location and remember current location"]
     "---"
     ["Redisplay" po-current-entry
      :help "Make current entry properly visible"]
     ["Current index" po-statistics
      :help "Statistical info on current translation file"])
    ("Modifying entries"
     ["Undo" po-undo
      :help "Revoke last changed entry"]
     "---"
     ;; "Msgstr"
     ["Edit msgstr" po-edit-msgstr
      :help "Edit current translation"]
     ["Ediff and merge msgstr" po-edit-msgstr-and-ediff
      :help "Call `ediff' on current translation for merging"]
     ["Cut msgstr" po-kill-msgstr
      :help "Cut (kill) current translation"]
     ["Copy msgstr" po-kill-ring-save-msgstr
      :help "Copy current translation"]
     ["Paste msgstr" po-yank-msgstr
      :help "Paste (yank) text most recently cut/copied translation"]
     "---"
     ;; "Comments"
     ["Edit comment" po-edit-comment
      :help "Edit current comment"]
     ["Ediff and merge comment" po-edit-comment-and-ediff
      :help "Call `ediff' on current comment for merging"]
     ["Cut comment" po-kill-comment
      :help "Cut (kill) current comment"]
     ["Copy comment" po-kill-ring-save-comment
      :help "Copy current translation"]
     ["Paste comment" po-yank-comment
      :help "Paste (yank) text most recently cut/copied"]
     "---"
     ["Remove fuzzy mark" po-unfuzzy
      :help "Remove \"#, fuzzy\""]
     ["Fuzzy or fade out" po-fade-out-entry
      :help "Set current entry fuzzy, or if already fuzzy delete it"]
     ["Init with msgid" po-msgid-to-msgstr
      :help "Initialize or replace current translation with the original message"])
    ("Other files"
     ["Other window" po-other-window
      :help "Select other window; if necessay split current frame"]
     "---"
     ;; "Program sources"
     ["Cycle reference in source file" po-cycle-source-reference t]
     ["Select reference" po-select-source-reference t]
     ["Consider path" po-consider-source-path t]
     ["Ignore path" po-ignore-source-path t]
     ;; "---"
     ;; ;; "Compendiums"
     ;; ["To add entry to compendium" po-save-entry nil]
     ;; ["Select from compendium, save" po-select-and-save-entry nil]
     "---"
     ;; "Auxiliary files"
     ["Cycle through auxilicary file" po-cycle-auxiliary t]
     ["Select auxilicary file" po-select-auxiliary t]
     ["Consider as auxilicary file" po-consider-as-auxiliary t]
     ["Ignore as auxilicary file" po-ignore-as-auxiliary t]
     ;; "---"
     ;; ;; "Lexicography"
     ;; ["Lookup translation" po-lookup-lexicons nil]
     ;; ["Add/edit translation" po-edit-lexicon-entry nil]
     ;; ["Consider lexicon" po-consider-lexicon-file nil]
     ;; ["Ignore lexicon" po-ignore-lexicon-file nil])
     "---"
     "Source marking"
     ["Find first string" (po-tags-search '(nil)) t]
     ["Prefer keyword" (po-select-mark-and-mark '(nil)) t]
     ["Find next string" po-tags-search t]
     ["Mark preferred" po-mark-translatable t]
     ["Mark with keyword" po-select-mark-and-mark t])
     "---"
     ["Version info" po-mode-version
      :help "Display version number of PO mode"]
     ["Help page" po-help
      :help "Show the PO mode help screen"]
     ["Validate" po-validate
      :help "Check validity of current translation file using `msgfmt'"]
     ["Mail officially" po-send-mail
      :help "Send current translation file to the Translation Robot by mail"]
     ["Edit out full" po-edit-out-full
      :help "Leave PO mode to edit translation file using fundamental mode"]
     "---"
     ["Forceful quit" po-quit
      :help "Close (kill) current translation file without saving"]
     ["Soft quit" po-confirm-and-quit
      :help "Save current translation file, than close (kill) it"]))


(defconst po-subedit-mode-menu-layout
  `("PO-Edit"
    ["Ediff and merge translation variants" po-subedit-ediff
      :help "Call `ediff' for merging variants"]
    ["Cycle through auxiliary files" po-subedit-cycle-auxiliary t]
    "---"
    ["Abort edit" po-subedit-abort
     :help "Don't change the translation"]
    ["Exit edit" po-subedit-exit
     :help "Use this text as the translation and close current edit buffer"]))

(defconst po-subedit-message
  (_"Type 'C-c C-c' once done, or 'C-c C-k' to abort edit")
  "Message to post in the minibuffer when an edit buffer is displayed.")

(defvar po-auxiliary-list nil
  "List of auxiliary PO files, in completing read format.")

(defvar po-auxiliary-cursor nil
  "Cursor into the 'po-auxiliary-list'.")

(defvar po-compose-mail-function
  (let ((functions '(compose-mail-other-window
                     message-mail-other-window
                     compose-mail
                     message-mail))
        result)
    (while (and (not result) functions)
      (if (fboundp (car functions))
          (setq result (car functions))
        (setq functions (cdr functions))))
    (cond (result)
          ((fboundp 'mail-other-window)
           (function (lambda (to subject)
                       (mail-other-window nil to subject))))
          ((fboundp 'mail)
           (function (lambda (to subject)
                       (mail nil to subject))))
          (t (function (lambda (to subject)
                         (error (_"I do not know how to mail to '%s'") to))))))
  "Function to start composing an electronic message.")

(defvar po-any-previous-msgctxt-regexp
  "^#\\(~\\)?|[ \t]*msgctxt.*\n\\(#\\(~\\)?|[ \t]*\".*\n\\)*"
  "Regexp matching a whole #| msgctxt field, whether obsolete or not.")

(defvar po-any-previous-msgid-regexp
  "^#\\(~\\)?|[ \t]*msgid.*\n\\(#\\(~\\)?|[ \t]*\".*\n\\)*"
  "Regexp matching a whole #| msgid field, whether obsolete or not.")

(defvar po-any-previous-msgid_plural-regexp
  "^#\\(~\\)?|[ \t]*msgid_plural.*\n\\(#\\(~\\)?|[ \t]*\".*\n\\)*"
  "Regexp matching a whole #| msgid_plural field, whether obsolete or not.")

(defvar po-any-msgctxt-msgid-regexp
  "^\\(#~[ \t]*\\)?msg\\(ctxt\\|id\\).*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*"
  "Regexp matching a whole msgctxt or msgid field, whether obsolete or not.")

(defvar po-any-msgid-regexp
  "^\\(#~[ \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.")

(defvar po-any-msgstr-form-regexp
  ;; "^\\(#~[ \t]*\\)?msgstr.*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*"
  "^\\(#~[ \t]*\\)?msgstr\\(\\[[0-9]\\]\\)?.*\n\\(\\(#~[ \t]*\\)?\".*\n\\)*"
  "Regexp matching just one msgstr or msgstr[] field, whether obsolete or not.")

(defvar po-msgstr-idx-keyword-regexp
  "^\\(#~[ \t]*\\)?msgstr\\[[0-9]\\]"
  "Regexp matching an indexed msgstr keyword, whether obsolete or not.")

(defvar po-msgfmt-program "msgfmt"
  "Path to msgfmt program from GNU gettext package.")

;; Font lock based highlighting code.
(defconst po-font-lock-keywords
  '(
    ("^# .*\\|^#[:,]?" . font-lock-comment-face)
    ("^#:\\(.*\\)" 1 font-lock-constant-face)
    ("^#,\\(.*\\)" 1 font-lock-function-name-face)
    ("^\\(\\(msg\\(ctxt\\|id\\(_plural\\)?\\|str\\(\\[[0-9]\\]\\)?\\)\\) \\)?\"\\|\"$"
     . font-lock-keyword-face)
    ("\\\\.\\|%[*$-.0-9hjltuzL]*[a-zA-Z]" . font-lock-variable-name-face)
    )
  "Additional expressions to highlight in PO mode.")

;; Old activator for 'font lock'.  Is it still useful?  I don't think so.
;;(if (boundp 'font-lock-keywords)
;;    (put 'po-mode 'font-lock-keywords 'po-font-lock-keywords))

;; 'hilit19' based highlighting code has been disabled, as most probably
;; nobody really needs it (it also generates ugly byte-compiler warnings).
;;
;;(if (fboundp 'hilit-set-mode-patterns)
;;    (hilit-set-mode-patterns 'po-mode
;;                             '(("^# .*\\|^#$" nil comment)
;;                               ("^#[.,:].*" nil include)
;;                               ("^\\(msgid\\|msgstr\\) *\"" nil keyword)
;;                               ("^\"\\|\"$" nil keyword))))
