]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
add org-ac
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Thu, 11 May 2023 16:11:16 +0000 (18:11 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Thu, 11 May 2023 16:11:16 +0000 (18:11 +0200)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
elpa/org-ac-20170401.1307/org-ac-autoloads.el [new file with mode: 0644]
elpa/org-ac-20170401.1307/org-ac-pkg.el [new file with mode: 0644]
elpa/org-ac-20170401.1307/org-ac.el [new file with mode: 0644]
elpa/org-ac-readme.txt [new file with mode: 0644]

diff --git a/elpa/org-ac-20170401.1307/org-ac-autoloads.el b/elpa/org-ac-20170401.1307/org-ac-autoloads.el
new file mode 100644 (file)
index 0000000..c505d7c
--- /dev/null
@@ -0,0 +1,32 @@
+;;; org-ac-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+                         (or (file-name-directory #$) (car load-path))))
+
+\f
+;;;### (autoloads nil "org-ac" "org-ac.el" (0 0 0 0))
+;;; Generated autoloads from org-ac.el
+
+(autoload 'org-ac/setup-current-buffer "org-ac" "\
+Do setup for using org-ac in current buffer.
+
+\(fn)" t nil)
+
+(autoload 'org-ac/config-default "org-ac" "\
+Do setting recommemded configuration.
+
+\(fn)" nil nil)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "org-ac" '("org-ac" "ac-source-org-ac-")))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; org-ac-autoloads.el ends here
diff --git a/elpa/org-ac-20170401.1307/org-ac-pkg.el b/elpa/org-ac-20170401.1307/org-ac-pkg.el
new file mode 100644 (file)
index 0000000..52e6bda
--- /dev/null
@@ -0,0 +1,2 @@
+;;; -*- no-byte-compile: t -*-
+(define-package "org-ac" "20170401.1307" "Some auto-complete sources for org-mode" '((auto-complete-pcmp "0.0.1") (log4e "0.2.0") (yaxception "0.1")) :commit "41e3ef8e4039619d0370c23c66730b3b2e9e32ed" :keywords '("org" "completion") :authors '(("Hiroaki Otsu" . "ootsuhiroakiNOSPAMgmail.com")) :maintainer '("Hiroaki Otsu" . "ootsuhiroakiNOSPAMgmail.com") :url "https://github.com/aki2o/org-ac")
diff --git a/elpa/org-ac-20170401.1307/org-ac.el b/elpa/org-ac-20170401.1307/org-ac.el
new file mode 100644 (file)
index 0000000..c062505
--- /dev/null
@@ -0,0 +1,262 @@
+;;; org-ac.el --- Some auto-complete sources for org-mode
+
+;; Copyright (C) 2014  Hiroaki Otsu
+
+;; Author: Hiroaki Otsu <ootsuhiroakiNOSPAMgmail.com>
+;; Keywords: org, completion
+;; Package-Version: 20170401.1307
+;; URL: https://github.com/aki2o/org-ac
+;; Version: 0.0.2
+;; Package-Requires: ((auto-complete-pcmp "0.0.1") (log4e "0.2.0") (yaxception "0.1"))
+
+;; This program 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.
+
+;; This file 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; 
+;; This extension provides auto-complete sources for org-mode.
+
+;;; Dependency:
+;; 
+;; - auto-complete-pcmp.el ( see <https://github.com/aki2o/auto-complete-pcmp> )
+;; - yaxception.el ( see <https://github.com/aki2o/yaxception> )
+;; - log4e.el ( see <https://github.com/aki2o/log4e> )
+
+;;; Installation:
+;;
+;; Put this to your load-path.
+;; And put the following lines in your .emacs or site-start.el file.
+;; 
+;; (require 'org-ac)
+
+;;; Configuration:
+;; 
+;; ;; Make config suit for you. About the config item, see Customization or eval the following sexp.
+;; ;; (customize-group "org-ac")
+;; 
+;; (org-ac/config-default)
+
+;;; Customization:
+;; 
+;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "org-ac/" :docstring t)
+;; `org-ac/ac-trigger-command-keys'
+;; Keystrokes for doing `ac-start' with self insert.
+;; 
+;;  *** END auto-documentation
+
+;;; API:
+;; 
+;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "org-ac/" :docstring t)
+;; `org-ac/setup-current-buffer'
+;; Do setup for using org-ac in current buffer.
+;; 
+;;  *** END auto-documentation
+;; [Note] Functions and variables other than listed above, Those specifications may be changed without notice.
+
+;;; Tested On:
+;; 
+;; - Emacs ... GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.4.2) of 2013-08-22 on chindi02, modified by Debian
+;; - auto-complete-pcmp.el ... Version 0.0.1
+;; - yaxception.el ... Version 0.1
+;; - log4e.el ... Version 0.2.0
+
+
+;; Enjoy!!!
+
+
+(eval-when-compile (require 'cl))
+(require 'org)
+(require 'auto-complete-pcmp)
+(require 'rx)
+(require 'log4e)
+(require 'yaxception)
+
+(defgroup org-ac nil
+  "Auto completion for org-mode."
+  :group 'org
+  :prefix "org-ac/")
+
+(defcustom org-ac/ac-trigger-command-keys '("\\" "*" "SPC" ":" "[" "+")
+  "Keystrokes for doing `ac-start' with self insert."
+  :type '(repeat string)
+  :group 'org-ac)
+
+
+(log4e:deflogger "org-ac" "%t [%l] %m" "%H:%M:%S" '((fatal . "fatal")
+                                                    (error . "error")
+                                                    (warn  . "warn")
+                                                    (info  . "info")
+                                                    (debug . "debug")
+                                                    (trace . "trace")))
+(org-ac--log-set-level 'trace)
+
+
+(defun* org-ac--show-message (msg &rest args)
+  (apply 'message (concat "[ORG-AC] " msg) args)
+  nil)
+
+(defun org-ac--complete-close-option-at-current-point ()
+  (let ((pt (point)))
+    (yaxception:$
+      (yaxception:try
+        (org-ac--trace "start complete close option at current point")
+        (when (save-excursion
+                (re-search-backward "#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9]+\\) *\\=" nil t))
+          (let* ((opennm (match-string-no-properties 1))
+                 (typenm (match-string-no-properties 2))
+                 (closenm (cond ((string= opennm "begin") "end")
+                                ((string= opennm "BEGIN") "END")))
+                 (case-fold-search t))
+            (if (or (not (re-search-forward "^[ \t]*#\\+" nil t))
+                    (not (re-search-forward (concat "\\=" closenm "_") nil t)))
+                (progn (goto-char pt)
+                       (insert "\n#+" closenm "_" typenm)
+                       (org-cycle))
+              (let ((currtypenm (if (re-search-forward "\\=\\([a-zA-Z0-9]+\\)" nil t)
+                                    (match-string-no-properties 1)
+                                  "")))
+                (backward-delete-char (+ (length closenm)
+                                         1
+                                         (length currtypenm)))
+                (insert closenm "_" typenm)))
+            (goto-char pt))))
+      (yaxception:catch 'error e
+        (org-ac--show-message "Failed complete close option : %s" (yaxception:get-text e))
+        (org-ac--error "failed complete close option at current point : %s\n%s"
+                       (yaxception:get-text e)
+                       (yaxception:get-stack-trace-string e))
+        (goto-char pt)))))
+
+(defun org-ac--get-link-head-candidates ()
+  (append (ac-pcmp/get-ac-candidates)
+          (mapcar (lambda (x) (concat x ":")) org-link-types)))
+
+(defvar ac-source-org-ac-tex
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "\\\\\\([a-zA-Z0-9_-]*\\)")
+    (symbol . "t")
+    (requires . 0)
+    (cache)
+    (action . ac-pcmp/do-ac-action)))
+
+(defvar ac-source-org-ac-head
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "[^\r\n*]\\*\\([^\t\r\n]*\\)")
+    (symbol . "h")
+    (requires . 0)
+    (cache)
+    (action . ac-pcmp/do-ac-action)))
+
+(defvar ac-source-org-ac-todo
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "^\\*+ \\([a-zA-Z0-9_-]*\\)")
+    (symbol . "d")
+    (requires . 0)
+    (cache)
+    (action . ac-pcmp/do-ac-action)))
+
+(defvar ac-source-org-ac-tag
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "[ \t]:\\([a-zA-Z0-9_-]*\\)")
+    (symbol . "t")
+    (requires . 0)
+    (cache)
+    (action . ac-pcmp/do-ac-action)))
+
+(defvar org-ac--regexp-link-head (rx-to-string `(and "["
+                                                     (* (any " \t"))
+                                                     "["
+                                                     (group (* (not (any ":*]")))))))
+(defvar ac-source-org-ac-link-head
+  `((candidates . org-ac--get-link-head-candidates)
+    (prefix . ,org-ac--regexp-link-head)
+    (symbol . "l")
+    (requires . 0)
+    (cache)
+    (action . (lambda ()
+                (ac-pcmp/do-ac-action)
+                (ac-start)))))
+
+(defvar ac-source-org-ac-option
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "^[ \t]*#\\+\\([a-zA-Z0-9_:=-]*\\)")
+    (symbol . "o")
+    (requires . 0)
+    (cache)
+    (action . (lambda ()
+                (ac-pcmp/do-ac-action)
+                (org-ac--complete-close-option-at-current-point)
+                (auto-complete '(ac-source-org-ac-option-key))))))
+
+(defvar ac-source-org-ac-option-key
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "^[ \t]*#\\+[a-zA-Z0-9_:=-]+ +\\([a-zA-Z0-9_-]*\\)")
+    (symbol . "k")
+    (requires . 0)
+    (cache)
+    (action . ac-pcmp/do-ac-action)))
+
+(defvar ac-source-org-ac-option-options
+  '((candidates . ac-pcmp/get-ac-candidates)
+    (prefix . "^[ \t]*#\\+\\(?:options\\|OPTIONS\\):.* +\\([a-zA-Z0-9_-]*\\)")
+    (symbol . "x")
+    (requires . 0)
+    (cache)
+    (action . ac-pcmp/do-ac-action)))
+
+(defvar ac-source-org-ac-file
+  '((init . (setq ac-filename-cache nil))
+    (candidates . org-ac/file-candidate)
+    (prefix . "\\[file:\\(.*\\)")
+    (symbol . "f")
+    (requires . 0)
+    (action . ac-start)
+    (limit . nil)))
+
+
+;;;###autoload
+(defun org-ac/setup-current-buffer ()
+  "Do setup for using org-ac in current buffer."
+  (interactive)
+  (when (eq major-mode 'org-mode)
+    (loop for stroke in org-ac/ac-trigger-command-keys
+          do (local-set-key (read-kbd-macro stroke) 'ac-pcmp/self-insert-command-with-ac-start))
+    (add-to-list 'ac-sources 'ac-source-org-ac-tex)
+    (add-to-list 'ac-sources 'ac-source-org-ac-head)
+    (add-to-list 'ac-sources 'ac-source-org-ac-todo)
+    (add-to-list 'ac-sources 'ac-source-org-ac-tag)
+    (add-to-list 'ac-sources 'ac-source-org-ac-link-head)
+    (add-to-list 'ac-sources 'ac-source-org-ac-option)
+    (add-to-list 'ac-sources 'ac-source-org-ac-option-key)
+    (add-to-list 'ac-sources 'ac-source-org-ac-option-options)
+    (add-to-list 'ac-sources 'ac-source-org-ac-file)
+    (auto-complete-mode t)))
+
+;;;###autoload
+(defun org-ac/config-default ()
+  "Do setting recommemded configuration."
+  (add-to-list 'ac-modes 'org-mode)
+  (add-hook 'org-mode-hook 'org-ac/setup-current-buffer t))
+
+
+(defun org-ac/file-candidate ()
+  "Adds [file: to the normal file completition, plus allows relative paths"
+  (if (string-match "^[~./]+" ac-prefix)
+      (ac-filename-candidate)
+    (let ((ac-prefix (concat "./" ac-prefix)))
+      (mapcar (lambda (path) (substring path 2))
+              (ac-filename-candidate)))))
+
+
+(provide 'org-ac)
+;;; org-ac.el ends here
diff --git a/elpa/org-ac-readme.txt b/elpa/org-ac-readme.txt
new file mode 100644 (file)
index 0000000..3ff8067
--- /dev/null
@@ -0,0 +1 @@
+This extension provides auto-complete sources for org-mode.