2016-06-21 17:14:49 -04:00
|
|
|
|
;;; org-pcomplete.el --- In-buffer Completion Code -*- lexical-binding: t; -*-
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
2019-01-01 05:50:56 -05:00
|
|
|
|
;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
|
2009-10-20 04:34:09 -04:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
|
|
|
|
;; John Wiegley <johnw at gnu dot org>
|
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
2018-01-16 11:22:00 -05:00
|
|
|
|
;; Homepage: https://orgmode.org
|
2009-10-20 04:34:09 -04:00
|
|
|
|
;;
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 18:52:52 -04:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2009-10-20 04:34:09 -04:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;;;; Require other packages
|
|
|
|
|
|
|
|
|
|
(require 'org-macs)
|
2012-08-10 09:32:24 -04:00
|
|
|
|
(require 'org-compat)
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(require 'pcomplete)
|
|
|
|
|
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(declare-function org-at-heading-p "org" (&optional ignored))
|
|
|
|
|
(declare-function org-before-first-heading-p "org" ())
|
2017-09-16 08:14:46 -04:00
|
|
|
|
(declare-function org-buffer-property-keys "org" (&optional specials defaults columns))
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(declare-function org-element-at-point "org-element" ())
|
|
|
|
|
(declare-function org-element-property "org-element" property element)
|
|
|
|
|
(declare-function org-element-type "org-element" (element))
|
|
|
|
|
(declare-function org-end-of-meta-data "org" (&optional full))
|
2016-05-15 17:42:47 -04:00
|
|
|
|
(declare-function org-entry-properties "org" (&optional pom which))
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(declare-function org-export-backend-options "ox" (cl-x) t)
|
|
|
|
|
(declare-function org-get-buffer-tags "org" ())
|
|
|
|
|
(declare-function org-get-export-keywords "org" ())
|
|
|
|
|
(declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment))
|
|
|
|
|
(declare-function org-get-tags "org" (&optional pos local))
|
|
|
|
|
(declare-function org-make-org-heading-search-string "org" (&optional string))
|
2016-04-18 13:34:08 -04:00
|
|
|
|
(declare-function org-tag-alist-to-string "org" (alist &optional skip-key))
|
2010-12-03 04:20:41 -05:00
|
|
|
|
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(defvar org-current-tag-alist)
|
|
|
|
|
(defvar org-default-priority)
|
2012-03-19 16:38:12 -04:00
|
|
|
|
(defvar org-drawer-regexp)
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(defvar org-element-affiliated-keywords)
|
|
|
|
|
(defvar org-entities)
|
|
|
|
|
(defvar org-export-default-language)
|
|
|
|
|
(defvar org-export-exclude-tags)
|
|
|
|
|
(defvar org-export-select-tags)
|
|
|
|
|
(defvar org-file-tags)
|
|
|
|
|
(defvar org-highest-priority)
|
|
|
|
|
(defvar org-link-abbrev-alist)
|
|
|
|
|
(defvar org-link-abbrev-alist-local)
|
|
|
|
|
(defvar org-lowest-priority)
|
|
|
|
|
(defvar org-options-keywords)
|
|
|
|
|
(defvar org-outline-regexp)
|
2012-03-19 16:38:12 -04:00
|
|
|
|
(defvar org-property-re)
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(defvar org-startup-options)
|
2018-11-30 15:20:39 -05:00
|
|
|
|
(defvar org-tag-re)
|
2018-10-18 09:49:32 -04:00
|
|
|
|
(defvar org-time-stamp-formats)
|
|
|
|
|
(defvar org-todo-keywords-1)
|
|
|
|
|
(defvar org-todo-line-regexp)
|
|
|
|
|
|
2018-10-18 12:09:41 -04:00
|
|
|
|
|
|
|
|
|
;;; Internal Functions
|
2012-03-19 16:38:12 -04:00
|
|
|
|
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(defun org-thing-at-point ()
|
|
|
|
|
"Examine the thing at point and let the caller know what it is.
|
|
|
|
|
The return value is a string naming the thing at point."
|
2018-10-18 09:44:19 -04:00
|
|
|
|
(let ((line-to-here (org-current-line-string t))
|
|
|
|
|
(case-fold-search t))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(cond
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Parameters on a clock table opening line.
|
|
|
|
|
((org-match-line "[ \t]*#\\+BEGIN: clocktable[ \t]")
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(cons "block-option" "clocktable"))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Flags and parameters on a source block opening line.
|
|
|
|
|
((org-match-line "[ \t]*#\\+BEGIN_SRC[ \t]")
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(cons "block-option" "src"))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Value for a known keyword.
|
|
|
|
|
((org-match-line "[ \t]*#\\+\\(\\S-+\\):")
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(cons "file-option" (match-string-no-properties 1)))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Keyword name.
|
|
|
|
|
((and (org-match-line "[ \t]*#\\+[a-zA-Z_]*$")
|
|
|
|
|
(looking-at-p "[ \t]*$"))
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(cons "file-option" nil))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Link abbreviation.
|
|
|
|
|
((save-excursion
|
|
|
|
|
(skip-chars-backward "A-Za-z0-9-_")
|
|
|
|
|
(and (eq ?\[ (char-before))
|
|
|
|
|
(eq ?\[ (char-before (1- (point))))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(cons "link" nil))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Entities. Some of them accept numbers, but only at their end.
|
|
|
|
|
;; So, we first skip numbers, then letters.
|
|
|
|
|
((eq ?\\ (save-excursion
|
|
|
|
|
(skip-chars-backward "0-9")
|
|
|
|
|
(skip-chars-backward "a-zA-Z")
|
|
|
|
|
(char-before)))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(cons "tex" nil))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Tags on a headline.
|
2018-11-24 20:01:41 -05:00
|
|
|
|
((and (org-match-line
|
|
|
|
|
(format "\\*+ \\(?:.+? \\)?\\(:\\)\\(\\(?::\\|%s\\)+\\)?[ \t]*$"
|
|
|
|
|
org-tag-re))
|
|
|
|
|
(or (org-point-in-group (point) 2)
|
|
|
|
|
(= (point) (match-end 1))))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
(cons "tag" nil))
|
|
|
|
|
;; TODO keywords on an empty headline.
|
|
|
|
|
((and (string-match "^\\*+ +\\S-*$" line-to-here)
|
|
|
|
|
(looking-at-p "[ \t]*$"))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(cons "todo" nil))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Heading after a star for search strings or links.
|
|
|
|
|
((save-excursion
|
|
|
|
|
(skip-chars-backward "^*" (line-beginning-position))
|
|
|
|
|
(and (eq ?* (char-before))
|
|
|
|
|
(eq (char-before (1- (point))) '?\[)
|
|
|
|
|
(eq (char-before (- (point) 2)) '?\[)))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(cons "searchhead" nil))
|
2018-10-18 09:44:19 -04:00
|
|
|
|
;; Property or drawer name, depending on point. If point is at
|
|
|
|
|
;; a valid location for a node property, offer completion on all
|
|
|
|
|
;; node properties in the buffer. Otherwise, offer completion on
|
|
|
|
|
;; all drawer names, including "PROPERTIES".
|
|
|
|
|
((and (string-match "^[ \t]*:\\S-*$" line-to-here)
|
|
|
|
|
(looking-at-p "[ \t]*$"))
|
|
|
|
|
(let ((origin (line-beginning-position)))
|
|
|
|
|
(if (org-before-first-heading-p) (cons "drawer" nil)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(org-end-of-meta-data)
|
|
|
|
|
(if (or (= origin (point))
|
|
|
|
|
(not (org-match-line "[ \t]*:PROPERTIES:[ \t]*$")))
|
|
|
|
|
(cons "drawer" nil)
|
|
|
|
|
(while (org-match-line org-property-re)
|
|
|
|
|
(forward-line))
|
|
|
|
|
(if (= origin (point)) (cons "prop" nil)
|
|
|
|
|
(cons "drawer" nil)))))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(t nil))))
|
|
|
|
|
|
2018-10-18 12:09:41 -04:00
|
|
|
|
(defun org-pcomplete-case-double (list)
|
|
|
|
|
"Return list with both upcase and downcase version of all strings in LIST."
|
|
|
|
|
(let (e res)
|
|
|
|
|
(while (setq e (pop list))
|
|
|
|
|
(setq res (cons (downcase e) (cons (upcase e) res))))
|
|
|
|
|
(nreverse res)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Completion API
|
|
|
|
|
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(defun org-command-at-point ()
|
|
|
|
|
"Return the qualified name of the Org completion entity at point.
|
|
|
|
|
When completing for #+STARTUP, for example, this function returns
|
2010-11-18 01:48:50 -05:00
|
|
|
|
\"file-option/startup\"."
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(let ((thing (org-thing-at-point)))
|
|
|
|
|
(cond
|
|
|
|
|
((string= "file-option" (car thing))
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(concat (car thing)
|
|
|
|
|
(and (cdr thing) (concat "/" (downcase (cdr thing))))))
|
2010-11-18 01:48:50 -05:00
|
|
|
|
((string= "block-option" (car thing))
|
|
|
|
|
(concat (car thing) "/" (downcase (cdr thing))))
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(t (car thing)))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
|
|
|
|
(defun org-parse-arguments ()
|
|
|
|
|
"Parse whitespace separated arguments in the current region."
|
|
|
|
|
(let ((begin (line-beginning-position))
|
|
|
|
|
(end (line-end-position))
|
|
|
|
|
begins args)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region begin end)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(skip-chars-forward " \t\n[")
|
|
|
|
|
(setq begins (cons (point) begins))
|
|
|
|
|
(skip-chars-forward "^ \t\n[")
|
|
|
|
|
(setq args (cons (buffer-substring-no-properties
|
|
|
|
|
(car begins) (point))
|
|
|
|
|
args)))
|
|
|
|
|
(cons (reverse args) (reverse begins))))))
|
|
|
|
|
|
2011-01-31 12:40:05 -05:00
|
|
|
|
(defun org-pcomplete-initial ()
|
2009-10-20 04:34:09 -04:00
|
|
|
|
"Calls the right completion function for first argument completions."
|
|
|
|
|
(ignore
|
|
|
|
|
(funcall (or (pcomplete-find-completion-function
|
|
|
|
|
(car (org-thing-at-point)))
|
|
|
|
|
pcomplete-default-completion-function))))
|
|
|
|
|
|
2018-10-18 12:09:41 -04:00
|
|
|
|
|
|
|
|
|
;;; Completion functions
|
|
|
|
|
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(defun pcomplete/org-mode/file-option ()
|
|
|
|
|
"Complete against all valid file options."
|
2013-02-16 02:26:08 -05:00
|
|
|
|
(require 'org-element)
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(pcomplete-here
|
2011-01-31 12:40:05 -05:00
|
|
|
|
(org-pcomplete-case-double
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(append (mapcar (lambda (keyword) (concat keyword " "))
|
|
|
|
|
org-options-keywords)
|
|
|
|
|
(mapcar (lambda (keyword) (concat keyword ": "))
|
|
|
|
|
org-element-affiliated-keywords)
|
|
|
|
|
(let (block-names)
|
2016-01-02 07:21:39 -05:00
|
|
|
|
(dolist (name
|
|
|
|
|
'("CENTER" "COMMENT" "EXAMPLE" "EXPORT" "QUOTE" "SRC"
|
|
|
|
|
"VERSE")
|
|
|
|
|
block-names)
|
|
|
|
|
(push (format "END_%s" name) block-names)
|
|
|
|
|
(push (concat "BEGIN_"
|
|
|
|
|
name
|
|
|
|
|
;; Since language is compulsory in
|
|
|
|
|
;; export blocks source blocks, add
|
|
|
|
|
;; a space.
|
|
|
|
|
(and (member name '("EXPORT" "SRC")) " "))
|
|
|
|
|
block-names)
|
|
|
|
|
(push (format "ATTR_%s: " name) block-names)))
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(mapcar (lambda (keyword) (concat keyword ": "))
|
|
|
|
|
(org-get-export-keywords))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(substring pcomplete-stub 2)))
|
2012-03-19 16:38:12 -04:00
|
|
|
|
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(defun pcomplete/org-mode/file-option/author ()
|
|
|
|
|
"Complete arguments for the #+AUTHOR file option."
|
|
|
|
|
(pcomplete-here (list user-full-name)))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/date ()
|
|
|
|
|
"Complete arguments for the #+DATE file option."
|
|
|
|
|
(pcomplete-here (list (format-time-string (car org-time-stamp-formats)))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/email ()
|
|
|
|
|
"Complete arguments for the #+EMAIL file option."
|
|
|
|
|
(pcomplete-here (list user-mail-address)))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/exclude_tags ()
|
|
|
|
|
"Complete arguments for the #+EXCLUDE_TAGS file option."
|
|
|
|
|
(require 'ox)
|
|
|
|
|
(pcomplete-here
|
|
|
|
|
(and org-export-exclude-tags
|
|
|
|
|
(list (mapconcat 'identity org-export-exclude-tags " ")))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/filetags ()
|
|
|
|
|
"Complete arguments for the #+FILETAGS file option."
|
|
|
|
|
(pcomplete-here (and org-file-tags (mapconcat 'identity org-file-tags " "))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/language ()
|
|
|
|
|
"Complete arguments for the #+LANGUAGE file option."
|
|
|
|
|
(require 'ox)
|
|
|
|
|
(pcomplete-here
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(pcomplete-uniquify-list
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(list org-export-default-language "en"))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/priorities ()
|
|
|
|
|
"Complete arguments for the #+PRIORITIES file option."
|
|
|
|
|
(pcomplete-here (list (format "%c %c %c"
|
|
|
|
|
org-highest-priority
|
|
|
|
|
org-lowest-priority
|
|
|
|
|
org-default-priority))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/select_tags ()
|
|
|
|
|
"Complete arguments for the #+SELECT_TAGS file option."
|
|
|
|
|
(require 'ox)
|
|
|
|
|
(pcomplete-here
|
|
|
|
|
(and org-export-select-tags
|
|
|
|
|
(list (mapconcat 'identity org-export-select-tags " ")))))
|
|
|
|
|
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(defun pcomplete/org-mode/file-option/startup ()
|
2009-10-20 04:34:09 -04:00
|
|
|
|
"Complete arguments for the #+STARTUP file option."
|
|
|
|
|
(while (pcomplete-here
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(let ((opts (pcomplete-uniquify-list
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(mapcar 'car org-startup-options))))
|
|
|
|
|
;; Some options are mutually exclusive, and shouldn't be completed
|
|
|
|
|
;; against if certain other options have already been seen.
|
|
|
|
|
(dolist (arg pcomplete-args)
|
|
|
|
|
(cond
|
|
|
|
|
((string= arg "hidestars")
|
|
|
|
|
(setq opts (delete "showstars" opts)))))
|
|
|
|
|
opts))))
|
|
|
|
|
|
2013-02-13 17:52:57 -05:00
|
|
|
|
(defun pcomplete/org-mode/file-option/tags ()
|
|
|
|
|
"Complete arguments for the #+TAGS file option."
|
|
|
|
|
(pcomplete-here
|
2016-04-18 13:34:08 -04:00
|
|
|
|
(list (org-tag-alist-to-string org-current-tag-alist))))
|
2013-02-13 17:52:57 -05:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/title ()
|
|
|
|
|
"Complete arguments for the #+TITLE file option."
|
|
|
|
|
(pcomplete-here
|
|
|
|
|
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
|
|
|
|
(list (or (and visited-file
|
|
|
|
|
(file-name-sans-extension
|
|
|
|
|
(file-name-nondirectory visited-file)))
|
|
|
|
|
(buffer-name (buffer-base-buffer)))))))
|
2013-02-13 08:29:31 -05:00
|
|
|
|
|
2013-07-03 17:10:08 -04:00
|
|
|
|
|
2012-08-01 11:19:13 -04:00
|
|
|
|
(defun pcomplete/org-mode/file-option/options ()
|
|
|
|
|
"Complete arguments for the #+OPTIONS file option."
|
2013-01-27 18:09:31 -05:00
|
|
|
|
(while (pcomplete-here
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(pcomplete-uniquify-list
|
2013-01-27 18:09:31 -05:00
|
|
|
|
(append
|
|
|
|
|
;; Hard-coded OPTION items always available.
|
|
|
|
|
'("H:" "\\n:" "num:" "timestamp:" "arch:" "author:" "c:"
|
|
|
|
|
"creator:" "date:" "d:" "email:" "*:" "e:" "::" "f:"
|
|
|
|
|
"inline:" "tex:" "p:" "pri:" "':" "-:" "stat:" "^:" "toc:"
|
|
|
|
|
"|:" "tags:" "tasks:" "<:" "todo:")
|
|
|
|
|
;; OPTION items from registered back-ends.
|
|
|
|
|
(let (items)
|
2016-06-23 08:18:38 -04:00
|
|
|
|
(dolist (backend (bound-and-true-p
|
2015-04-22 04:24:02 -04:00
|
|
|
|
org-export-registered-backends))
|
2013-07-03 17:10:08 -04:00
|
|
|
|
(dolist (option (org-export-backend-options backend))
|
2013-01-27 18:09:31 -05:00
|
|
|
|
(let ((item (nth 2 option)))
|
|
|
|
|
(when item (push (concat item ":") items)))))
|
|
|
|
|
items))))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/infojs_opt ()
|
|
|
|
|
"Complete arguments for the #+INFOJS_OPT file option."
|
|
|
|
|
(while (pcomplete-here
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(pcomplete-uniquify-list
|
2013-01-27 18:09:31 -05:00
|
|
|
|
(mapcar (lambda (item) (format "%s:" (car item)))
|
2016-06-23 08:18:38 -04:00
|
|
|
|
(bound-and-true-p org-html-infojs-opts-table))))))
|
2012-08-01 11:19:13 -04:00
|
|
|
|
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(defun pcomplete/org-mode/file-option/bind ()
|
2012-07-30 04:08:15 -04:00
|
|
|
|
"Complete arguments for the #+BIND file option, which are variable names."
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(let (vars)
|
|
|
|
|
(mapatoms
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(lambda (a) (when (boundp a) (setq vars (cons (symbol-name a) vars)))))
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(pcomplete-here vars)))
|
|
|
|
|
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(defun pcomplete/org-mode/link ()
|
|
|
|
|
"Complete against defined #+LINK patterns."
|
|
|
|
|
(pcomplete-here
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(pcomplete-uniquify-list
|
2011-01-17 06:51:43 -05:00
|
|
|
|
(copy-sequence
|
2018-10-18 09:46:53 -04:00
|
|
|
|
(mapcar (lambda (e) (concat (car e) ":"))
|
|
|
|
|
(append org-link-abbrev-alist-local
|
|
|
|
|
org-link-abbrev-alist))))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/tex ()
|
|
|
|
|
"Complete against TeX-style HTML entity names."
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(require 'org-entities)
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(while (pcomplete-here
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(pcomplete-uniquify-list (remove nil (mapcar 'car-safe org-entities)))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(substring pcomplete-stub 1))))
|
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/todo ()
|
|
|
|
|
"Complete against known TODO keywords."
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(pcomplete-here (pcomplete-uniquify-list (copy-sequence org-todo-keywords-1))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/searchhead ()
|
|
|
|
|
"Complete against all headings.
|
|
|
|
|
This needs more work, to handle headings with lots of spaces in them."
|
2018-10-18 09:47:56 -04:00
|
|
|
|
(while (pcomplete-here
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let (tbl)
|
|
|
|
|
(while (re-search-forward org-outline-regexp nil t)
|
|
|
|
|
(push (org-make-org-heading-search-string
|
|
|
|
|
(org-get-heading t t t t))
|
|
|
|
|
tbl))
|
|
|
|
|
(pcomplete-uniquify-list tbl)))
|
|
|
|
|
;; When completing a bracketed link, i.e., "[[*", argument
|
|
|
|
|
;; starts at the star, so remove this character.
|
|
|
|
|
(substring pcomplete-stub 1))))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/tag ()
|
|
|
|
|
"Complete a tag name. Omit tags already set."
|
|
|
|
|
(while (pcomplete-here
|
2016-04-17 11:00:14 -04:00
|
|
|
|
(mapcar (lambda (x) (concat x ":"))
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(let ((lst (pcomplete-uniquify-list
|
2016-04-17 11:00:14 -04:00
|
|
|
|
(or (remq
|
2010-11-18 01:48:50 -05:00
|
|
|
|
nil
|
2016-04-17 11:00:14 -04:00
|
|
|
|
(mapcar (lambda (x) (org-string-nw-p (car x)))
|
2016-04-18 13:34:08 -04:00
|
|
|
|
org-current-tag-alist))
|
2016-04-17 11:00:14 -04:00
|
|
|
|
(mapcar #'car (org-get-buffer-tags))))))
|
2018-04-18 11:28:52 -04:00
|
|
|
|
(dolist (tag (org-get-tags nil t))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(setq lst (delete tag lst)))
|
|
|
|
|
lst))
|
|
|
|
|
(and (string-match ".*:" pcomplete-stub)
|
2018-11-24 20:01:41 -05:00
|
|
|
|
(substring pcomplete-stub (match-end 0)))
|
|
|
|
|
t)))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
2018-10-18 11:03:15 -04:00
|
|
|
|
(defun pcomplete/org-mode/drawer ()
|
|
|
|
|
"Complete a drawer name, including \"PROPERTIES\"."
|
|
|
|
|
(pcomplete-here
|
|
|
|
|
(org-pcomplete-case-double
|
|
|
|
|
(mapcar (lambda (x) (concat x ":"))
|
|
|
|
|
(let ((names (list "PROPERTIES")))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (re-search-forward org-drawer-regexp nil t)
|
|
|
|
|
(let ((drawer (org-element-at-point)))
|
|
|
|
|
(when (memq (org-element-type drawer)
|
|
|
|
|
'(drawer property-drawer))
|
|
|
|
|
(push (org-element-property :drawer-name drawer) names)
|
|
|
|
|
(goto-char (org-element-property :end drawer))))))
|
|
|
|
|
(pcomplete-uniquify-list names))))
|
|
|
|
|
(substring pcomplete-stub 1))) ;remove initial colon
|
|
|
|
|
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(defun pcomplete/org-mode/prop ()
|
|
|
|
|
"Complete a property name. Omit properties already set."
|
|
|
|
|
(pcomplete-here
|
2018-10-18 09:45:14 -04:00
|
|
|
|
(org-pcomplete-case-double
|
|
|
|
|
(mapcar (lambda (x)
|
|
|
|
|
(concat x ": "))
|
|
|
|
|
(let ((lst (pcomplete-uniquify-list
|
|
|
|
|
(copy-sequence (org-buffer-property-keys nil t t)))))
|
|
|
|
|
(dolist (prop (org-entry-properties))
|
|
|
|
|
(setq lst (delete (car prop) lst)))
|
|
|
|
|
lst)))
|
2009-10-20 04:34:09 -04:00
|
|
|
|
(substring pcomplete-stub 1)))
|
|
|
|
|
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(defun pcomplete/org-mode/block-option/src ()
|
2018-09-20 05:23:49 -04:00
|
|
|
|
"Complete the arguments of a source block.
|
|
|
|
|
Complete a language in the first field, the header arguments and
|
|
|
|
|
switches."
|
2010-11-18 01:48:50 -05:00
|
|
|
|
(pcomplete-here
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda(x) (symbol-name (nth 3 x)))
|
|
|
|
|
(cdr (car (cdr (memq :key-type (plist-get
|
|
|
|
|
(symbol-plist
|
|
|
|
|
'org-babel-load-languages)
|
|
|
|
|
'custom-type)))))))
|
|
|
|
|
(while (pcomplete-here
|
|
|
|
|
'("-n" "-r" "-l"
|
|
|
|
|
":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
|
|
|
|
|
":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
|
2013-06-08 14:29:02 -04:00
|
|
|
|
":session" ":shebang" ":tangle" ":tangle-mode" ":var"))))
|
2010-11-18 01:48:50 -05:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/block-option/clocktable ()
|
2012-07-30 04:08:15 -04:00
|
|
|
|
"Complete keywords in a clocktable line."
|
2013-03-19 08:50:42 -04:00
|
|
|
|
(while (pcomplete-here '(":maxlevel" ":scope" ":lang"
|
2010-11-18 01:48:50 -05:00
|
|
|
|
":tstart" ":tend" ":block" ":step"
|
|
|
|
|
":stepskip0" ":fileskip0"
|
|
|
|
|
":emphasize" ":link" ":narrow" ":indent"
|
|
|
|
|
":tcolumns" ":level" ":compact" ":timestamp"
|
2013-03-19 08:50:42 -04:00
|
|
|
|
":formula" ":formatter" ":wstart" ":mstart"))))
|
2010-11-18 01:48:50 -05:00
|
|
|
|
|
2018-10-18 12:09:41 -04:00
|
|
|
|
|
|
|
|
|
;;; Finish up
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
2011-01-31 12:40:05 -05:00
|
|
|
|
(provide 'org-pcomplete)
|
2009-10-20 04:34:09 -04:00
|
|
|
|
|
2011-01-31 12:40:05 -05:00
|
|
|
|
;;; org-pcomplete.el ends here
|