From 3f4a0d5370ae6c34afe180df96add3b8522f4af1 Mon Sep 17 00:00:00 2001 From: mattkae Date: Wed, 11 May 2022 09:23:58 -0400 Subject: initial commit --- elpa/org-9.5.2/org-tempo.el | 188 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 elpa/org-9.5.2/org-tempo.el (limited to 'elpa/org-9.5.2/org-tempo.el') diff --git a/elpa/org-9.5.2/org-tempo.el b/elpa/org-9.5.2/org-tempo.el new file mode 100644 index 0000000..c121b8e --- /dev/null +++ b/elpa/org-9.5.2/org-tempo.el @@ -0,0 +1,188 @@ +;;; org-tempo.el --- Template expansion for Org structures -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2021 Free Software Foundation, Inc. +;; +;; Author: Rasmus Pank Roulund +;; Keywords: outlines, hypermedia, calendar, wp +;; Homepage: https://orgmode.org +;; +;; 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 +;; along with GNU Emacs. If not, see . +;; +;;; Commentary: +;; +;; Org Tempo reimplements completions of structure template before +;; point like `org-try-structure-completion' in Org v9.1 and earlier. +;; For example, strings like " (length keys) (length (delete-dups keys))) + (warn + "Duplicated keys in `org-structure-template-alist' and `org-tempo-keywords-alist'")) + ;; Remove any keys already defined in case they have been updated. + (setq org-tempo-tags + (cl-remove-if (lambda (tag) (member (car tag) keys)) org-tempo-tags)) + (mapc #'org-tempo-add-block org-structure-template-alist) + (mapc #'org-tempo-add-keyword org-tempo-keywords-alist))) + +(defun org-tempo-add-block (entry) + "Add block entry from `org-structure-template-alist'." + (let* ((key (format "<%s" (car entry))) + (name (cdr entry)) + (special (member name '("src" "export")))) + (tempo-define-template (format "org-%s" (replace-regexp-in-string " " "-" name)) + `(,(format "#+begin_%s%s" name (if special " " "")) + ,(when special 'p) '> n ,(unless special 'p) n + ,(format "#+end_%s" (car (split-string name " "))) + >) + key + (format "Insert a %s block" name) + 'org-tempo-tags))) + +(defun org-tempo-add-keyword (entry) + "Add keyword entry from `org-tempo-keywords-alist'." + (let* ((key (format "<%s" (car entry))) + (name (cdr entry))) + (tempo-define-template (format "org-%s" (replace-regexp-in-string " " "-" name)) + `(,(format "#+%s: " name) p '>) + key + (format "Insert a %s keyword" name) + 'org-tempo-tags))) + +(defun org-tempo-complete-tag (&rest _) + "Look for a tag and expand it silently. +Unlike to `tempo-complete-tag', do not give a signal if a partial +completion or no match at all is found. Return nil if expansion +didn't succeed." + (org-tempo--update-maybe) + ;; `tempo-complete-tag' returns its SILENT argument when there is no + ;; completion available at all. + (not (eq 'fail (tempo-complete-tag 'fail)))) + + +;;; Additional keywords + +(defun org-tempo--include-file () + "Add #+include: and a file name." + (let ((inhibit-quit t)) + (unless (with-local-quit + (prog1 t + (insert + (format "#+include: %S " + (file-relative-name + (read-file-name "Include file: ")))))) + (insert ") + "