(defvar fetchmail-mode-syntax-table nil
"Syntax table used while in fetchmail-mode" )
(if fetchmail-mode-syntax-table
() (setq fetchmail-mode-syntax-table (make-syntax-table))
(modify-syntax-entry ?\\ "\\ " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\, "." fetchmail-mode-syntax-table)
(modify-syntax-entry ?\: "." fetchmail-mode-syntax-table)
(modify-syntax-entry ?\ (modify-syntax-entry ?\" "\"" fetchmail-mode-syntax-table)
(modify-syntax-entry ?\' "\"" fetchmail-mode-syntax-table)
(modify-syntax-entry ?\n "> " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\# "< " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\( "() " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\) ")( " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\[ "(] " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\] ")[ " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\{ "(} " fetchmail-mode-syntax-table)
(modify-syntax-entry ?\} "){ " fetchmail-mode-syntax-table)
)
(defvar fetchmail-mode-map nil
"Keymap used in fetchmail-mode" )
(if fetchmail-mode-map nil
(setq fetchmail-mode-map (make-sparse-keymap))
(define-key fetchmail-mode-map "\t" 'fetchmail-complete)
(define-key fetchmail-mode-map "\C-c\C-c" 'comment-region) )
(defvar fetchmail-mode-hook nil
"Hooks to run in fetchmail-mode" )
(defvar fetchmail-keywords nil
"Keywords used for fetchmail-mode" )
(unless fetchmail-keywords
(setq fetchmail-keywords
'("poll" "skip" "via" "in" "proto" "protocol" "uidl" "no" "port" "auth" "authenticate" "timeout" "envelope" "qvirtual" "envelope" "aka" "localdomains" "interface" "monitor" "dns" "user" "username" "is" "folder" "pass" "password" "smtp" "smtphost" "smtpaddress" "antispam" "mda" "pre" "preconnect" "post" "postconnect" "keep" "flush" "fetchall" "rewrite" "forcecr" "stripcr" "pass8bits" "dropstatus" "limit" "fetchlimit" "batchlimit" "expunge" "pop2" "POP2" "pop3" "POP3" "imap" "IMAP" "imap-k4" "IMAP-K4" "apop" "APOP" "rpop" "RPOP" "kpop" "KPOP" "etrn" "ETRN" "login" "kerberos" "kerberos_v5" "logfile" "daemon" "syslog" "invisible" "and" "with" "has" "wants" "options" "here" "there" "aka" "set")))
(defvar fetchmail-keyword-table nil
"Completion table for fetchmail-mode" )
(unless fetchmail-keyword-table
(setq fetchmail-keyword-table (make-vector 8 0))
(mapcar (lambda (x) (intern x fetchmail-keyword-table))
fetchmail-keywords))
(defvar fetchmail-font-lock-keywords nil
"Default expressions to highlight in fetchmail-mode" )
(unless fetchmail-font-lock-keywords
(setq fetchmail-font-lock-keywords
(list (list (concat "\\b" (regexp-opt
fetchmail-keywords t) "\\b")
0 'font-lock-keyword-face ))))
(defun fetchmail-complete ()
"Tab completion for fetchmail-mode"
(interactive)
(let* ((end (point))
(beg (save-excursion
(skip-syntax-backward "w")
(point)))
(pattern (buffer-substring beg end))
(table fetchmail-keyword-table)
(completion (try-completion pattern table)))
(cond ((eq completion t))
((null completion)
(error "Can't find completion for \"%s\"" pattern))
((not (string-equal pattern completion))
(delete-region beg end)
(insert completion))
(t
(message "Making completion list...")
(let ((list (all-completions pattern table)))
(if (fboundp 'prettify)
(setq list (funcall 'prettify list)))
(with-output-to-temp-buffer "*Help*"
(display-completion-list list)))
(message "Making completion list...%s" "done")))))
(defun fetchmail-mode ()
"Mode for editing .fetchmailrc files"
(interactive)
(kill-all-local-variables)
(use-local-map fetchmail-mode-map) (setq mode-name "Fetchmail") (setq major-mode 'fetchmail-mode) (run-hooks 'fetchmail-mode-hook) (set-syntax-table fetchmail-mode-syntax-table)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(fetchmail-font-lock-keywords nil t))
(setq comment-start "#")
)
(provide 'fetchmail-mode)