2016-06-21 21:14:49 +00:00
|
|
|
|
;;; org-pcomplete.el --- In-buffer Completion Code -*- lexical-binding: t; -*-
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
|
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
|
2009-10-20 08:34:09 +00:00
|
|
|
|
;;
|
2021-05-07 14:50:57 +00:00
|
|
|
|
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
|
2009-10-20 08:34:09 +00:00
|
|
|
|
;; John Wiegley <johnw at gnu dot org>
|
2023-12-30 17:01:48 +00:00
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, text
|
2021-09-26 07:44:29 +00:00
|
|
|
|
;; URL: https://orgmode.org
|
2009-10-20 08:34:09 +00: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 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2021-09-16 10:32:43 +00:00
|
|
|
|
|
2023-10-30 10:05:09 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2024-06-09 22:38:13 +00:00
|
|
|
|
;; This library implements completion support in Org mode buffers.
|
2023-10-30 10:05:09 +00:00
|
|
|
|
|
2009-10-20 08:34:09 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;;;; Require other packages
|
|
|
|
|
|
2022-08-04 13:53:05 +00:00
|
|
|
|
(require 'org-macs)
|
|
|
|
|
(org-assert-version)
|
|
|
|
|
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(require 'org-macs)
|
2012-08-10 13:32:24 +00:00
|
|
|
|
(require 'org-compat)
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(require 'pcomplete)
|
|
|
|
|
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(declare-function org-at-heading-p "org" (&optional ignored))
|
2020-06-03 14:52:20 +00:00
|
|
|
|
(declare-function org-babel-combine-header-arg-lists "ob-core" (original &rest others))
|
2022-10-18 15:34:18 +00:00
|
|
|
|
(declare-function org-babel-get-src-block-info "ob-core" (&optional no-eval datum))
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(declare-function org-before-first-heading-p "org" ())
|
2017-09-16 12:14:46 +00:00
|
|
|
|
(declare-function org-buffer-property-keys "org" (&optional specials defaults columns))
|
2022-01-06 17:39:05 +00:00
|
|
|
|
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
2023-10-07 13:25:08 +00:00
|
|
|
|
(declare-function org-element-property "org-element-ast" (property node &optional dflt force-undefer))
|
2023-05-03 14:26:41 +00:00
|
|
|
|
(declare-function org-element-end "org-element" (node))
|
2023-05-16 10:41:53 +00:00
|
|
|
|
(declare-function org-element-type-p "org-element-ast" (node types))
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(declare-function org-end-of-meta-data "org" (&optional full))
|
2016-05-15 21:42:47 +00:00
|
|
|
|
(declare-function org-entry-properties "org" (&optional pom which))
|
2018-10-18 13:49:32 +00: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))
|
2018-11-26 23:04:41 +00:00
|
|
|
|
(declare-function org-link-heading-search-string "ol" (&optional string))
|
2016-04-18 17:34:08 +00:00
|
|
|
|
(declare-function org-tag-alist-to-string "org" (alist &optional skip-key))
|
2022-11-13 22:53:53 +00:00
|
|
|
|
(declare-function org-time-stamp-format "org" (&optional with-time inactive custom))
|
2010-12-03 09:20:41 +00:00
|
|
|
|
|
2020-06-03 14:52:20 +00:00
|
|
|
|
(defvar org-babel-common-header-args-w-values)
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(defvar org-current-tag-alist)
|
2020-01-30 13:56:38 +00:00
|
|
|
|
(defvar org-priority-default)
|
2012-03-19 20:38:12 +00:00
|
|
|
|
(defvar org-drawer-regexp)
|
2018-10-18 13:49:32 +00: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)
|
2020-01-30 13:56:38 +00:00
|
|
|
|
(defvar org-priority-highest)
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(defvar org-link-abbrev-alist)
|
|
|
|
|
(defvar org-link-abbrev-alist-local)
|
2020-01-30 13:56:38 +00:00
|
|
|
|
(defvar org-priority-lowest)
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(defvar org-options-keywords)
|
|
|
|
|
(defvar org-outline-regexp)
|
2012-03-19 20:38:12 +00:00
|
|
|
|
(defvar org-property-re)
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(defvar org-startup-options)
|
2018-11-30 20:20:39 +00:00
|
|
|
|
(defvar org-tag-re)
|
2018-10-18 13:49:32 +00:00
|
|
|
|
(defvar org-todo-keywords-1)
|
|
|
|
|
(defvar org-todo-line-regexp)
|
|
|
|
|
|
2018-10-18 16:09:41 +00:00
|
|
|
|
|
|
|
|
|
;;; Internal Functions
|
2012-03-19 20:38:12 +00:00
|
|
|
|
|
2009-10-20 08:34:09 +00: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 13:44:19 +00:00
|
|
|
|
(let ((line-to-here (org-current-line-string t))
|
|
|
|
|
(case-fold-search t))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(cond
|
2018-10-18 13:44:19 +00:00
|
|
|
|
;; Parameters on a clock table opening line.
|
|
|
|
|
((org-match-line "[ \t]*#\\+BEGIN: clocktable[ \t]")
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(cons "block-option" "clocktable"))
|
2018-10-18 13:44:19 +00:00
|
|
|
|
;; Flags and parameters on a source block opening line.
|
|
|
|
|
((org-match-line "[ \t]*#\\+BEGIN_SRC[ \t]")
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(cons "block-option" "src"))
|
2018-10-18 13:44:19 +00:00
|
|
|
|
;; Value for a known keyword.
|
|
|
|
|
((org-match-line "[ \t]*#\\+\\(\\S-+\\):")
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(cons "file-option" (match-string-no-properties 1)))
|
2018-10-18 13:44:19 +00:00
|
|
|
|
;; Keyword name.
|
|
|
|
|
((and (org-match-line "[ \t]*#\\+[a-zA-Z_]*$")
|
|
|
|
|
(looking-at-p "[ \t]*$"))
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(cons "file-option" nil))
|
2018-10-18 13:44:19 +00:00
|
|
|
|
;; Link abbreviation.
|
|
|
|
|
((save-excursion
|
2019-03-20 01:45:17 +00:00
|
|
|
|
(skip-chars-backward "-A-Za-z0-9_")
|
2018-10-18 13:44:19 +00:00
|
|
|
|
(and (eq ?\[ (char-before))
|
|
|
|
|
(eq ?\[ (char-before (1- (point))))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(cons "link" nil))
|
2018-10-18 13:44:19 +00: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 08:34:09 +00:00
|
|
|
|
(cons "tex" nil))
|
2018-10-18 13:44:19 +00:00
|
|
|
|
;; Tags on a headline.
|
2018-11-25 01:01:41 +00: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 13:44:19 +00:00
|
|
|
|
(cons "tag" nil))
|
|
|
|
|
;; TODO keywords on an empty headline.
|
|
|
|
|
((and (string-match "^\\*+ +\\S-*$" line-to-here)
|
|
|
|
|
(looking-at-p "[ \t]*$"))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(cons "todo" nil))
|
2018-10-18 13:44:19 +00: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 08:34:09 +00:00
|
|
|
|
(cons "searchhead" nil))
|
2018-10-18 13:44:19 +00: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 08:34:09 +00:00
|
|
|
|
(t nil))))
|
|
|
|
|
|
2018-10-18 16:09:41 +00: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 08:34:09 +00: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 06:48:50 +00:00
|
|
|
|
\"file-option/startup\"."
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(let ((thing (org-thing-at-point)))
|
|
|
|
|
(cond
|
|
|
|
|
((string= "file-option" (car thing))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
(concat (car thing)
|
|
|
|
|
(and (cdr thing) (concat "/" (downcase (cdr thing))))))
|
2010-11-18 06:48:50 +00:00
|
|
|
|
((string= "block-option" (car thing))
|
|
|
|
|
(concat (car thing) "/" (downcase (cdr thing))))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
(t (car thing)))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
|
|
|
|
(defun org-parse-arguments ()
|
|
|
|
|
"Parse whitespace separated arguments in the current region."
|
2024-01-07 15:43:04 +00:00
|
|
|
|
(if (equal (cons "searchhead" nil) (org-thing-at-point))
|
|
|
|
|
;; [[* foo<point> bar link::search option.
|
|
|
|
|
;; Arguments are not simply space-separated.
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(save-excursion
|
2024-01-07 15:43:04 +00:00
|
|
|
|
(let ((origin (point)))
|
|
|
|
|
(skip-chars-backward "^*" (line-beginning-position))
|
|
|
|
|
(cons (list (buffer-substring-no-properties (point) origin))
|
|
|
|
|
(list (point)))))
|
|
|
|
|
(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)))))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
2011-01-31 17:40:05 +00:00
|
|
|
|
(defun org-pcomplete-initial ()
|
2021-09-16 10:32:43 +00:00
|
|
|
|
"Call the right completion function for first argument completions."
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(ignore
|
|
|
|
|
(funcall (or (pcomplete-find-completion-function
|
|
|
|
|
(car (org-thing-at-point)))
|
|
|
|
|
pcomplete-default-completion-function))))
|
|
|
|
|
|
2018-10-18 16:09:41 +00:00
|
|
|
|
|
|
|
|
|
;;; Completion functions
|
|
|
|
|
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(defun pcomplete/org-mode/file-option ()
|
|
|
|
|
"Complete against all valid file options."
|
2013-02-16 07:26:08 +00:00
|
|
|
|
(require 'org-element)
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(pcomplete-here
|
2011-01-31 17:40:05 +00:00
|
|
|
|
(org-pcomplete-case-double
|
2013-02-13 22:52:57 +00: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 12:21:39 +00: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 22:52:57 +00:00
|
|
|
|
(mapcar (lambda (keyword) (concat keyword ": "))
|
|
|
|
|
(org-get-export-keywords))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(substring pcomplete-stub 2)))
|
2012-03-19 20:38:12 +00:00
|
|
|
|
|
2013-02-13 22:52:57 +00: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."
|
2022-11-07 07:05:37 +00:00
|
|
|
|
(pcomplete-here (list (format-time-string (org-time-stamp-format)))))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
|
|
|
|
|
(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
|
2021-02-12 21:08:01 +00:00
|
|
|
|
(list (mapconcat #'identity org-export-exclude-tags " ")))))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/filetags ()
|
|
|
|
|
"Complete arguments for the #+FILETAGS file option."
|
2021-02-12 21:08:01 +00:00
|
|
|
|
(pcomplete-here (and org-file-tags (mapconcat #'identity org-file-tags " "))))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
|
|
|
|
|
(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-10 01:02:35 +00:00
|
|
|
|
(pcomplete-uniquify-list
|
2013-02-13 22:52:57 +00: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"
|
2020-01-30 13:56:38 +00:00
|
|
|
|
org-priority-highest
|
|
|
|
|
org-priority-lowest
|
|
|
|
|
org-priority-default))))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
|
|
|
|
|
(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
|
2021-02-12 21:08:01 +00:00
|
|
|
|
(list (mapconcat #'identity org-export-select-tags " ")))))
|
2013-02-13 22:52:57 +00:00
|
|
|
|
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(defun pcomplete/org-mode/file-option/startup ()
|
2009-10-20 08:34:09 +00: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-10 01:02:35 +00:00
|
|
|
|
(let ((opts (pcomplete-uniquify-list
|
2021-02-12 21:08:01 +00:00
|
|
|
|
(mapcar #'car org-startup-options))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
;; 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 22:52:57 +00:00
|
|
|
|
(defun pcomplete/org-mode/file-option/tags ()
|
|
|
|
|
"Complete arguments for the #+TAGS file option."
|
|
|
|
|
(pcomplete-here
|
2016-04-18 17:34:08 +00:00
|
|
|
|
(list (org-tag-alist-to-string org-current-tag-alist))))
|
2013-02-13 22:52:57 +00: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 13:29:31 +00:00
|
|
|
|
|
2013-07-03 21:10:08 +00:00
|
|
|
|
|
2012-08-01 15:19:13 +00:00
|
|
|
|
(defun pcomplete/org-mode/file-option/options ()
|
|
|
|
|
"Complete arguments for the #+OPTIONS file option."
|
2013-01-27 23:09:31 +00: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-10 01:02:35 +00:00
|
|
|
|
(pcomplete-uniquify-list
|
2013-01-27 23:09:31 +00: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:")
|
2023-04-20 12:11:19 +00:00
|
|
|
|
;; OPTION items from registered backends.
|
2013-01-27 23:09:31 +00:00
|
|
|
|
(let (items)
|
2016-06-23 12:18:38 +00:00
|
|
|
|
(dolist (backend (bound-and-true-p
|
2015-04-22 08:24:02 +00:00
|
|
|
|
org-export-registered-backends))
|
2013-07-03 21:10:08 +00:00
|
|
|
|
(dolist (option (org-export-backend-options backend))
|
2013-01-27 23:09:31 +00: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-10 01:02:35 +00:00
|
|
|
|
(pcomplete-uniquify-list
|
2013-01-27 23:09:31 +00:00
|
|
|
|
(mapcar (lambda (item) (format "%s:" (car item)))
|
2016-06-23 12:18:38 +00:00
|
|
|
|
(bound-and-true-p org-html-infojs-opts-table))))))
|
2012-08-01 15:19:13 +00:00
|
|
|
|
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(defun pcomplete/org-mode/file-option/bind ()
|
2012-07-30 08:08:15 +00:00
|
|
|
|
"Complete arguments for the #+BIND file option, which are variable names."
|
2010-11-18 06:48:50 +00: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-10 01:02:35 +00:00
|
|
|
|
(lambda (a) (when (boundp a) (setq vars (cons (symbol-name a) vars)))))
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(pcomplete-here vars)))
|
|
|
|
|
|
2009-10-20 08:34:09 +00: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-10 01:02:35 +00:00
|
|
|
|
(pcomplete-uniquify-list
|
2011-01-17 11:51:43 +00:00
|
|
|
|
(copy-sequence
|
2018-10-18 13:46:53 +00:00
|
|
|
|
(mapcar (lambda (e) (concat (car e) ":"))
|
|
|
|
|
(append org-link-abbrev-alist-local
|
|
|
|
|
org-link-abbrev-alist))))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/tex ()
|
|
|
|
|
"Complete against TeX-style HTML entity names."
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(require 'org-entities)
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(while (pcomplete-here
|
2021-02-12 21:08:01 +00:00
|
|
|
|
(pcomplete-uniquify-list
|
|
|
|
|
(remove nil (mapcar #'car-safe org-entities)))
|
2009-10-20 08:34:09 +00: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-10 01:02:35 +00:00
|
|
|
|
(pcomplete-here (pcomplete-uniquify-list (copy-sequence org-todo-keywords-1))))
|
2009-10-20 08:34:09 +00: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 13:47:56 +00:00
|
|
|
|
(while (pcomplete-here
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let (tbl)
|
|
|
|
|
(while (re-search-forward org-outline-regexp nil t)
|
2020-02-19 17:03:53 +00:00
|
|
|
|
;; Remove the leading asterisk from
|
|
|
|
|
;; `org-link-heading-search-string' result.
|
|
|
|
|
(push (substring (org-link-heading-search-string) 1) tbl))
|
2024-01-07 15:43:04 +00:00
|
|
|
|
(pcomplete-uniquify-list tbl))))))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/tag ()
|
|
|
|
|
"Complete a tag name. Omit tags already set."
|
|
|
|
|
(while (pcomplete-here
|
2016-04-17 15:00:14 +00: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-10 01:02:35 +00:00
|
|
|
|
(let ((lst (pcomplete-uniquify-list
|
2016-04-17 15:00:14 +00:00
|
|
|
|
(or (remq
|
2010-11-18 06:48:50 +00:00
|
|
|
|
nil
|
2016-04-17 15:00:14 +00:00
|
|
|
|
(mapcar (lambda (x) (org-string-nw-p (car x)))
|
2016-04-18 17:34:08 +00:00
|
|
|
|
org-current-tag-alist))
|
2016-04-17 15:00:14 +00:00
|
|
|
|
(mapcar #'car (org-get-buffer-tags))))))
|
2018-04-18 15:28:52 +00:00
|
|
|
|
(dolist (tag (org-get-tags nil t))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(setq lst (delete tag lst)))
|
|
|
|
|
lst))
|
|
|
|
|
(and (string-match ".*:" pcomplete-stub)
|
2018-11-25 01:01:41 +00:00
|
|
|
|
(substring pcomplete-stub (match-end 0)))
|
|
|
|
|
t)))
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
2018-10-18 15:03:15 +00: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)))
|
2023-05-16 10:41:53 +00:00
|
|
|
|
(when (org-element-type-p drawer '(drawer property-drawer))
|
2018-10-18 15:03:15 +00:00
|
|
|
|
(push (org-element-property :drawer-name drawer) names)
|
2023-05-03 14:26:41 +00:00
|
|
|
|
(goto-char (org-element-end drawer))))))
|
2018-10-18 15:03:15 +00:00
|
|
|
|
(pcomplete-uniquify-list names))))
|
|
|
|
|
(substring pcomplete-stub 1))) ;remove initial colon
|
|
|
|
|
|
2009-10-20 08:34:09 +00:00
|
|
|
|
(defun pcomplete/org-mode/prop ()
|
|
|
|
|
"Complete a property name. Omit properties already set."
|
|
|
|
|
(pcomplete-here
|
2018-10-18 13:45:14 +00: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 08:34:09 +00:00
|
|
|
|
(substring pcomplete-stub 1)))
|
|
|
|
|
|
2010-11-18 06:48:50 +00:00
|
|
|
|
(defun pcomplete/org-mode/block-option/src ()
|
2018-09-20 09:23:49 +00:00
|
|
|
|
"Complete the arguments of a source block.
|
|
|
|
|
Complete a language in the first field, the header arguments and
|
|
|
|
|
switches."
|
2010-11-18 06:48:50 +00: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)))))))
|
2022-10-18 15:34:18 +00:00
|
|
|
|
(let* ((info (org-babel-get-src-block-info 'no-eval))
|
2020-05-12 13:44:04 +00:00
|
|
|
|
(lang (car info))
|
|
|
|
|
(lang-headers (intern (concat "org-babel-header-args:" lang)))
|
|
|
|
|
(headers (org-babel-combine-header-arg-lists
|
|
|
|
|
org-babel-common-header-args-w-values
|
|
|
|
|
(and (boundp lang-headers) (eval lang-headers t)))))
|
|
|
|
|
(while (pcomplete-here
|
|
|
|
|
(append (mapcar
|
|
|
|
|
(lambda (arg) (format ":%s" (symbol-name (car arg))))
|
|
|
|
|
headers)
|
|
|
|
|
'("-n" "-r" "-l"))))))
|
2010-11-18 06:48:50 +00:00
|
|
|
|
|
|
|
|
|
(defun pcomplete/org-mode/block-option/clocktable ()
|
2012-07-30 08:08:15 +00:00
|
|
|
|
"Complete keywords in a clocktable line."
|
2013-03-19 12:50:42 +00:00
|
|
|
|
(while (pcomplete-here '(":maxlevel" ":scope" ":lang"
|
2010-11-18 06:48:50 +00:00
|
|
|
|
":tstart" ":tend" ":block" ":step"
|
|
|
|
|
":stepskip0" ":fileskip0"
|
|
|
|
|
":emphasize" ":link" ":narrow" ":indent"
|
2019-03-10 19:05:10 +00:00
|
|
|
|
":hidefiles" ":tcolumns" ":level" ":compact"
|
|
|
|
|
":timestamp" ":formula" ":formatter"
|
|
|
|
|
":wstart" ":mstart"))))
|
2010-11-18 06:48:50 +00:00
|
|
|
|
|
2018-10-18 16:09:41 +00:00
|
|
|
|
|
|
|
|
|
;;; Finish up
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
2011-01-31 17:40:05 +00:00
|
|
|
|
(provide 'org-pcomplete)
|
2009-10-20 08:34:09 +00:00
|
|
|
|
|
2011-01-31 17:40:05 +00:00
|
|
|
|
;;; org-pcomplete.el ends here
|