1 ;; fetchmail-mode.el -*- Emacs-Lisp -*-
3 ;; Mode for editing .fetchmailrc files
5 ;; Created: <Mon Oct 30 20:13:15 EST 2000>
6 ;; Time-stamp: <17.02.2001 17:59:43>
8 ;; Keywords: fetchmail,config
9 ;; Author: Alex Shinn <foof@debian.org>
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2 of
14 ;; the License, or (at your option) any later version.
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public
22 ;; License along with this program; if not, write to the Free
23 ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 ;; This file provides a major mode for editing .fetchmailrc files.
29 ;; It offers syntax highlighting and indentation.
31 ;; To use it, put the following in your .emacs:
33 ;; (autoload 'fetchmail-mode "fetchmail-mode.el" "Mode for editing .fetchmailrc files" t)
35 ;; You may also want something like:
37 ;; (setq auto-mode-alist
38 ;; (append '(("\..fetchmailrc$" . fetchmail-mode))
41 ;; Create mode-specific tables.
42 (defvar fetchmail-mode-syntax-table nil
43 "Syntax table used while in fetchmail-mode" )
44 (if fetchmail-mode-syntax-table
45 () ; Do not change the table if it is already set up.
46 (setq fetchmail-mode-syntax-table (make-syntax-table))
47 (modify-syntax-entry ?\\ "\\ " fetchmail-mode-syntax-table)
48 (modify-syntax-entry ?\, "." fetchmail-mode-syntax-table)
49 (modify-syntax-entry ?\: "." fetchmail-mode-syntax-table)
50 (modify-syntax-entry ?\; "." fetchmail-mode-syntax-table)
51 (modify-syntax-entry ?\" "\"" fetchmail-mode-syntax-table)
52 (modify-syntax-entry ?\' "\"" fetchmail-mode-syntax-table)
53 (modify-syntax-entry ?\n "> " fetchmail-mode-syntax-table)
54 (modify-syntax-entry ?\# "< " fetchmail-mode-syntax-table)
55 (modify-syntax-entry ?\( "() " fetchmail-mode-syntax-table)
56 (modify-syntax-entry ?\) ")( " fetchmail-mode-syntax-table)
57 (modify-syntax-entry ?\[ "(] " fetchmail-mode-syntax-table)
58 (modify-syntax-entry ?\] ")[ " fetchmail-mode-syntax-table)
59 (modify-syntax-entry ?\{ "(} " fetchmail-mode-syntax-table)
60 (modify-syntax-entry ?\} "){ " fetchmail-mode-syntax-table)
63 (defvar fetchmail-mode-map nil
64 "Keymap used in fetchmail-mode" )
66 (if fetchmail-mode-map nil
67 (setq fetchmail-mode-map (make-sparse-keymap))
68 (define-key fetchmail-mode-map "\t" 'fetchmail-complete)
69 (define-key fetchmail-mode-map "\C-c\C-c" 'comment-region) )
70 (defvar fetchmail-mode-hook nil
71 "Hooks to run in fetchmail-mode" )
73 (defvar fetchmail-keywords nil
74 "Keywords used for fetchmail-mode" )
76 (unless fetchmail-keywords
77 (setq fetchmail-keywords
78 '("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")))
80 (defvar fetchmail-keyword-table nil
81 "Completion table for fetchmail-mode" )
82 (unless fetchmail-keyword-table
83 (setq fetchmail-keyword-table (make-vector 8 0))
84 (mapcar (lambda (x) (intern x fetchmail-keyword-table))
87 (defvar fetchmail-font-lock-keywords nil
88 "Default expressions to highlight in fetchmail-mode" )
90 (unless fetchmail-font-lock-keywords
91 (setq fetchmail-font-lock-keywords
92 (list (list (concat "\\b" (regexp-opt
93 fetchmail-keywords t) "\\b")
94 0 'font-lock-keyword-face ))))
96 (defun fetchmail-complete ()
97 "Tab completion for fetchmail-mode"
101 (skip-syntax-backward "w")
103 (pattern (buffer-substring beg end))
104 (table fetchmail-keyword-table)
105 (completion (try-completion pattern table)))
106 (cond ((eq completion t))
108 (error "Can't find completion for \"%s\"" pattern))
109 ((not (string-equal pattern completion))
110 (delete-region beg end)
113 (message "Making completion list...")
114 (let ((list (all-completions pattern table)))
115 (if (fboundp 'prettify)
116 (setq list (funcall 'prettify list)))
117 (with-output-to-temp-buffer "*Help*"
118 (display-completion-list list)))
119 (message "Making completion list...%s" "done")))))
122 (defun fetchmail-mode ()
123 "Mode for editing .fetchmailrc files"
125 (kill-all-local-variables)
126 (use-local-map fetchmail-mode-map) ; This provides the local keymap.
127 (setq mode-name "Fetchmail") ; This name goes into the modeline.
128 (setq major-mode 'fetchmail-mode) ; Used by `describe-mode'
129 (run-hooks 'fetchmail-mode-hook) ; Run each time mode is called
130 (set-syntax-table fetchmail-mode-syntax-table)
134 (make-local-variable 'font-lock-defaults)
135 (setq font-lock-defaults '(fetchmail-font-lock-keywords nil t))
137 (setq comment-start "#")
142 (provide 'fetchmail-mode)