1 ;;; lj-pcomplete.el --- programmable completion for ljupdate composition buffers
3 ;; Copyright (C) 2002, 2003, 2004, 2005 Edward O'Connor <ted@oconnor.cx>
5 ;; Author: Edward O'Connor <ted@oconnor.cx>
6 ;; Keywords: convenience
8 ;; This file is part of ljupdate, a LiveJournal client for Emacs.
10 ;; ljupdate is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or
13 ;; {at your option} any later version.
15 ;; ljupdate is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING, or type `C-h C-c'. If
22 ;; not, write to the Free Software Foundation at this address:
24 ;; Free Software Foundation
25 ;; 51 Franklin Street, Fifth Floor
26 ;; Boston, MA 02110-1301
39 (defun lj-pcomplete-setup ()
40 "Configure this buffer for programmable completion."
41 (set (make-local-variable 'pcomplete-termination-string
) "")
42 (set (make-local-variable 'pcomplete-ignore-case
) t
)
43 (set (make-local-variable 'pcomplete-use-paring
) nil
)
44 (set (make-local-variable 'pcomplete-parse-arguments-function
)
45 'lj-pcomplete-parse-header-arguments
)
46 (set (make-local-variable 'pcomplete-command-name-function
)
51 (defun pcomplete/lj-compose-header-mode
/Subject
()
52 "Attempt to complete the Subject header."
55 (defun pcomplete/lj-compose-header-mode
/Mood
()
56 "Attempt to complete the Mood header."
57 (pcomplete-here (sort (mapcar 'car
(lj-server-get (lj-this-server) :moods
))
61 (defun pcomplete/lj-compose-header-mode
/Server
()
62 "Attempt to complete the Server header."
63 (pcomplete-here (sort (lj-servers) 'string-lessp
)
66 (defun pcomplete/lj-compose-header-mode
/User
()
67 "Attempt to complete the User header."
68 (pcomplete-here (sort (lj-users (lj-this-server)) 'string-lessp
)
71 (defun pcomplete/lj-compose-header-mode
/Community
()
72 "Attempt to complete the Community header."
73 (pcomplete-here (sort (copy-list (lj-user-get (lj-this-server)
79 (defun pcomplete/lj-compose-header-mode
/Picture
()
80 "Attempt to complete the Picture header."
81 (pcomplete-here (sort (copy-list (lj-user-get (lj-this-server)
87 (defun pcomplete/lj-compose-header-mode
/Access
()
88 "Attempt to complete the Access header."
91 (list "public" "private" "friends")
93 (lj-user-get (lj-this-server)
99 ;; pcomplete support code
101 (defun lj-pcomplete-parse-header-arguments ()
102 "Return a list of parsed whitespace-separated arguments.
103 These are the words from the beginning of the line up to where point is
105 (let* ((start (save-excursion (beginning-of-line) (point)))
109 (if (< (skip-chars-backward " \t\n" start
) 0)
111 beginnings
(list end
)))
113 (while (< (skip-chars-backward "^ \t\n" start
) 0)
114 (setq beginnings
(cons (point) beginnings
)
115 args
(cons (buffer-substring-no-properties
118 (skip-chars-backward " \t\n" start
)
120 (cons args beginnings
)))
122 (provide 'lj-pcomplete
)
123 ;;; lj-pcomplete.el ends here