annotate lisp/org/org-complete.el @ 112395:f1de024f822c

* nsterm.m (keyDown): If ns_right_alternate_modifier is Qleft, check if ns_alternate_modifier is none.
author Jan D. <jan.h.d@swipnet.se>
date Fri, 21 Jan 2011 09:35:30 +0100
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111880
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
1 ;;; org-complete.el --- In-buffer completion code
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
2
112275
6378d1b57038 Add 2011 to remaining FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 111880
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
111880
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
4 ;; Free Software Foundation, Inc.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
5 ;;
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
7 ;; John Wiegley <johnw at gnu dot org>
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
8 ;; Keywords: outlines, hypermedia, calendar, wp
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
9 ;; Homepage: http://orgmode.org
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
10 ;; Version: 7.4
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
11 ;;
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
13 ;;
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
17 ;; (at your option) any later version.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
18
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
22 ;; GNU General Public License for more details.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
23
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
27 ;;
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
28 ;;; Code:
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
29
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
30 ;;;; Require other packages
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
31
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
32 (eval-when-compile
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
33 (require 'cl))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
34
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
35 (require 'org-macs)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
36 (require 'pcomplete)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
37
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
38 (declare-function org-split-string "org" (string &optional separators))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
39 (declare-function org-get-current-options "org-exp" ())
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
40 (declare-function org-make-org-heading-search-string "org"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
41 (&optional string heading))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
42 (declare-function org-get-buffer-tags "org" ())
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
43 (declare-function org-get-tags "org" ())
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
44 (declare-function org-buffer-property-keys "org"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
45 (&optional include-specials include-defaults include-columns))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
46 (declare-function org-entry-properties "org" (&optional pom which specific))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
47
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
48 ;;;; Customization variables
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
49
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
50 (defgroup org-complete nil
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
51 "Outline-based notes management and organizer."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
52 :tag "Org"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
53 :group 'org)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
54
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
55 (defun org-thing-at-point ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
56 "Examine the thing at point and let the caller know what it is.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
57 The return value is a string naming the thing at point."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
58 (let ((beg1 (save-excursion
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
59 (skip-chars-backward (org-re "[:alnum:]_@"))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
60 (point)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
61 (beg (save-excursion
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
62 (skip-chars-backward "a-zA-Z0-9_:$")
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
63 (point)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
64 (line-to-here (buffer-substring (point-at-bol) (point))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
65 (cond
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
66 ((string-match "\\`[ \t]*#\\+begin: clocktable[ \t]+" line-to-here)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
67 (cons "block-option" "clocktable"))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
68 ((string-match "\\`[ \t]*#\\+begin_src[ \t]+" line-to-here)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
69 (cons "block-option" "src"))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
70 ((save-excursion
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
71 (re-search-backward "^[ \t]*#\\+\\([A-Z_]+\\):.*"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
72 (line-beginning-position) t))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
73 (cons "file-option" (match-string-no-properties 1)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
74 ((string-match "\\`[ \t]*#\\+[a-zA-Z]*\\'" line-to-here)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
75 (cons "file-option" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
76 ((equal (char-before beg) ?\[)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
77 (cons "link" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
78 ((equal (char-before beg) ?\\)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
79 (cons "tex" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
80 ((string-match "\\`\\*+[ \t]+\\'"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
81 (buffer-substring (point-at-bol) beg))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
82 (cons "todo" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
83 ((equal (char-before beg) ?*)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
84 (cons "searchhead" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
85 ((and (equal (char-before beg1) ?:)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
86 (equal (char-after (point-at-bol)) ?*))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
87 (cons "tag" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
88 ((and (equal (char-before beg1) ?:)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
89 (not (equal (char-after (point-at-bol)) ?*)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
90 (cons "prop" nil))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
91 (t nil))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
92
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
93 (defun org-command-at-point ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
94 "Return the qualified name of the Org completion entity at point.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
95 When completing for #+STARTUP, for example, this function returns
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
96 \"file-option/startup\"."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
97 (let ((thing (org-thing-at-point)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
98 (cond
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
99 ((string= "file-option" (car thing))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
100 (concat (car thing) "/" (downcase (cdr thing))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
101 ((string= "block-option" (car thing))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
102 (concat (car thing) "/" (downcase (cdr thing))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
103 (t
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
104 (car thing)))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
105
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
106 (defun org-parse-arguments ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
107 "Parse whitespace separated arguments in the current region."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
108 (let ((begin (line-beginning-position))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
109 (end (line-end-position))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
110 begins args)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
111 (save-restriction
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
112 (narrow-to-region begin end)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
113 (save-excursion
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
114 (goto-char (point-min))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
115 (while (not (eobp))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
116 (skip-chars-forward " \t\n[")
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
117 (setq begins (cons (point) begins))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
118 (skip-chars-forward "^ \t\n[")
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
119 (setq args (cons (buffer-substring-no-properties
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
120 (car begins) (point))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
121 args)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
122 (cons (reverse args) (reverse begins))))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
123
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
124
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
125 (defun org-complete-initial ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
126 "Calls the right completion function for first argument completions."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
127 (ignore
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
128 (funcall (or (pcomplete-find-completion-function
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
129 (car (org-thing-at-point)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
130 pcomplete-default-completion-function))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
131
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
132 (defvar org-additional-option-like-keywords)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
133 (defun pcomplete/org-mode/file-option ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
134 "Complete against all valid file options."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
135 (require 'org-exp)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
136 (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
137 (org-complete-case-double
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
138 (mapcar (lambda (x)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
139 (if (= ?: (aref x (1- (length x))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
140 (concat x " ")
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
141 x))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
142 (delq nil
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
143 (pcomplete-uniqify-list
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
144 (append
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
145 (mapcar (lambda (x)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
146 (if (string-match "^#\\+\\([A-Z_]+:?\\)" x)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
147 (match-string 1 x)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
148 (org-split-string (org-get-current-options) "\n"))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
149 org-additional-option-like-keywords)))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
150 (substring pcomplete-stub 2)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
151
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
152 (defvar org-startup-options)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
153 (defun pcomplete/org-mode/file-option/startup ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
154 "Complete arguments for the #+STARTUP file option."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
155 (while (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
156 (let ((opts (pcomplete-uniqify-list
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
157 (mapcar 'car org-startup-options))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
158 ;; Some options are mutually exclusive, and shouldn't be completed
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
159 ;; against if certain other options have already been seen.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
160 (dolist (arg pcomplete-args)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
161 (cond
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
162 ((string= arg "hidestars")
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
163 (setq opts (delete "showstars" opts)))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
164 opts))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
165
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
166 (defun pcomplete/org-mode/file-option/bind ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
167 "Complete arguments for the #+BIND file option, which are variable names"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
168 (let (vars)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
169 (mapatoms
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
170 (lambda (a) (if (boundp a) (setq vars (cons (symbol-name a) vars)))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
171 (pcomplete-here vars)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
172
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
173 (defvar org-link-abbrev-alist-local)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
174 (defvar org-link-abbrev-alist)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
175 (defun pcomplete/org-mode/link ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
176 "Complete against defined #+LINK patterns."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
177 (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
178 (pcomplete-uniqify-list (append (mapcar 'car org-link-abbrev-alist-local)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
179 (mapcar 'car org-link-abbrev-alist)))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
180
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
181 (defvar org-entities)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
182 (defun pcomplete/org-mode/tex ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
183 "Complete against TeX-style HTML entity names."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
184 (require 'org-entities)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
185 (while (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
186 (pcomplete-uniqify-list (remove nil (mapcar 'car-safe org-entities)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
187 (substring pcomplete-stub 1))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
188
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
189 (defvar org-todo-keywords-1)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
190 (defun pcomplete/org-mode/todo ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
191 "Complete against known TODO keywords."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
192 (pcomplete-here (pcomplete-uniqify-list org-todo-keywords-1)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
193
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
194 (defvar org-todo-line-regexp)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
195 (defun pcomplete/org-mode/searchhead ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
196 "Complete against all headings.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
197 This needs more work, to handle headings with lots of spaces in them."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
198 (while
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
199 (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
200 (save-excursion
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
201 (goto-char (point-min))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
202 (let (tbl)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
203 (while (re-search-forward org-todo-line-regexp nil t)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
204 (push (org-make-org-heading-search-string
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
205 (match-string-no-properties 3) t)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
206 tbl))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
207 (pcomplete-uniqify-list tbl)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
208 (substring pcomplete-stub 1))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
209
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
210 (defvar org-tag-alist)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
211 (defun pcomplete/org-mode/tag ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
212 "Complete a tag name. Omit tags already set."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
213 (while (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
214 (mapcar (lambda (x)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
215 (concat x ":"))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
216 (let ((lst (pcomplete-uniqify-list
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
217 (or (remove
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
218 nil
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
219 (mapcar (lambda (x)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
220 (and (stringp (car x)) (car x)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
221 org-tag-alist))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
222 (mapcar 'car (org-get-buffer-tags))))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
223 (dolist (tag (org-get-tags))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
224 (setq lst (delete tag lst)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
225 lst))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
226 (and (string-match ".*:" pcomplete-stub)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
227 (substring pcomplete-stub (match-end 0))))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
228
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
229 (defun pcomplete/org-mode/prop ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
230 "Complete a property name. Omit properties already set."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
231 (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
232 (mapcar (lambda (x)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
233 (concat x ": "))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
234 (let ((lst (pcomplete-uniqify-list
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
235 (org-buffer-property-keys nil t t))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
236 (dolist (prop (org-entry-properties))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
237 (setq lst (delete (car prop) lst)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
238 lst))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
239 (substring pcomplete-stub 1)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
240
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
241 (defun pcomplete/org-mode/block-option/src ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
242 "Complete the arguments of a begin_src block.
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
243 Complete a language in the first field, the header arguments and switches."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
244 (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
245 (mapcar
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
246 (lambda(x) (symbol-name (nth 3 x)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
247 (cdr (car (cdr (memq :key-type (plist-get
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
248 (symbol-plist
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
249 'org-babel-load-languages)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
250 'custom-type)))))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
251 (while (pcomplete-here
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
252 '("-n" "-r" "-l"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
253 ":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
254 ":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
255 ":session" ":shebang" ":tangle" ":var"))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
256
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
257 (defun pcomplete/org-mode/block-option/clocktable ()
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
258 "Complete keywords in a clocktable line"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
259 (while (pcomplete-here '(":maxlevel" ":scope"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
260 ":tstart" ":tend" ":block" ":step"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
261 ":stepskip0" ":fileskip0"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
262 ":emphasize" ":link" ":narrow" ":indent"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
263 ":tcolumns" ":level" ":compact" ":timestamp"
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
264 ":formula" ":formatter"))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
265
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
266 (defun org-complete-case-double (list)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
267 "Return list with both upcase and downcase version of all strings in LIST."
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
268 (let (e res)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
269 (while (setq e (pop list))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
270 (setq res (cons (downcase e) (cons (upcase e) res))))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
271 (nreverse res)))
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
272
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
273 ;;;; Finish up
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
274
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
275 (provide 'org-complete)
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
276
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
277
a7740098b594 Update to Org mode 7.4
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
278 ;;; org-complete.el ends here