Install org, org-jekyll, and electric-spaces
This commit is contained in:
parent
cb7b4594a4
commit
73837bf135
16
elpa/electric-case-20150417.412/electric-case-autoloads.el
Normal file
16
elpa/electric-case-20150417.412/electric-case-autoloads.el
Normal file
@ -0,0 +1,16 @@
|
||||
;;; electric-case-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
|
||||
|
||||
;;;### (autoloads nil nil ("electric-case.el") (22499 30815 963740
|
||||
;;;;;; 197000))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; End:
|
||||
;;; electric-case-autoloads.el ends here
|
1
elpa/electric-case-20150417.412/electric-case-pkg.el
Normal file
1
elpa/electric-case-20150417.412/electric-case-pkg.el
Normal file
@ -0,0 +1 @@
|
||||
(define-package "electric-case" "20150417.412" "insert camelCase, snake_case words without \"Shift\"ing" 'nil :url "http://hins11.yu-yake.com/")
|
383
elpa/electric-case-20150417.412/electric-case.el
Normal file
383
elpa/electric-case-20150417.412/electric-case.el
Normal file
@ -0,0 +1,383 @@
|
||||
;;; electric-case.el --- insert camelCase, snake_case words without "Shift"ing
|
||||
|
||||
;; Copyright (C) 2013-2015 zk_phi
|
||||
|
||||
;; 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 2 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program 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, write to the Free Software
|
||||
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
;; Version: 2.2.2
|
||||
;; Package-Version: 20150417.412
|
||||
;; Author: zk_phi
|
||||
;; URL: http://hins11.yu-yake.com/
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Load this script
|
||||
;;
|
||||
;; (require 'electric-case)
|
||||
;;
|
||||
;; and initialize in major-mode hooks.
|
||||
;;
|
||||
;; (add-hook 'java-mode-hook 'electric-case-java-init)
|
||||
;;
|
||||
;; And when you type the following in java-mode for example,
|
||||
;;
|
||||
;; public class test-class{
|
||||
;; public void test-method(void){
|
||||
;;
|
||||
;; =electric-case= automatically converts it into :
|
||||
;;
|
||||
;; public class TestClass{
|
||||
;; public void testMethod(void){
|
||||
;;
|
||||
;; Preconfigured settings for some other languages are also
|
||||
;; provided. Try:
|
||||
;;
|
||||
;; (add-hook 'c-mode-hook electric-case-c-init)
|
||||
;; (add-hook 'ahk-mode-hook electric-case-ahk-init)
|
||||
;; (add-hook 'scala-mode-hook electric-case-scala-init)
|
||||
;;
|
||||
;; For more informations, see Readme.org.
|
||||
|
||||
;;; Change Log:
|
||||
|
||||
;; 1.0.0 first released
|
||||
;; 1.0.1 fixed java settings
|
||||
;; 1.0.2 minor fixes
|
||||
;; 1.0.3 fixed java settings
|
||||
;; 1.0.4 fixed java settings
|
||||
;; 1.0.5 fixed C settings
|
||||
;; 1.1.0 added electric-case-convert-calls
|
||||
;; 1.1.1 modified arguments for criteria function
|
||||
;; 1.1.2 added ahk-mode settings
|
||||
;; 1.1.3 added scala-mode settings, and refactord
|
||||
;; 1.1.4 fixes and improvements
|
||||
;; 2.0.0 added pending-overlays
|
||||
;; 2.0.1 added electric-case-trigger to post-command-hook
|
||||
;; deleted variable "convert-calls"
|
||||
;; 2.0.2 minow fixes for criterias
|
||||
;; 2.0.3 removed electric-case-trigger from post-command-hook
|
||||
;; 2.0.4 fixed trigger and added hook again
|
||||
;; 2.1.0 added 2 custom variables, minor fixes
|
||||
;; 2.1.1 added 2 custom variables
|
||||
;; 2.2.0 changed behavior
|
||||
;; now only symbols overlayd are converted
|
||||
;; 2.2.1 fixed bug that words without overlay may converted
|
||||
;; 2.2.2 fixed bug that electric-case-convert-end is ignored
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
;; * constants
|
||||
|
||||
(defconst electric-case-version "2.2.2")
|
||||
|
||||
;; * customs
|
||||
|
||||
(defgroup electric-case nil
|
||||
"Insert camelCase, snake_case words without \"Shift\"ing"
|
||||
:group 'emacs)
|
||||
|
||||
(defcustom electric-case-pending-overlay 'shadow
|
||||
"Face used to highlight pending symbols"
|
||||
:group 'electric-case)
|
||||
|
||||
(defcustom electric-case-convert-calls nil
|
||||
"When nil, only declarations are converted."
|
||||
:group 'electric-case)
|
||||
|
||||
(defcustom electric-case-convert-nums nil
|
||||
"When non-nil, hyphens around numbers are also counted as a
|
||||
part of the symbol."
|
||||
:group 'electric-case)
|
||||
|
||||
(defcustom electric-case-convert-beginning nil
|
||||
"When non-nil, hyphens at the beginning of symbols are also
|
||||
counted as a part of the symbol."
|
||||
:group 'electric-case)
|
||||
|
||||
(defcustom electric-case-convert-end nil
|
||||
"When non-nil, hyphens at the end of symbols are also counted
|
||||
as a part of the symbol."
|
||||
:group 'electric-case)
|
||||
|
||||
;; * mode variables
|
||||
|
||||
(define-minor-mode electric-case-mode
|
||||
"insert camelCase, snake_case words without \"Shift\"ing"
|
||||
:init-value nil
|
||||
:lighter "eCase"
|
||||
:global nil
|
||||
(if electric-case-mode
|
||||
(add-hook 'post-command-hook 'electric-case--post-command-function nil t)
|
||||
(remove-hook 'post-command-hook 'electric-case--post-command-function t)))
|
||||
|
||||
;; * buffer-local variables
|
||||
|
||||
(defvar electric-case-criteria (lambda (b e) 'camel))
|
||||
(make-variable-buffer-local 'electric-case-criteria)
|
||||
|
||||
(defvar electric-case-max-iteration 1)
|
||||
(make-variable-buffer-local 'electric-case-max-iteration)
|
||||
|
||||
;; * utilities
|
||||
;; ** motion
|
||||
|
||||
(defun electric-case--range (n)
|
||||
(save-excursion
|
||||
(let* ((pos (point))
|
||||
(beg (ignore-errors
|
||||
(dotimes (_ n)
|
||||
(when (bobp) (error "beginning of buffer"))
|
||||
(backward-word)
|
||||
(if electric-case-convert-nums
|
||||
(skip-chars-backward "[:alnum:]-")
|
||||
(skip-chars-backward "[:alpha:]-"))
|
||||
(unless electric-case-convert-beginning
|
||||
(skip-chars-forward "-")))
|
||||
(point)))
|
||||
(end (when beg
|
||||
(goto-char beg)
|
||||
(if electric-case-convert-nums
|
||||
(skip-chars-forward "[:alnum:]-")
|
||||
(skip-chars-forward "[:alpha:]-"))
|
||||
(unless electric-case-convert-end
|
||||
(skip-chars-backward "-"))
|
||||
(point))))
|
||||
;; inside-lo|ng-symbol => nil
|
||||
;; b p e
|
||||
(when (and end (<= end pos))
|
||||
(cons beg end)))))
|
||||
|
||||
;; ** replace buffer
|
||||
|
||||
(defun electric-case--replace-buffer (beg end str)
|
||||
"(replace 1 2 \"aa\")
|
||||
buffer-string => aaffer-string"
|
||||
(when (not (string= (buffer-substring-no-properties beg end) str))
|
||||
(let ((pos (point))
|
||||
(oldlen (- end beg))
|
||||
(newlen (length str)))
|
||||
(kill-region beg end)
|
||||
(goto-char beg)
|
||||
(insert str)
|
||||
(remove-overlays beg (+ beg newlen))
|
||||
(goto-char (+ pos (- newlen oldlen))))))
|
||||
|
||||
;; ** overlay management
|
||||
|
||||
(defvar electric-case--overlays nil)
|
||||
(make-variable-buffer-local 'electric-case--overlays)
|
||||
|
||||
(defun electric-case--put-overlay (n)
|
||||
(let ((range (electric-case--range n)))
|
||||
(when range
|
||||
(let ((ov (make-overlay (car range) (cdr range))))
|
||||
(overlay-put ov 'face electric-case-pending-overlay)
|
||||
(add-to-list 'electric-case--overlays ov)))))
|
||||
|
||||
(defun electric-case--remove-overlays ()
|
||||
(mapc 'delete-overlay electric-case--overlays)
|
||||
(setq electric-case--overlays nil))
|
||||
|
||||
(defun electric-case--not-on-overlay-p ()
|
||||
(let ((res t) (pos (point)))
|
||||
(dolist (ov electric-case--overlays res)
|
||||
(setq res (and res
|
||||
(or (< pos (overlay-start ov))
|
||||
(< (overlay-end ov) pos)))))))
|
||||
|
||||
;; * commands
|
||||
|
||||
(defun electric-case--convert-all ()
|
||||
(dolist (ov electric-case--overlays)
|
||||
(let ((beg (overlay-start ov))
|
||||
(end (overlay-end ov)))
|
||||
;; vvv i dont remember why i added whis line vvv
|
||||
(when (string-match "[a-z]" (buffer-substring-no-properties beg end))
|
||||
(let* ((type (apply electric-case-criteria (list beg end)))
|
||||
(str (buffer-substring-no-properties beg end))
|
||||
(wlst (split-string str "-"))
|
||||
(convstr (case type
|
||||
('ucamel (mapconcat (lambda (w) (upcase-initials w)) wlst ""))
|
||||
('camel (concat
|
||||
(car wlst)
|
||||
(mapconcat (lambda (w) (upcase-initials w)) (cdr wlst) "")))
|
||||
('usnake (mapconcat (lambda (w) (upcase w)) wlst "_"))
|
||||
('snake (mapconcat 'identity wlst "_"))
|
||||
(t nil))))
|
||||
(when convstr
|
||||
(electric-case--replace-buffer beg end convstr))))))
|
||||
(electric-case--remove-overlays))
|
||||
|
||||
(defun electric-case--post-command-function ()
|
||||
;; update overlay
|
||||
(when (and (eq 'self-insert-command (key-binding (this-single-command-keys)))
|
||||
(characterp last-command-event)
|
||||
(string-match
|
||||
(if electric-case-convert-nums "[a-zA-Z0-9]" "[a-zA-Z]")
|
||||
(char-to-string last-command-event)))
|
||||
(electric-case--remove-overlays)
|
||||
(let (n)
|
||||
(dotimes (n electric-case-max-iteration)
|
||||
(electric-case--put-overlay (- electric-case-max-iteration n)))))
|
||||
;; electric-case trigger
|
||||
(when (and (electric-case--not-on-overlay-p)
|
||||
(not mark-active))
|
||||
(electric-case--convert-all)))
|
||||
|
||||
;; * settings
|
||||
;; ** utilities
|
||||
|
||||
(defun electric-case--possible-properties (beg end)
|
||||
(let* ((ret (point))
|
||||
(str (buffer-substring beg end))
|
||||
(convstr (replace-regexp-in-string "-" "" str))
|
||||
(val (progn (electric-case--replace-buffer beg end convstr)
|
||||
(font-lock-fontify-buffer)
|
||||
(sit-for 0)
|
||||
(text-properties-at beg))))
|
||||
(electric-case--replace-buffer beg (+ beg (length convstr)) str)
|
||||
(font-lock-fontify-buffer)
|
||||
val))
|
||||
|
||||
(defun electric-case--this-line-string ()
|
||||
(buffer-substring (save-excursion (beginning-of-line) (point))
|
||||
(save-excursion (end-of-line) (point))))
|
||||
|
||||
;; ** c-mode
|
||||
|
||||
(defun electric-case-c-init ()
|
||||
|
||||
(electric-case-mode 1)
|
||||
(setq electric-case-max-iteration 2)
|
||||
|
||||
(setq electric-case-criteria
|
||||
(lambda (b e)
|
||||
(let ((proper (electric-case--possible-properties b e))
|
||||
(key (key-description (this-single-command-keys))))
|
||||
(cond
|
||||
((member 'font-lock-variable-name-face proper)
|
||||
;; #ifdef A_MACRO / int variable_name;
|
||||
(if (member '(cpp-macro) (c-guess-basic-syntax)) 'usnake 'snake))
|
||||
((member 'font-lock-string-face proper) nil)
|
||||
((member 'font-lock-comment-face proper) nil)
|
||||
((member 'font-lock-keyword-face proper) nil)
|
||||
((member 'font-lock-function-name-face proper) 'snake)
|
||||
((member 'font-lock-type-face proper) 'snake)
|
||||
(electric-case-convert-calls 'snake)
|
||||
(t nil)))))
|
||||
|
||||
(defadvice electric-case-trigger (around electric-case-c-try-semi activate)
|
||||
(when (and electric-case-mode
|
||||
(eq major-mode 'c-mode))
|
||||
(if (not (string= (key-description (this-single-command-keys)) ";"))
|
||||
ad-do-it
|
||||
(insert ";")
|
||||
(backward-char)
|
||||
ad-do-it
|
||||
(delete-char 1))))
|
||||
)
|
||||
|
||||
;; ** java-mode
|
||||
|
||||
(defconst electric-case-java-primitives
|
||||
'("boolean" "char" "byte" "short" "int" "long" "float" "double" "void"))
|
||||
|
||||
(defun electric-case-java-init ()
|
||||
|
||||
(electric-case-mode 1)
|
||||
(setq electric-case-max-iteration 2)
|
||||
|
||||
(setq electric-case-criteria
|
||||
(lambda (b e)
|
||||
;; do not convert primitives
|
||||
(when (not (member (buffer-substring b e) electric-case-java-primitives))
|
||||
(let ((proper (electric-case--possible-properties b e))
|
||||
(str (electric-case--this-line-string)))
|
||||
(cond
|
||||
((string-match "^import" str)
|
||||
;; import java.util.ArrayList;
|
||||
(if (= (char-before) ?\;) 'ucamel nil))
|
||||
;; annotation
|
||||
((save-excursion (goto-char b)
|
||||
(and (not (= (point) (point-min)))
|
||||
(= (char-before) ?@)))
|
||||
'camel)
|
||||
((member 'font-lock-string-face proper) nil)
|
||||
((member 'font-lock-comment-face proper) nil)
|
||||
((member 'font-lock-keyword-face proper) nil)
|
||||
((member 'font-lock-type-face proper) 'ucamel)
|
||||
((member 'font-lock-function-name-face proper) 'camel)
|
||||
((member 'font-lock-variable-name-face proper) 'camel)
|
||||
(electric-case-convert-calls 'camel)
|
||||
(t nil))))))
|
||||
|
||||
(defadvice electric-case-trigger (around electric-case-java-try-semi activate)
|
||||
(when (and electric-case-mode
|
||||
(eq major-mode 'java-mode))
|
||||
(if (not (string= (key-description (this-single-command-keys)) ";"))
|
||||
ad-do-it
|
||||
(insert ";")
|
||||
(backward-char)
|
||||
ad-do-it
|
||||
(delete-char 1))))
|
||||
)
|
||||
|
||||
;; ** scala-mode
|
||||
|
||||
(defun electric-case-scala-init ()
|
||||
|
||||
(electric-case-mode 1)
|
||||
(setq electric-case-max-iteration 2)
|
||||
|
||||
(setq electric-case-criteria
|
||||
(lambda (b e)
|
||||
(when (not (member (buffer-substring b e) electric-case-java-primitives))
|
||||
(let ((proper (electric-case--possible-properties b e)))
|
||||
(cond
|
||||
((member 'font-lock-string-face proper) nil)
|
||||
((member 'font-lock-comment-face proper) nil)
|
||||
((member 'font-lock-keyword-face proper) nil)
|
||||
((member 'font-lock-type-face proper) 'ucamel)
|
||||
((member 'font-lock-function-name-face proper) 'camel)
|
||||
((member 'font-lock-variable-name-face proper) 'camel)
|
||||
(electric-case-convert-calls 'camel)
|
||||
(t nil))))))
|
||||
)
|
||||
|
||||
;; ** ahk-mode
|
||||
|
||||
(defun electric-case-ahk-init ()
|
||||
|
||||
(electric-case-mode 1)
|
||||
(setq electric-case-max-iteration 1)
|
||||
|
||||
(setq electric-case-criteria
|
||||
(lambda (b e)
|
||||
(let ((proper (electric-case--possible-properties b e)))
|
||||
(cond
|
||||
((member 'font-lock-string-face proper) nil)
|
||||
((member 'font-lock-comment-face proper) nil)
|
||||
((member 'font-lock-keyword-face proper) 'ucamel)
|
||||
(electric-case-convert-calls 'camel)
|
||||
(t nil)))))
|
||||
)
|
||||
|
||||
;; * provide
|
||||
|
||||
(provide 'electric-case)
|
||||
|
||||
;;; electric-case.el ends here
|
@ -0,0 +1,29 @@
|
||||
;;; electric-spacing-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
|
||||
|
||||
;;;### (autoloads nil "electric-spacing" "electric-spacing.el" (22499
|
||||
;;;;;; 30815 203000 0))
|
||||
;;; Generated autoloads from electric-spacing.el
|
||||
|
||||
(autoload 'electric-spacing-mode "electric-spacing" "\
|
||||
Toggle automatic surrounding space insertion (Electric Spacing mode).
|
||||
With a prefix argument ARG, enable Electric Spacing mode if ARG is
|
||||
positive, and disable it otherwise. If called from Lisp, enable
|
||||
the mode if ARG is omitted or nil.
|
||||
|
||||
This is a local minor mode. When enabled, typing an operator automatically
|
||||
inserts surrounding spaces. e.g., `=' becomes ` = ',`+=' becomes ` += '. This
|
||||
is very handy for many programming languages.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; End:
|
||||
;;; electric-spacing-autoloads.el ends here
|
@ -0,0 +1 @@
|
||||
(define-package "electric-spacing" "20151209.736" "Insert operators with surrounding spaces smartly" 'nil)
|
405
elpa/electric-spacing-20151209.736/electric-spacing.el
Normal file
405
elpa/electric-spacing-20151209.736/electric-spacing.el
Normal file
@ -0,0 +1,405 @@
|
||||
;;; electric-spacing.el --- Insert operators with surrounding spaces smartly
|
||||
|
||||
;; Copyright (C) 2004, 2005, 2007-2015 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: William Xu <william.xwl@gmail.com>
|
||||
;; Version: 5.0
|
||||
;; Package-Version: 20151209.736
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; This program 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 EMMS; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Smart Operator mode is a minor mode which automatically inserts
|
||||
;; surrounding spaces around operator symbols. For example, `='
|
||||
;; becomes ` = ', `+=' becomes ` += '. This is most handy for writing
|
||||
;; C-style source code.
|
||||
;;
|
||||
;; Type `M-x electric-spacing-mode' to toggle this minor mode.
|
||||
|
||||
;;; Acknowledgements
|
||||
|
||||
;; Nikolaj Schumacher <n_schumacher@web.de>, for suggesting
|
||||
;; reimplementing as a minor mode and providing an initial patch for
|
||||
;; that.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'cc-mode)
|
||||
(require 'thingatpt)
|
||||
|
||||
;;; electric-spacing minor mode
|
||||
|
||||
(defcustom electric-spacing-double-space-docs t
|
||||
"Enable double spacing of . in document lines - e,g, type '.' => get '. '."
|
||||
:type 'boolean
|
||||
:group 'electricity)
|
||||
|
||||
(defcustom electric-spacing-docs t
|
||||
"Enable electric-spacing in strings and comments."
|
||||
:type 'boolean
|
||||
:group 'electricity)
|
||||
|
||||
(defvar electric-spacing-rules
|
||||
'((?= . electric-spacing-self-insert-command)
|
||||
(?< . electric-spacing-<)
|
||||
(?> . electric-spacing->)
|
||||
(?% . electric-spacing-%)
|
||||
(?+ . electric-spacing-+)
|
||||
(?- . electric-spacing--)
|
||||
(?* . electric-spacing-*)
|
||||
(?/ . electric-spacing-/)
|
||||
(?& . electric-spacing-&)
|
||||
(?| . electric-spacing-self-insert-command)
|
||||
(?: . electric-spacing-:)
|
||||
(?? . electric-spacing-?)
|
||||
(?, . electric-spacing-\,)
|
||||
(?~ . electric-spacing-~)
|
||||
(?. . electric-spacing-.)
|
||||
(?^ . electric-spacing-self-insert-command)))
|
||||
|
||||
(defun electric-spacing-post-self-insert-function ()
|
||||
(when (electric-spacing-should-run?)
|
||||
(let ((rule (cdr (assq last-command-event electric-spacing-rules))))
|
||||
(when rule
|
||||
(goto-char (electric--after-char-pos))
|
||||
(delete-char -1)
|
||||
(funcall rule)))))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode electric-spacing-mode
|
||||
"Toggle automatic surrounding space insertion (Electric Spacing mode).
|
||||
With a prefix argument ARG, enable Electric Spacing mode if ARG is
|
||||
positive, and disable it otherwise. If called from Lisp, enable
|
||||
the mode if ARG is omitted or nil.
|
||||
|
||||
This is a local minor mode. When enabled, typing an operator automatically
|
||||
inserts surrounding spaces. e.g., `=' becomes ` = ',`+=' becomes ` += '. This
|
||||
is very handy for many programming languages."
|
||||
:global nil
|
||||
:group 'electricity
|
||||
:lighter " _+_"
|
||||
|
||||
;; body
|
||||
(if electric-spacing-mode
|
||||
(add-hook 'post-self-insert-hook
|
||||
#'electric-spacing-post-self-insert-function nil t)
|
||||
(remove-hook 'post-self-insert-hook
|
||||
#'electric-spacing-post-self-insert-function t)))
|
||||
|
||||
(defun electric-spacing-self-insert-command ()
|
||||
"Insert character with surrounding spaces."
|
||||
(electric-spacing-insert (string last-command-event)))
|
||||
|
||||
(defun electric-spacing-insert (op &optional only-where)
|
||||
"See `electric-spacing-insert-1'."
|
||||
(delete-horizontal-space)
|
||||
(cond ((and (electric-spacing-lispy-mode?)
|
||||
(not (electric-spacing-document?)))
|
||||
(electric-spacing-lispy op))
|
||||
(t
|
||||
(electric-spacing-insert-1 op only-where))))
|
||||
|
||||
(defun electric-spacing-insert-1 (op &optional only-where)
|
||||
"Insert operator OP with surrounding spaces.
|
||||
e.g., `=' becomes ` = ', `+=' becomes ` += '.
|
||||
|
||||
When `only-where' is 'after, we will insert space at back only;
|
||||
when `only-where' is 'before, we will insert space at front only;
|
||||
when `only-where' is 'middle, we will not insert space."
|
||||
(pcase only-where
|
||||
(`before (insert " " op))
|
||||
(`middle (insert op))
|
||||
(`after (insert op " "))
|
||||
(_
|
||||
(let ((begin? (bolp)))
|
||||
(unless (or (looking-back (regexp-opt
|
||||
(mapcar 'char-to-string
|
||||
(mapcar 'car electric-spacing-rules)))
|
||||
(line-beginning-position))
|
||||
begin?)
|
||||
(insert " "))
|
||||
(insert op " ")
|
||||
(when begin?
|
||||
(indent-according-to-mode))))))
|
||||
|
||||
(defun electric-spacing-c-types ()
|
||||
(concat c-primitive-type-key "?"))
|
||||
|
||||
(defun electric-spacing-document? ()
|
||||
(nth 8 (syntax-ppss)))
|
||||
|
||||
(defun electric-spacing-should-run? ()
|
||||
(or (not electric-spacing-docs)
|
||||
(not (electric-spacing-document?))))
|
||||
|
||||
(defun electric-spacing-lispy-mode? ()
|
||||
(derived-mode-p 'emacs-lisp-mode
|
||||
'lisp-mode
|
||||
'lisp-interaction-mode
|
||||
'scheme-mode))
|
||||
|
||||
(defun electric-spacing-lispy (op)
|
||||
"We're in a Lisp-ish mode, so let's look for parenthesis.
|
||||
Meanwhile, if not found after ( operators are more likely to be function names,
|
||||
so let's not get too insert-happy."
|
||||
(cond
|
||||
((save-excursion
|
||||
(backward-char 1)
|
||||
(looking-at "("))
|
||||
(if (equal op ",")
|
||||
(electric-spacing-insert-1 op 'middle)
|
||||
(electric-spacing-insert-1 op 'after)))
|
||||
((equal op ",")
|
||||
(electric-spacing-insert-1 op 'before))
|
||||
(t
|
||||
(electric-spacing-insert-1 op 'middle))))
|
||||
|
||||
(defconst electric-spacing-operators-regexp
|
||||
(regexp-opt
|
||||
(mapcar (lambda (el) (char-to-string (car el)))
|
||||
electric-spacing-rules)))
|
||||
|
||||
|
||||
;;; Fine Tunings
|
||||
|
||||
(defun electric-spacing-< ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond
|
||||
((or (and c-buffer-is-cc-mode
|
||||
(looking-back
|
||||
(concat "\\("
|
||||
(regexp-opt
|
||||
'("#include" "vector" "deque" "list" "map" "stack"
|
||||
"multimap" "set" "hash_map" "iterator" "template"
|
||||
"pair" "auto_ptr" "static_cast"
|
||||
"dynmaic_cast" "const_cast" "reintepret_cast"
|
||||
|
||||
"#import"))
|
||||
"\\)\\ *")
|
||||
(line-beginning-position)))
|
||||
(derived-mode-p 'sgml-mode))
|
||||
(insert "<>")
|
||||
(backward-char))
|
||||
(t
|
||||
(electric-spacing-insert "<"))))
|
||||
|
||||
(defun electric-spacing-: ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond (c-buffer-is-cc-mode
|
||||
(if (looking-back "\\?.+")
|
||||
(electric-spacing-insert ":")
|
||||
(electric-spacing-insert ":" 'middle)))
|
||||
((derived-mode-p 'haskell-mode)
|
||||
(electric-spacing-insert ":"))
|
||||
((derived-mode-p 'python-mode) (electric-spacing-python-:))
|
||||
((derived-mode-p 'ess-mode)
|
||||
(insert ":"))
|
||||
(t
|
||||
(electric-spacing-insert ":" 'after))))
|
||||
|
||||
(defun electric-spacing-\, ()
|
||||
"See `electric-spacing-insert'."
|
||||
(electric-spacing-insert "," 'after))
|
||||
|
||||
(defun electric-spacing-. ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond ((and electric-spacing-double-space-docs
|
||||
(electric-spacing-document?))
|
||||
(electric-spacing-insert "." 'after)
|
||||
(insert " "))
|
||||
((or (looking-back "[0-9]")
|
||||
(or (and c-buffer-is-cc-mode
|
||||
(looking-back "[a-z]"))
|
||||
(and
|
||||
(derived-mode-p 'python-mode 'ruby-mode)
|
||||
(looking-back "[a-z\)]"))
|
||||
(and
|
||||
(derived-mode-p 'js-mode 'js2-mode)
|
||||
(looking-back "[a-z\)$]"))))
|
||||
(insert "."))
|
||||
((derived-mode-p 'cperl-mode 'perl-mode 'ruby-mode)
|
||||
;; Check for the .. range operator
|
||||
(if (looking-back ".")
|
||||
(insert ".")
|
||||
(insert " . ")))
|
||||
(t
|
||||
(electric-spacing-insert "." 'after)
|
||||
(insert " "))))
|
||||
|
||||
(defun electric-spacing-& ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond (c-buffer-is-cc-mode
|
||||
;; ,----[ cases ]
|
||||
;; | char &a = b; // FIXME
|
||||
;; | void foo(const int& a);
|
||||
;; | char *a = &b;
|
||||
;; | int c = a & b;
|
||||
;; | a && b;
|
||||
;; `----
|
||||
(cond ((looking-back (concat (electric-spacing-c-types) " *" ))
|
||||
(electric-spacing-insert "&" 'after))
|
||||
((looking-back "= *")
|
||||
(electric-spacing-insert "&" 'before))
|
||||
(t
|
||||
(electric-spacing-insert "&"))))
|
||||
(t
|
||||
(electric-spacing-insert "&"))))
|
||||
|
||||
(defun electric-spacing-* ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond (c-buffer-is-cc-mode
|
||||
;; ,----
|
||||
;; | a * b;
|
||||
;; | char *a;
|
||||
;; | char **b;
|
||||
;; | (*a)->func();
|
||||
;; | *p++;
|
||||
;; | *a = *b;
|
||||
;; `----
|
||||
(cond ((looking-back (concat (electric-spacing-c-types) " *" ))
|
||||
(electric-spacing-insert "*" 'before))
|
||||
((looking-back "\\* *")
|
||||
(electric-spacing-insert "*" 'middle))
|
||||
((looking-back "^[ (]*")
|
||||
(electric-spacing-insert "*" 'middle)
|
||||
(indent-according-to-mode))
|
||||
((looking-back "= *")
|
||||
(electric-spacing-insert "*" 'before))
|
||||
(t
|
||||
(electric-spacing-insert "*"))))
|
||||
|
||||
;; Handle python *args and **kwargs
|
||||
((derived-mode-p 'python-mode)
|
||||
;; Can only occur after '(' ',' or on a new line, so just check
|
||||
;; for those. If it's just after a comma then also insert a space
|
||||
;; before the *.
|
||||
(cond ((looking-back ",") (insert " *"))
|
||||
((looking-back "[(,^)][ \t]*[*]?") (insert "*"))
|
||||
;; Othewise act as normal
|
||||
(t (electric-spacing-insert "*"))))
|
||||
(t
|
||||
(electric-spacing-insert "*"))))
|
||||
|
||||
(defun electric-spacing-> ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond ((and c-buffer-is-cc-mode (looking-back " - "))
|
||||
(delete-char -3)
|
||||
(insert "->"))
|
||||
(t
|
||||
(electric-spacing-insert ">"))))
|
||||
|
||||
(defun electric-spacing-+ ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond ((and c-buffer-is-cc-mode (looking-back "\\+ *"))
|
||||
(when (looking-back "[a-zA-Z0-9_] +\\+ *")
|
||||
(save-excursion
|
||||
(backward-char 2)
|
||||
(delete-horizontal-space)))
|
||||
(electric-spacing-insert "+" 'middle)
|
||||
(indent-according-to-mode))
|
||||
(t
|
||||
(electric-spacing-insert "+"))))
|
||||
|
||||
(defun electric-spacing-- ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond ((and c-buffer-is-cc-mode (looking-back "\\- *"))
|
||||
(when (looking-back "[a-zA-Z0-9_] +\\- *")
|
||||
(save-excursion
|
||||
(backward-char 2)
|
||||
(delete-horizontal-space)))
|
||||
(electric-spacing-insert "-" 'middle)
|
||||
(indent-according-to-mode))
|
||||
|
||||
;; exponent notation, e.g. 1e-10: don't space
|
||||
((looking-back "[0-9.]+[eE]")
|
||||
(insert "-"))
|
||||
|
||||
;; a = -9
|
||||
((and (looking-back (concat electric-spacing-operators-regexp " *"))
|
||||
(not (looking-back "- *")))
|
||||
(electric-spacing-insert "-" 'before))
|
||||
|
||||
(t
|
||||
(electric-spacing-insert "-"))))
|
||||
|
||||
(defun electric-spacing-? ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond (c-buffer-is-cc-mode
|
||||
(electric-spacing-insert "?"))
|
||||
(t
|
||||
(electric-spacing-insert "?" 'after))))
|
||||
|
||||
(defun electric-spacing-% ()
|
||||
"See `electric-spacing-insert'."
|
||||
(cond (c-buffer-is-cc-mode
|
||||
;; ,----
|
||||
;; | a % b;
|
||||
;; | printf("%d %d\n", a % b);
|
||||
;; `----
|
||||
(if (and (looking-back "\".*")
|
||||
(not (looking-back "\",.*")))
|
||||
(insert "%")
|
||||
(electric-spacing-insert "%")))
|
||||
;; If this is a comment or string, we most likely
|
||||
;; want no spaces - probably string formatting
|
||||
((and (derived-mode-p 'python-mode)
|
||||
(electric-spacing-document?))
|
||||
(insert "%"))
|
||||
(t
|
||||
(electric-spacing-insert "%"))))
|
||||
|
||||
(defun electric-spacing-~ ()
|
||||
"See `electric-spacing-insert'."
|
||||
;; First class regex operator =~ langs
|
||||
(cond ((derived-mode-p 'ruby-mode 'perl-mode 'cperl-mode)
|
||||
(if (looking-back "= ")
|
||||
(progn
|
||||
(delete-char -2)
|
||||
(insert "=~ "))
|
||||
(insert "~")))
|
||||
(t
|
||||
(insert "~"))))
|
||||
|
||||
(defun electric-spacing-/ ()
|
||||
"See `electric-spacing-insert'."
|
||||
;; *nix shebangs #!
|
||||
(cond ((and (eq 1 (line-number-at-pos))
|
||||
(save-excursion
|
||||
(move-beginning-of-line nil)
|
||||
(looking-at "#!")))
|
||||
(insert "/"))
|
||||
(t
|
||||
(electric-spacing-insert "/"))))
|
||||
|
||||
|
||||
(defun electric-spacing-enclosing-paren ()
|
||||
"Return the opening parenthesis of the enclosing parens, or nil if not inside any parens."
|
||||
(interactive)
|
||||
(let ((ppss (syntax-ppss)))
|
||||
(when (nth 1 ppss)
|
||||
(char-after (nth 1 ppss)))))
|
||||
|
||||
(defun electric-spacing-python-: ()
|
||||
(if (and (not (in-string-p))
|
||||
(eq (electric-spacing-enclosing-paren) ?\{))
|
||||
(electric-spacing-insert ":" 'after)
|
||||
(insert ":")))
|
||||
|
||||
(provide 'electric-spacing)
|
||||
|
||||
;;; electric-spacing.el ends here
|
674
elpa/org-20160919/COPYING
Normal file
674
elpa/org-20160919/COPYING
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 program 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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
41
elpa/org-20160919/README_ELPA
Normal file
41
elpa/org-20160919/README_ELPA
Normal file
@ -0,0 +1,41 @@
|
||||
This is the Emacs Org project, an Emacs library for organizing your life.
|
||||
|
||||
The homepage of Org is at:
|
||||
http://orgmode.org
|
||||
|
||||
Installations instructions are at:
|
||||
http://orgmode.org/org.html#Installation
|
||||
|
||||
This distribution contains an ELPA packaged version of Org.
|
||||
"ELPA" stands for the "Emacs Lisp Package Archive".
|
||||
|
||||
The GNU ELPA is at:
|
||||
http://elpa.gnu.org
|
||||
|
||||
It contains the org-*.tar package, containing only the org files
|
||||
that are also part of GNU Emacs.
|
||||
|
||||
There are other ELPA online, offering more packages.
|
||||
|
||||
Some contain the org-plus-contrib-*.tar ELPA package, which bundles
|
||||
the core Org files plus many additional contributed libraries.
|
||||
|
||||
All ELPA packages of Org contain:
|
||||
|
||||
README_ELPA
|
||||
This file.
|
||||
|
||||
*.el
|
||||
Elisp files.
|
||||
|
||||
org
|
||||
The Org info manual.
|
||||
|
||||
orgcard.pdf
|
||||
The Org reference card.
|
||||
|
||||
etc/
|
||||
Libraries for the ODT exporter.
|
||||
|
||||
org-*-pkg.el
|
||||
The name of the package, requested GNU Emacs packaging system.
|
18
elpa/org-20160919/dir
Normal file
18
elpa/org-20160919/dir
Normal file
@ -0,0 +1,18 @@
|
||||
This is the file .../info/dir, which contains the
|
||||
topmost node of the Info hierarchy, called (dir)Top.
|
||||
The first time you invoke Info you start off looking at this node.
|
||||
|
||||
File: dir, Node: Top This is the top of the INFO tree
|
||||
|
||||
This (the Directory node) gives a menu of major topics.
|
||||
Typing "q" exits, "?" lists all Info commands, "d" returns here,
|
||||
"h" gives a primer for first-timers,
|
||||
"mEmacs<Return>" visits the Emacs manual, etc.
|
||||
|
||||
In Emacs, you can click mouse button 2 on a menu item or cross reference
|
||||
to select it.
|
||||
|
||||
* Menu:
|
||||
|
||||
Emacs
|
||||
* Org Mode: (org). Outline-based notes management and organizer
|
3119
elpa/org-20160919/etc/ORG-NEWS
Normal file
3119
elpa/org-20160919/etc/ORG-NEWS
Normal file
File diff suppressed because it is too large
Load Diff
275
elpa/org-20160919/etc/styles/OrgOdtContentTemplate.xml
Normal file
275
elpa/org-20160919/etc/styles/OrgOdtContentTemplate.xml
Normal file
@ -0,0 +1,275 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- See etc/org/README for copyright information -->
|
||||
<office:document-content
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:rpt="http://openoffice.org/2005/report"
|
||||
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
|
||||
xmlns:xodt="http://www.w3.org/1999/xodt"
|
||||
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" office:version="1.2">
|
||||
<!-- scripts -->
|
||||
<office:scripts/>
|
||||
|
||||
<!-- font face declarations -->
|
||||
<office:font-face-decls>
|
||||
<style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/>
|
||||
<style:font-face style:name="courier" svg:font-family="courier, monospace"/>
|
||||
<style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="HG Mincho Light J" svg:font-family="'HG Mincho Light J'" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="Thorndale" svg:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="Albany" svg:font-family="Albany" style:font-family-generic="swiss" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="SimSun" svg:font-family="SimSun" style:font-family-generic="system" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/>
|
||||
</office:font-face-decls>
|
||||
|
||||
<!-- automatic styles -->
|
||||
<office:automatic-styles>
|
||||
|
||||
<!-- Section styles -->
|
||||
|
||||
<!-- Section styles for Table Of Contents and Other Indices -->
|
||||
<style:style style:name="OrgIndexSection" style:family="section">
|
||||
<style:section-properties fo:background-color="#c0c0c0" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
<style:background-image/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
|
||||
<!-- Indented sections, used as container for tables that occur
|
||||
within list items -->
|
||||
<style:style style:name="OrgIndentedSection-Level-1" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="1.281cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-2" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="1.905cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-3" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="2.54cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-4" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="3.175cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-5" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="3.81cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-6" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="4.445cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-7" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="5.08cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-8" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="5.715cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-9" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="6.35cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgIndentedSection-Level-10" style:family="section">
|
||||
<style:section-properties text:dont-balance-text-columns="false" fo:margin-left="6.985cm" fo:margin-right="0cm" style:editable="false">
|
||||
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
|
||||
</style:section-properties>
|
||||
</style:style>
|
||||
|
||||
<!-- Table styles -->
|
||||
<style:style style:name="OrgTable" style:family="table">
|
||||
<style:table-properties style:rel-width="96%" fo:margin-top="0cm" fo:margin-bottom="0.20cm" table:align="center"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgTableColumn" style:family="table-column">
|
||||
<style:table-column-properties style:rel-column-width="1*"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgTblCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="top" fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellL" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellT" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTL" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellB" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellBL" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellBR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellBLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTB" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTBL" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTBR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTblCellTBLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
|
||||
<style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
|
||||
<!-- BEGIN: Table styles for numbered equations -->
|
||||
<style:style style:name="OrgEquation" style:family="table">
|
||||
<style:table-properties style:rel-width="100%" fo:margin-top="0cm" fo:margin-bottom="0.20cm" table:align="center"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgEquationTableColumn" style:family="table-column">
|
||||
<style:table-column-properties style:rel-column-width="1*"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgFirstEquationFirstColumnTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="middle" fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgEquationLastColumnTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="middle" fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgEquationFirstColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgEquationLastColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<!-- END: Table styles for numbered equations -->
|
||||
|
||||
<!-- BEGIN: Custom Table Template -->
|
||||
<style:style style:name="Custom" style:family="table">
|
||||
<style:table-properties style:rel-width="80%" table:align="center"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomColumn" style:family="table-column">
|
||||
<style:table-column-properties style:rel-column-width="1*"/>
|
||||
</style:style>
|
||||
|
||||
<!-- Table Paragraph Styles -->
|
||||
<style:style style:name="CustomTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:color="#000000" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomLastRowTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:color="#000000" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomLastColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:color="#000000" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomFirstRowTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:color="#ffffff" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomFirstColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
|
||||
<style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:color="#ffffff" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
|
||||
</style:style>
|
||||
|
||||
<!-- Table Cell Styles -->
|
||||
<style:style style:name="CustomTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="top" fo:background-color="#ffffff" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
|
||||
<style:background-image/>
|
||||
</style:table-cell-properties>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomFirstRowTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="top" fo:background-color="#000080" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
|
||||
<style:background-image/>
|
||||
</style:table-cell-properties>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomLastRowTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="top" fo:background-color="#cccccc" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
|
||||
<style:background-image/>
|
||||
</style:table-cell-properties>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomFirstColumnTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="top" fo:background-color="#4d4d4d" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
|
||||
<style:background-image/>
|
||||
</style:table-cell-properties>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="CustomLastColumnTableCell" style:family="table-cell">
|
||||
<style:table-cell-properties style:vertical-align="top" fo:background-color="#cccccc" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
|
||||
<style:background-image/>
|
||||
</style:table-cell-properties>
|
||||
</style:style>
|
||||
|
||||
<!-- END: Custom Table Template -->
|
||||
|
||||
</office:automatic-styles>
|
||||
|
||||
<office:body>
|
||||
<office:text>
|
||||
<text:sequence-decls>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Equation"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Listing"/>
|
||||
</text:sequence-decls>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document-content>
|
861
elpa/org-20160919/etc/styles/OrgOdtStyles.xml
Normal file
861
elpa/org-20160919/etc/styles/OrgOdtStyles.xml
Normal file
@ -0,0 +1,861 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- See etc/org/README for copyright information -->
|
||||
<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2">
|
||||
<office:font-face-decls>
|
||||
<style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/>
|
||||
<style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/>
|
||||
<style:font-face style:name="Courier New" svg:font-family="'Courier New'" style:font-family-generic="modern" style:font-pitch="fixed"/>
|
||||
<style:font-face style:name="NSimSun" svg:font-family="NSimSun" style:font-family-generic="modern" style:font-pitch="fixed"/>
|
||||
<style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="SimSun" svg:font-family="SimSun" style:font-family-generic="system" style:font-pitch="variable"/>
|
||||
<style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/>
|
||||
</office:font-face-decls>
|
||||
<office:styles>
|
||||
<style:default-style style:family="graphic">
|
||||
<style:graphic-properties draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
|
||||
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
|
||||
<style:tab-stops/>
|
||||
</style:paragraph-properties>
|
||||
<style:text-properties style:use-window-font-color="true" fo:font-size="12pt" fo:language="en" fo:country="GB" style:letter-kerning="true" style:font-size-asian="12pt" style:language-asian="zh" style:country-asian="CN" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/>
|
||||
</style:default-style>
|
||||
<style:default-style style:family="paragraph">
|
||||
<style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
|
||||
<style:text-properties style:use-window-font-color="true" style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" fo:country="GB" style:letter-kerning="true" style:font-name-asian="SimSun" style:font-size-asian="12pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Tahoma" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
|
||||
</style:default-style>
|
||||
<style:default-style style:family="table">
|
||||
<style:table-properties table:border-model="collapsing"/>
|
||||
</style:default-style>
|
||||
<style:default-style style:family="table-row">
|
||||
<style:table-row-properties fo:keep-together="auto"/>
|
||||
</style:default-style>
|
||||
|
||||
<!-- Outline numbering -->
|
||||
<text:outline-style style:name="OrgOutline">
|
||||
<text:outline-level-style text:level="1" style:num-suffix=". " style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-0.762cm" fo:margin-left="0.762cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="2" style:num-suffix=". " style:num-format="1" text:display-levels="2">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.016cm" fo:margin-left="1.016cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="3" style:num-suffix=". " style:num-format="1" text:display-levels="3">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.27cm" fo:margin-left="1.27cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="4" style:num-suffix=". " style:num-format="1" text:display-levels="4">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.524cm" fo:margin-left="1.524cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="5" style:num-suffix=". " style:num-format="1" text:display-levels="5">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.778cm" fo:margin-left="1.778cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="6" style:num-suffix=". " style:num-format="1" text:display-levels="6">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.032cm" fo:margin-left="2.032cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="7" style:num-suffix=". " style:num-format="1" text:display-levels="7">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.286cm" fo:margin-left="2.286cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="8" style:num-suffix=". " style:num-format="1" text:display-levels="8">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.54cm" fo:margin-left="2.54cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="9" style:num-suffix=". " style:num-format="1" text:display-levels="9">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.794cm" fo:margin-left="2.794cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="10" style:num-suffix=". " style:num-format="1" text:display-levels="10">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-3.048cm" fo:margin-left="3.048cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:outline-level-style>
|
||||
</text:outline-style>
|
||||
|
||||
<style:style style:name="Standard" style:family="paragraph" style:class="text"/>
|
||||
<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="17cm" style:type="right"/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
<style:text-properties style:font-name="Arial" fo:font-size="14pt" style:font-name-asian="SimSun" style:font-size-asian="14pt" style:font-name-complex="Tahoma" style:font-size-complex="14pt"/>
|
||||
</style:style>
|
||||
<style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm"/>
|
||||
</style:style>
|
||||
<style:style style:name="List" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="list">
|
||||
<style:text-properties style:font-name-complex="Tahoma1"/>
|
||||
</style:style>
|
||||
<style:style style:name="Caption" style:family="paragraph" style:parent-style-name="Standard" style:class="extra">
|
||||
<style:paragraph-properties fo:margin-top="0.212cm" fo:margin-bottom="0.212cm" text:number-lines="false" text:line-number="0"/>
|
||||
<style:text-properties fo:font-size="12pt" fo:font-style="italic" style:font-size-asian="12pt" style:font-style-asian="italic" style:font-name-complex="Tahoma1" style:font-size-complex="12pt" style:font-style-complex="italic"/>
|
||||
</style:style>
|
||||
<style:style style:name="Index" style:family="paragraph" style:parent-style-name="Standard" style:class="index">
|
||||
<style:paragraph-properties text:number-lines="false" text:line-number="0"/>
|
||||
<style:text-properties style:font-name-complex="Tahoma1"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="1" style:class="text">
|
||||
<style:text-properties fo:font-size="115%" fo:font-weight="bold" style:font-size-asian="115%" style:font-weight-asian="bold" style:font-size-complex="115%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_1_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_1" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_2" style:display-name="Heading 2" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="2" style:class="text">
|
||||
<style:text-properties fo:font-size="14pt" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="14pt" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-style-complex="italic" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_2_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_2" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_3" style:display-name="Heading 3" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="3" style:class="text">
|
||||
<style:text-properties fo:font-size="14pt" fo:font-weight="bold" style:font-size-asian="14pt" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_3_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_3" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_4" style:display-name="Heading 4" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="4" style:class="text">
|
||||
<style:text-properties fo:font-size="85%" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="85%" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="85%" style:font-style-complex="italic" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_4_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_4" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_5" style:display-name="Heading 5" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="5" style:class="text">
|
||||
<style:text-properties fo:font-size="85%" fo:font-weight="bold" style:font-size-asian="85%" style:font-weight-asian="bold" style:font-size-complex="85%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_5_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_5" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_6" style:display-name="Heading 6" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="6" style:class="text">
|
||||
<style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_6_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_6" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_7" style:display-name="Heading 7" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="7" style:class="text">
|
||||
<style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_7_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_7" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_8" style:display-name="Heading 8" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="8" style:class="text">
|
||||
<style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_8_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_8" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_9" style:display-name="Heading 9" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="9" style:class="text">
|
||||
<style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_9_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_9" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_10" style:display-name="Heading 10" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="10" style:class="text">
|
||||
<style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_10_unnumbered" style:family="paragraph" style:parent-style-name="Heading_20_10" style:list-style-name="">
|
||||
</style:style>
|
||||
<style:style style:name="Heading_20_1.title" style:display-name="Heading 1.title" style:family="paragraph" style:parent-style-name="Heading_20_1">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="Title" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Subtitle" style:class="chapter">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:font-size="18pt" fo:font-weight="bold" style:font-size-asian="18pt" style:font-weight-asian="bold" style:font-size-complex="18pt" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTitle" style:family="paragraph" style:parent-style-name="Title">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
|
||||
<style:text-properties fo:font-size="24pt"/>
|
||||
</style:style>
|
||||
<style:style style:name="Subtitle" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:class="chapter">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
<style:text-properties fo:font-size="14pt" fo:font-style="italic" style:font-size-asian="14pt" style:font-style-asian="italic" style:font-size-complex="14pt" style:font-style-complex="italic"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgSubtitle" style:family="paragraph" style:parent-style-name="Subtitle">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
|
||||
<style:text-properties fo:font-size="20pt"/>
|
||||
</style:style>
|
||||
<style:style style:name="Text_20_body_20_indent" style:display-name="Text body indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="List_20_Indent" style:display-name="List Indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-left="5.001cm" fo:margin-right="0cm" fo:text-indent="-4.5cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="0cm"/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="First_20_line_20_indent" style:display-name="First line indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0.499cm" style:auto-text-indent="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="Hanging_20_indent" style:display-name="Hanging indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="-0.499cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="0cm"/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Salutation" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
|
||||
<style:paragraph-properties text:number-lines="false" text:line-number="0"/>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_Heading" style:display-name="Contents Heading" style:family="paragraph" style:parent-style-name="Heading" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/>
|
||||
<style:text-properties fo:font-size="16pt" fo:font-weight="bold" style:font-size-asian="16pt" style:font-weight-asian="bold" style:font-size-complex="16pt" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_1" style:display-name="Contents 1" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="17cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_2" style:display-name="Contents 2" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="16.501cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_3" style:display-name="Contents 3" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="0.998cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="16.002cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_4" style:display-name="Contents 4" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="1.498cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="15.503cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_5" style:display-name="Contents 5" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="1.997cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="15.004cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_6" style:display-name="Contents 6" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="2.496cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="14.504cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_7" style:display-name="Contents 7" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="2.995cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="14.005cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_8" style:display-name="Contents 8" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="3.494cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="13.506cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_9" style:display-name="Contents 9" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="3.993cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="13.007cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Contents_20_10" style:display-name="Contents 10" style:family="paragraph" style:parent-style-name="Index" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="4.493cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="12.508cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Quotations" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
|
||||
<style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgFootnoteQuotations" style:family="paragraph" style:parent-style-name="Footnote" style:class="html">
|
||||
<style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="Preformatted_20_Text" style:display-name="Preformatted Text" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
|
||||
<style:text-properties style:font-name="Courier New" fo:font-size="10pt" style:font-name-asian="NSimSun" style:font-size-asian="10pt" style:font-name-complex="Courier New" style:font-size-complex="10pt"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgVerse" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
|
||||
<style:paragraph-properties fo:background-color="transparent" fo:padding="0cm" fo:border="none" style:shadow="none">
|
||||
<style:background-image/>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgClock" style:family="paragraph" style:parent-style-name="Text_20_body">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgClockLastLine" style:family="paragraph" style:parent-style-name="OrgClock"/>
|
||||
<style:style style:name="OrgPlanning" style:family="paragraph" style:parent-style-name="Text_20_body"/>
|
||||
|
||||
<!-- Fixed width block -->
|
||||
<style:style style:name="OrgFixedWidthBlock" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
|
||||
<style:paragraph-properties fo:background-color="#c0c0c0" fo:padding="0.049cm" fo:border="0.06pt solid #000000" style:shadow="none">
|
||||
<style:background-image/>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="OrgFixedWidthBlockLastLine" style:family="paragraph" style:parent-style-name="OrgFixedWidthBlock">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgFormula" style:family="paragraph" style:parent-style-name="Text_20_body">
|
||||
<style:paragraph-properties>
|
||||
<style:tab-stops>
|
||||
<style:tab-stop style:position="17cm" style:type="right"/>
|
||||
</style:tab-stops>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgSrcBlockLastLine" style:family="paragraph" style:parent-style-name="OrgSrcBlock">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgCenter" style:family="paragraph" style:parent-style-name="Text_20_body">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgFootnoteCenter" style:family="paragraph" style:parent-style-name="Footnote">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTableContents" style:family="paragraph" style:parent-style-name="Text_20_body"/>
|
||||
<style:style style:name="OrgTableHeading" style:family="paragraph" style:parent-style-name="OrgTableContents" style:class="extra">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false" text:number-lines="false" text:line-number="0"/>
|
||||
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgTableHeadingLeft" style:family="paragraph" style:parent-style-name="OrgTableHeading">
|
||||
<style:paragraph-properties fo:text-align="left" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTableHeadingRight" style:family="paragraph" style:parent-style-name="OrgTableHeading">
|
||||
<style:paragraph-properties fo:text-align="right" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTableHeadingCenter" style:family="paragraph" style:parent-style-name="OrgTableHeading">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgTableContentsLeft" style:family="paragraph" style:parent-style-name="OrgTableContents">
|
||||
<style:paragraph-properties fo:text-align="left" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTableContentsRight" style:family="paragraph" style:parent-style-name="OrgTableContents">
|
||||
<style:paragraph-properties fo:text-align="right" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTableContentsCenter" style:family="paragraph" style:parent-style-name="OrgTableContents">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="Text_20_body_20_bold" style:display-name="Text body bold" style:family="paragraph" style:parent-style-name="Text_20_body" style:next-style-name="Text_20_body">
|
||||
<style:text-properties fo:font-weight="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Footnote" style:family="paragraph" style:parent-style-name="Standard" style:class="extra">
|
||||
<style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="-0.499cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/>
|
||||
<style:text-properties fo:font-size="10pt" style:font-size-asian="10pt" style:font-size-complex="10pt"/>
|
||||
</style:style>
|
||||
<style:style style:name="Figure" style:family="paragraph" style:parent-style-name="Caption"/>
|
||||
<style:style style:name="Illustration_20_Index_20_Heading" style:display-name="Illustration Index Heading" style:family="paragraph" style:parent-style-name="Heading" style:class="index">
|
||||
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/>
|
||||
<style:text-properties fo:font-size="16pt" fo:font-weight="bold" style:font-size-asian="16pt" style:font-weight-asian="bold" style:font-size-complex="16pt" style:font-weight-complex="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Table" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:style style:name="Listing" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
|
||||
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" fo:keep-with-next="always">
|
||||
<style:tab-stops/>
|
||||
</style:paragraph-properties>
|
||||
</style:style>
|
||||
<style:style style:name="Horizontal_20_Line" style:display-name="Horizontal Line" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="html">
|
||||
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm" style:page-number="auto" fo:padding="0cm" fo:border-left="none" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.06pt solid #000000" style:shadow="none" text:number-lines="false" text:line-number="0" style:join-border="false"/>
|
||||
<style:text-properties fo:font-size="6pt" style:font-size-asian="6pt" style:font-size-complex="6pt"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="Emphasis" style:family="text">
|
||||
<style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/>
|
||||
</style:style>
|
||||
<style:style style:name="Underline" style:family="text">
|
||||
<style:text-properties style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" fo:background-color="transparent"/>
|
||||
</style:style>
|
||||
<style:style style:name="Strikethrough" style:family="text">
|
||||
<style:text-properties style:text-line-through-style="solid"/>
|
||||
</style:style>
|
||||
<style:style style:name="Source_20_Text" style:display-name="Source Text" style:family="text">
|
||||
<style:text-properties style:font-name="Courier New" fo:background-color="transparent" style:font-name-asian="NSimSun" style:font-name-complex="Courier New"/>
|
||||
</style:style>
|
||||
<style:style style:name="Citation" style:family="text">
|
||||
<style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/>
|
||||
</style:style>
|
||||
<style:style style:name="Example" style:family="text">
|
||||
<style:text-properties style:font-name="Courier New" fo:background-color="transparent" style:font-name-asian="NSimSun" style:font-name-complex="Courier New"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgCode" style:family="text" style:parent-style-name="Source_20_Text"/>
|
||||
|
||||
<!-- BEGIN: Org Agenda Styles -->
|
||||
<style:style style:name="OrgTodo" style:family="text"/>
|
||||
<style:style style:name="OrgDone" style:family="text"/>
|
||||
|
||||
<style:style style:name="OrgTag" style:family="text">
|
||||
<style:text-properties fo:font-variant="small-caps" fo:background-color="transparent"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgTags" style:family="text"/>
|
||||
|
||||
<style:style style:name="OrgPriority" style:family="text"/>
|
||||
<style:style style:name="OrgPriority-A" style:family="text" style:parent-style-name="OrgPriority"/>
|
||||
<style:style style:name="OrgPriority-B" style:family="text" style:parent-style-name="OrgPriority"/>
|
||||
<style:style style:name="OrgPriority-C" style:family="text" style:parent-style-name="OrgPriority"/>
|
||||
|
||||
<style:style style:name="OrgTimestamp" style:display-name="OrgTimestamp" style:family="text">
|
||||
<style:text-properties style:font-name="Courier New" fo:background-color="transparent" style:font-name-asian="NSimSun" style:font-name-complex="Courier New"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgActiveTimestamp" style:family="text" style:parent-style-name="OrgTimestamp"/>
|
||||
<style:style style:name="OrgInactiveTimestamp" style:family="text" style:parent-style-name="OrgTimestamp"/>
|
||||
<style:style style:name="OrgTimestampKeyword" style:family="text">
|
||||
<style:text-properties style:use-window-font-color="true" fo:font-weight="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgScheduledKeyword" style:family="text" style:parent-style-name="OrgTimestampKeyword"/>
|
||||
<style:style style:name="OrgDeadlineKeyword" style:family="text" style:parent-style-name="OrgTimestampKeyword"/>
|
||||
<style:style style:name="OrgClockKeyword" style:family="text" style:parent-style-name="OrgTimestampKeyword"/>
|
||||
<style:style style:name="OrgClosedKeyword" style:family="text" style:parent-style-name="OrgTimestampKeyword"/>
|
||||
<style:style style:name="OrgTimestampWrapper" style:family="text"/>
|
||||
<style:style style:name="OrgTarget" style:family="text"/>
|
||||
|
||||
<number:date-style style:name="OrgDate" number:automatic-order="true">
|
||||
<number:day number:style="long"/>
|
||||
<number:text>/</number:text>
|
||||
<number:month number:style="long"/>
|
||||
<number:text>/</number:text>
|
||||
<number:year number:style="long"/>
|
||||
</number:date-style>
|
||||
<!-- END: Org Agenda Styles -->
|
||||
|
||||
<style:style style:name="Bold" style:family="text">
|
||||
<style:text-properties fo:font-weight="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="Numbering_20_Symbols" style:display-name="Numbering Symbols" style:family="text"/>
|
||||
<style:style style:name="Footnote_20_Symbol" style:display-name="Footnote Symbol" style:family="text"/>
|
||||
<style:style style:name="Footnote_20_anchor" style:display-name="Footnote anchor" style:family="text">
|
||||
<style:text-properties style:text-position="super 58%"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgSuperscript" style:family="text">
|
||||
<style:text-properties style:text-position="super 58%"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgSubscript" style:family="text">
|
||||
<style:text-properties style:text-position="sub 58%"/>
|
||||
</style:style>
|
||||
<style:style style:name="Internet_20_link" style:display-name="Internet link" style:family="text">
|
||||
<style:text-properties fo:color="#000080" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/>
|
||||
</style:style>
|
||||
<style:style style:name="Graphics" style:family="graphic">
|
||||
<style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
|
||||
</style:style>
|
||||
<style:style style:name="Frame" style:family="graphic">
|
||||
<style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" fo:margin-top="0.201cm" fo:margin-bottom="0.201cm" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0.15cm" fo:border="0.002cm solid #000000"/>
|
||||
</style:style>
|
||||
|
||||
<!-- Simple Images -->
|
||||
<style:style style:name="OrgDisplayImage" style:family="graphic" style:parent-style-name="Graphics">
|
||||
<style:graphic-properties text:anchor-type="paragraph" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgPageImage" style:family="graphic" style:parent-style-name="Graphics">
|
||||
<style:graphic-properties text:anchor-type="page" fo:margin-top="0.21cm" fo:margin-bottom="0.21cm" style:vertical-pos="middle" style:vertical-rel="page" style:horizontal-pos="center" style:horizontal-rel="page" fo:background-color="transparent" style:background-transparency="100%" style:shadow="none" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard">
|
||||
<style:background-image/>
|
||||
</style:graphic-properties>
|
||||
</style:style>
|
||||
|
||||
<!-- Captioned Images -->
|
||||
<style:style style:name="OrgCaptionedImage" style:family="graphic" style:parent-style-name="Graphics">
|
||||
<style:graphic-properties style:rel-width="100%" text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" style:vertical-rel="paragraph-content" style:horizontal-pos="from-left" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none" style:shadow="none"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgImageCaptionFrame" style:family="graphic" style:parent-style-name="Frame">
|
||||
<style:graphic-properties text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0cm" fo:border="none"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgPageImageCaptionFrame" style:family="graphic" style:parent-style-name="Frame">
|
||||
<style:graphic-properties text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.21cm" fo:margin-bottom="0.21cm" style:wrap="none" style:vertical-pos="middle" style:vertical-rel="page" style:horizontal-pos="center" style:horizontal-rel="page" fo:background-color="transparent" style:background-transparency="100%" fo:padding="0cm" fo:border="none" style:shadow="none">
|
||||
<style:background-image/>
|
||||
</style:graphic-properties>
|
||||
</style:style>
|
||||
|
||||
<!-- Inlined Images -->
|
||||
<style:style style:name="OrgInlineImage" style:family="graphic" style:parent-style-name="Graphics">
|
||||
<style:graphic-properties text:anchor-type="as-char" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
|
||||
</style:style>
|
||||
|
||||
<!-- Inline Formula -->
|
||||
<style:style style:name="OrgFormula" style:family="graphic">
|
||||
<style:graphic-properties text:anchor-type="as-char" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" style:vertical-pos="middle" style:vertical-rel="text" style:shadow="none"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgInlineFormula" style:family="graphic" style:parent-style-name="Formula">
|
||||
<style:graphic-properties text:anchor-type="as-char" fo:margin-left="0.201cm" fo:margin-right="0.201cm" style:vertical-pos="middle" style:vertical-rel="text"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgInlineFormula" style:family="graphic" style:parent-style-name="Formula">
|
||||
<style:graphic-properties style:vertical-pos="middle" style:vertical-rel="text" draw:ole-draw-aspect="1"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgDisplayFormula" style:family="graphic" style:parent-style-name="OrgFormula">
|
||||
<style:graphic-properties style:vertical-pos="middle" style:vertical-rel="text" style:horizontal-pos="from-left" style:horizontal-rel="paragraph-content" draw:ole-draw-aspect="1"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgFormulaCaptionFrame" style:family="graphic" style:parent-style-name="Frame">
|
||||
<style:graphic-properties text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="right" style:number-wrapped-paragraphs="1" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0cm" fo:border="none"/>
|
||||
</style:style>
|
||||
|
||||
<style:style style:name="OrgCaptionedFormula" style:family="graphic" style:parent-style-name="OrgFormula">
|
||||
<style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none" style:shadow="none" draw:ole-draw-aspect="1"/>
|
||||
</style:style>
|
||||
|
||||
<!-- Inline Tasks -->
|
||||
<style:style style:name="OrgInlineTaskHeading" style:family="paragraph" style:parent-style-name="Caption" style:next-style-name="Text_20_body">
|
||||
<style:text-properties style:font-name="Arial1" fo:font-style="normal" fo:font-weight="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="OrgInlineTaskFrame" style:family="graphic" style:parent-style-name="Frame">
|
||||
<style:graphic-properties svg:x="0cm" svg:y="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:background-color="#ffffcc" style:background-transparency="0%" fo:padding="0.15cm" fo:border="0.26pt solid #000000" style:shadow="none">
|
||||
<style:background-image/>
|
||||
</style:graphic-properties>
|
||||
</style:style>
|
||||
|
||||
<text:list-style style:name="Numbering_20_1" style:display-name="Numbering 1">
|
||||
<text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.499cm" fo:text-indent="-0.499cm" fo:margin-left="0.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1cm" fo:text-indent="-0.499cm" fo:margin-left="1cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.499cm" fo:text-indent="-0.499cm" fo:margin-left="1.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="4" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.499cm" fo:margin-left="2cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="5" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.499cm" fo:text-indent="-0.499cm" fo:margin-left="2.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="6" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3cm" fo:text-indent="-0.499cm" fo:margin-left="3cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="7" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5cm" fo:text-indent="-0.499cm" fo:margin-left="3.5cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="8" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.499cm" fo:margin-left="4.001cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="9" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5cm" fo:text-indent="-0.499cm" fo:margin-left="4.5cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="10" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.001cm" fo:text-indent="-0.499cm" fo:margin-left="5.001cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>
|
||||
<text:list-style style:name="List_20_1" style:display-name="List 1">
|
||||
<text:list-level-style-bullet text:level="1" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.4cm" fo:text-indent="-0.4cm" fo:margin-left="0.4cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="2" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.801cm" fo:text-indent="-0.4cm" fo:margin-left="0.801cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="3" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.199cm" fo:text-indent="-0.4cm" fo:margin-left="1.199cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="4" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.6cm" fo:text-indent="-0.4cm" fo:margin-left="1.6cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="5" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.4cm" fo:margin-left="2cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="6" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.401cm" fo:text-indent="-0.4cm" fo:margin-left="2.401cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="7" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.799cm" fo:text-indent="-0.4cm" fo:margin-left="2.799cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="8" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.2cm" fo:text-indent="-0.4cm" fo:margin-left="3.2cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="9" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.6cm" fo:text-indent="-0.4cm" fo:margin-left="3.6cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="10" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.4cm" fo:margin-left="4.001cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
</text:list-style>
|
||||
|
||||
<!-- Numbered List -->
|
||||
<text:list-style style:name="OrgNumberedList">
|
||||
<text:list-level-style-number text:level="1" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="2" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="3" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="4" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="5" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="6" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="7" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="8" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="9" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="10" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>
|
||||
|
||||
<!-- Bulleted List -->
|
||||
<text:list-style style:name="OrgBulletedList">
|
||||
<text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
|
||||
<style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm"/>
|
||||
<style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
</text:list-style>
|
||||
|
||||
<!-- Description List -->
|
||||
<text:list-style style:name="OrgDescriptionList">
|
||||
<text:list-level-style-number text:level="1" style:num-format="">
|
||||
<style:list-level-properties text:space-before="0.635cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="2" style:num-format="">
|
||||
<style:list-level-properties text:space-before="1.27cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="3" style:num-format="">
|
||||
<style:list-level-properties text:space-before="1.905cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="4" style:num-format="">
|
||||
<style:list-level-properties text:space-before="2.54cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="5" style:num-format="">
|
||||
<style:list-level-properties text:space-before="3.175cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="6" style:num-format="">
|
||||
<style:list-level-properties text:space-before="3.81cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="7" style:num-format="">
|
||||
<style:list-level-properties text:space-before="4.445cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="8" style:num-format="">
|
||||
<style:list-level-properties text:space-before="5.08cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="9" style:num-format="">
|
||||
<style:list-level-properties text:space-before="5.715cm"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="10" style:num-format="">
|
||||
<style:list-level-properties text:space-before="6.35cm"/>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>
|
||||
|
||||
<text:list-style style:name="OrgSrcBlockNumberedLine">
|
||||
<text:list-level-style-number text:level="1" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="2" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="3" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="4" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="5" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="6" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="7" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="8" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="9" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="10" style:num-format="1">
|
||||
<style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>
|
||||
|
||||
<text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_20_Symbol" text:citation-body-style-name="Footnote_20_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
|
||||
<text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/>
|
||||
<text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
|
||||
</office:styles>
|
||||
<office:automatic-styles>
|
||||
<style:style style:name="MP1" style:family="paragraph" style:parent-style-name="Footer">
|
||||
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
|
||||
</style:style>
|
||||
<style:page-layout style:name="Mpm1" style:page-usage="mirrored">
|
||||
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
|
||||
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
|
||||
</style:page-layout-properties>
|
||||
<style:header-style/>
|
||||
<style:footer-style>
|
||||
<style:header-footer-properties fo:min-height="0.6cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" style:dynamic-spacing="false"/>
|
||||
</style:footer-style>
|
||||
</style:page-layout>
|
||||
<style:page-layout style:name="Mpm2">
|
||||
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
|
||||
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
|
||||
</style:page-layout-properties>
|
||||
<style:header-style/>
|
||||
<style:footer-style/>
|
||||
</style:page-layout>
|
||||
<style:page-layout style:name="Mpm3" style:page-usage="mirrored">
|
||||
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="i" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
|
||||
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
|
||||
</style:page-layout-properties>
|
||||
<style:header-style/>
|
||||
<style:footer-style>
|
||||
<style:header-footer-properties fo:min-height="0cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm"/>
|
||||
</style:footer-style>
|
||||
</style:page-layout>
|
||||
<style:page-layout style:name="Mpm4" style:page-usage="right">
|
||||
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" fo:background-color="transparent" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
|
||||
<style:background-image/>
|
||||
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
|
||||
</style:page-layout-properties>
|
||||
<style:header-style/>
|
||||
<style:footer-style>
|
||||
<style:header-footer-properties fo:min-height="0.6cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" style:dynamic-spacing="false"/>
|
||||
</style:footer-style>
|
||||
</style:page-layout>
|
||||
<style:page-layout style:name="Mpm5" style:page-usage="mirrored">
|
||||
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
|
||||
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
|
||||
</style:page-layout-properties>
|
||||
<style:header-style/>
|
||||
<style:footer-style>
|
||||
<style:header-footer-properties fo:min-height="0.6cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" style:dynamic-spacing="false"/>
|
||||
</style:footer-style>
|
||||
</style:page-layout>
|
||||
</office:automatic-styles>
|
||||
<office:master-styles>
|
||||
<style:master-page style:name="Standard" style:page-layout-name="Mpm1">
|
||||
<style:footer>
|
||||
<text:p text:style-name="MP1"><text:page-number text:select-page="current"></text:page-number></text:p>
|
||||
</style:footer>
|
||||
</style:master-page>
|
||||
<style:master-page style:name="OrgTitlePage" style:page-layout-name="Mpm2" style:next-style-name="OrgFrontMatterPage"/>
|
||||
<style:master-page style:name="OrgFrontMatterPage" style:page-layout-name="Mpm3">
|
||||
<style:footer>
|
||||
<text:p text:style-name="MP1"><text:page-number text:select-page="current"/></text:p>
|
||||
</style:footer>
|
||||
</style:master-page>
|
||||
<style:master-page style:name="OrgFirstPage" style:page-layout-name="Mpm4" style:next-style-name="OrgPage">
|
||||
<style:footer>
|
||||
<text:p text:style-name="MP1"><text:page-number text:select-page="current"/></text:p>
|
||||
</style:footer>
|
||||
</style:master-page>
|
||||
<style:master-page style:name="OrgPage" style:page-layout-name="Mpm5">
|
||||
<style:footer>
|
||||
<text:p text:style-name="MP1"><text:page-number text:select-page="current"/></text:p>
|
||||
</style:footer>
|
||||
</style:master-page>
|
||||
</office:master-styles>
|
||||
</office:document-styles>
|
36
elpa/org-20160919/etc/styles/README
Normal file
36
elpa/org-20160919/etc/styles/README
Normal file
@ -0,0 +1,36 @@
|
||||
The files OrgOdtContentTemplate.xml and OrgOdtStyles.xml have the
|
||||
following copyright information:
|
||||
|
||||
Copyright (C) 2010-2014 Free Software Foundation, Inc.
|
||||
|
||||
These files are 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
Author: Jambunathan K <kjambunathan at gmail dot com>
|
||||
Keywords: outlines, hypermedia, calendar, wp
|
||||
Homepage: http://orgmode.org
|
||||
|
||||
Commentary:
|
||||
|
||||
These files are part of Org-mode's OpenDocument export module.
|
||||
|
||||
OrgOdtContentTemplate.xml provides a template within which the content
|
||||
of an exported document is enclosed. This file contributes to
|
||||
"content.xml" file within an exported document and acts as a
|
||||
repository of automatic styles.
|
||||
|
||||
OrgOdtStyles.xml contributes to "styles.xml" file within an exported
|
||||
document and acts as a repository of custom styles.
|
439
elpa/org-20160919/ob-C.el
Normal file
439
elpa/org-20160919/ob-C.el
Normal file
@ -0,0 +1,439 @@
|
||||
;;; ob-C.el --- org-babel functions for C and similar languages
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Thierry Banel
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating C, C++, D code.
|
||||
;;
|
||||
;; very limited implementation:
|
||||
;; - currently only support :results output
|
||||
;; - not much in the way of error feedback
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'cc-mode)
|
||||
|
||||
(declare-function org-entry-get "org"
|
||||
(pom property &optional inherit literal-nil))
|
||||
(declare-function org-remove-indentation "org" (code &optional n))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("C++" . "cpp"))
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("D" . "d"))
|
||||
|
||||
(defvar org-babel-default-header-args:C '())
|
||||
|
||||
(defcustom org-babel-C-compiler "gcc"
|
||||
"Command used to compile a C source code file into an executable.
|
||||
May be either a command in the path, like gcc
|
||||
or an absolute path name, like /usr/local/bin/gcc
|
||||
parameter may be used, like gcc -v"
|
||||
:group 'org-babel
|
||||
:version "24.3"
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-C++-compiler "g++"
|
||||
"Command used to compile a C++ source code file into an executable.
|
||||
May be either a command in the path, like g++
|
||||
or an absolute path name, like /usr/local/bin/g++
|
||||
parameter may be used, like g++ -v"
|
||||
:group 'org-babel
|
||||
:version "24.3"
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-D-compiler "rdmd"
|
||||
"Command used to compile and execute a D source code file.
|
||||
May be either a command in the path, like rdmd
|
||||
or an absolute path name, like /usr/local/bin/rdmd
|
||||
parameter may be used, like rdmd --chatty"
|
||||
:group 'org-babel
|
||||
:version "24.3"
|
||||
:type 'string)
|
||||
|
||||
(defvar org-babel-c-variant nil
|
||||
"Internal variable used to hold which type of C (e.g. C or C++ or D)
|
||||
is currently being evaluated.")
|
||||
|
||||
(defun org-babel-execute:cpp (body params)
|
||||
"Execute BODY according to PARAMS.
|
||||
This function calls `org-babel-execute:C++'."
|
||||
(org-babel-execute:C++ body params))
|
||||
|
||||
(defun org-babel-expand-body:cpp (body params)
|
||||
"Expand a block of C++ code with org-babel according to its
|
||||
header arguments."
|
||||
(org-babel-expand-body:C++ body params))
|
||||
|
||||
(defun org-babel-execute:C++ (body params)
|
||||
"Execute a block of C++ code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((org-babel-c-variant 'cpp)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:C++ (body params)
|
||||
"Expand a block of C++ code with org-babel according to its
|
||||
header arguments."
|
||||
(let ((org-babel-c-variant 'cpp)) (org-babel-C-expand-C++ body params)))
|
||||
|
||||
(defun org-babel-execute:D (body params)
|
||||
"Execute a block of D code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((org-babel-c-variant 'd)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:D (body params)
|
||||
"Expand a block of D code with org-babel according to its
|
||||
header arguments."
|
||||
(let ((org-babel-c-variant 'd)) (org-babel-C-expand-D body params)))
|
||||
|
||||
(defun org-babel-execute:C (body params)
|
||||
"Execute a block of C code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((org-babel-c-variant 'c)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:C (body params)
|
||||
"Expand a block of C code with org-babel according to its
|
||||
header arguments."
|
||||
(let ((org-babel-c-variant 'c)) (org-babel-C-expand-C body params)))
|
||||
|
||||
(defun org-babel-C-execute (body params)
|
||||
"This function should only be called by `org-babel-execute:C'
|
||||
or `org-babel-execute:C++' or `org-babel-execute:D'."
|
||||
(let* ((tmp-src-file (org-babel-temp-file
|
||||
"C-src-"
|
||||
(case org-babel-c-variant
|
||||
(c ".c" )
|
||||
(cpp ".cpp")
|
||||
(d ".d" ))))
|
||||
(tmp-bin-file (org-babel-temp-file "C-bin-" org-babel-exeext)) ;; not used for D
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(cmdline (if cmdline (concat " " cmdline) ""))
|
||||
(flags (cdr (assoc :flags params)))
|
||||
(flags (mapconcat 'identity
|
||||
(if (listp flags) flags (list flags)) " "))
|
||||
(full-body
|
||||
(case org-babel-c-variant
|
||||
(c (org-babel-C-expand-C body params))
|
||||
(cpp (org-babel-C-expand-C++ body params))
|
||||
(d (org-babel-C-expand-D body params)))))
|
||||
(with-temp-file tmp-src-file (insert full-body))
|
||||
(case org-babel-c-variant
|
||||
((c cpp)
|
||||
(org-babel-eval
|
||||
(format "%s -o %s %s %s"
|
||||
(case org-babel-c-variant
|
||||
(c org-babel-C-compiler)
|
||||
(cpp org-babel-C++-compiler))
|
||||
(org-babel-process-file-name tmp-bin-file)
|
||||
flags
|
||||
(org-babel-process-file-name tmp-src-file)) ""))
|
||||
(d nil)) ;; no separate compilation for D
|
||||
(let ((results
|
||||
(org-babel-eval
|
||||
(case org-babel-c-variant
|
||||
((c cpp)
|
||||
(concat tmp-bin-file cmdline))
|
||||
(d
|
||||
(format "%s %s %s %s"
|
||||
org-babel-D-compiler
|
||||
flags
|
||||
(org-babel-process-file-name tmp-src-file)
|
||||
cmdline)))
|
||||
"")))
|
||||
(when results
|
||||
(setq results (org-babel-trim (org-remove-indentation results)))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(org-babel-read results t)
|
||||
(let ((tmp-file (org-babel-temp-file "c-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
|
||||
)))
|
||||
|
||||
(defun org-babel-C-expand-C++ (body params)
|
||||
"Expand a block of C or C++ code with org-babel according to
|
||||
its header arguments."
|
||||
(org-babel-C-expand-C body params))
|
||||
|
||||
(defun org-babel-C-expand-C (body params)
|
||||
"Expand a block of C or C++ code with org-babel according to
|
||||
its header arguments."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(colnames (cdar (org-babel-get-header params :colname-names)))
|
||||
(main-p (not (string= (cdr (assoc :main params)) "no")))
|
||||
(includes (org-babel-read
|
||||
(or (cdr (assoc :includes params))
|
||||
(org-entry-get nil "includes" t))
|
||||
nil))
|
||||
(defines (org-babel-read
|
||||
(or (cdr (assoc :defines params))
|
||||
(org-entry-get nil "defines" t))
|
||||
nil)))
|
||||
(when (stringp includes)
|
||||
(setq includes (split-string includes)))
|
||||
(when (stringp defines)
|
||||
(let ((y nil)
|
||||
(result (list t)))
|
||||
(dolist (x (split-string defines))
|
||||
(if (null y)
|
||||
(setq y x)
|
||||
(nconc result (list (concat y " " x)))
|
||||
(setq y nil)))
|
||||
(setq defines (cdr result))))
|
||||
(mapconcat 'identity
|
||||
(list
|
||||
;; includes
|
||||
(mapconcat
|
||||
(lambda (inc) (format "#include %s" inc))
|
||||
includes "\n")
|
||||
;; defines
|
||||
(mapconcat
|
||||
(lambda (inc) (format "#define %s" inc))
|
||||
(if (listp defines) defines (list defines)) "\n")
|
||||
;; variables
|
||||
(mapconcat 'org-babel-C-var-to-C vars "\n")
|
||||
;; table sizes
|
||||
(mapconcat 'org-babel-C-table-sizes-to-C vars "\n")
|
||||
;; tables headers utility
|
||||
(when colnames
|
||||
(org-babel-C-utility-header-to-C))
|
||||
;; tables headers
|
||||
(mapconcat 'org-babel-C-header-to-C colnames "\n")
|
||||
;; body
|
||||
(if main-p
|
||||
(org-babel-C-ensure-main-wrap body)
|
||||
body) "\n") "\n")))
|
||||
|
||||
(defun org-babel-C-expand-D (body params)
|
||||
"Expand a block of D code with org-babel according to
|
||||
its header arguments."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(colnames (cdar (org-babel-get-header params :colname-names)))
|
||||
(main-p (not (string= (cdr (assoc :main params)) "no")))
|
||||
(imports (or (cdr (assoc :imports params))
|
||||
(org-babel-read (org-entry-get nil "imports" t)))))
|
||||
(when (stringp imports)
|
||||
(setq imports (split-string imports)))
|
||||
(setq imports (append imports '("std.stdio" "std.conv")))
|
||||
(mapconcat 'identity
|
||||
(list
|
||||
"module mmm;"
|
||||
;; imports
|
||||
(mapconcat
|
||||
(lambda (inc) (format "import %s;" inc))
|
||||
imports "\n")
|
||||
;; variables
|
||||
(mapconcat 'org-babel-C-var-to-C vars "\n")
|
||||
;; table sizes
|
||||
(mapconcat 'org-babel-C-table-sizes-to-C vars "\n")
|
||||
;; tables headers utility
|
||||
(when colnames
|
||||
(org-babel-C-utility-header-to-C))
|
||||
;; tables headers
|
||||
(mapconcat 'org-babel-C-header-to-C colnames "\n")
|
||||
;; body
|
||||
(if main-p
|
||||
(org-babel-C-ensure-main-wrap body)
|
||||
body) "\n") "\n")))
|
||||
|
||||
(defun org-babel-C-ensure-main-wrap (body)
|
||||
"Wrap BODY in a \"main\" function call if none exists."
|
||||
(if (string-match "^[ \t]*[intvod]+[ \t\n\r]*main[ \t]*(.*)" body)
|
||||
body
|
||||
(format "int main() {\n%s\nreturn 0;\n}\n" body)))
|
||||
|
||||
(defun org-babel-prep-session:C (session params)
|
||||
"This function does nothing as C is a compiled language with no
|
||||
support for sessions"
|
||||
(error "C is a compiled languages -- no support for sessions"))
|
||||
|
||||
(defun org-babel-load-session:C (session body params)
|
||||
"This function does nothing as C is a compiled language with no
|
||||
support for sessions"
|
||||
(error "C is a compiled languages -- no support for sessions"))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-C-format-val (type val)
|
||||
"Handle the FORMAT part of TYPE with the data from VAL."
|
||||
(let ((format-data (cadr type)))
|
||||
(if (stringp format-data)
|
||||
(cons "" (format format-data val))
|
||||
(funcall format-data val))))
|
||||
|
||||
(defun org-babel-C-val-to-C-type (val)
|
||||
"Determine the type of VAL.
|
||||
Return a list (TYPE-NAME FORMAT). TYPE-NAME should be the name of the type.
|
||||
FORMAT can be either a format string or a function which is called with VAL."
|
||||
(let* ((basetype (org-babel-C-val-to-base-type val))
|
||||
(type
|
||||
(case basetype
|
||||
(integerp '("int" "%d"))
|
||||
(floatp '("double" "%f"))
|
||||
(stringp
|
||||
(list
|
||||
(if (equal org-babel-c-variant 'd) "string" "const char*")
|
||||
"\"%s\""))
|
||||
(t (error "unknown type %S" basetype)))))
|
||||
(cond
|
||||
((integerp val) type) ;; an integer declared in the #+begin_src line
|
||||
((floatp val) type) ;; a numeric declared in the #+begin_src line
|
||||
((and (listp val) (listp (car val))) ;; a table
|
||||
`(,(car type)
|
||||
(lambda (val)
|
||||
(cons
|
||||
(format "[%d][%d]" (length val) (length (car val)))
|
||||
(concat
|
||||
(if (equal org-babel-c-variant 'd) "[\n" "{\n")
|
||||
(mapconcat
|
||||
(lambda (v)
|
||||
(concat
|
||||
(if (equal org-babel-c-variant 'd) " [" " {")
|
||||
(mapconcat (lambda (w) (format ,(cadr type) w)) v ",")
|
||||
(if (equal org-babel-c-variant 'd) "]" "}")))
|
||||
val
|
||||
",\n")
|
||||
(if (equal org-babel-c-variant 'd) "\n]" "\n}"))))))
|
||||
((or (listp val) (vectorp val)) ;; a list declared in the #+begin_src line
|
||||
`(,(car type)
|
||||
(lambda (val)
|
||||
(cons
|
||||
(format "[%d]" (length val))
|
||||
(concat
|
||||
(if (equal org-babel-c-variant 'd) "[" "{")
|
||||
(mapconcat (lambda (v) (format ,(cadr type) v)) val ",")
|
||||
(if (equal org-babel-c-variant 'd) "]" "}"))))))
|
||||
(t ;; treat unknown types as string
|
||||
type))))
|
||||
|
||||
(defun org-babel-C-val-to-base-type (val)
|
||||
"Determine the base type of VAL which may be
|
||||
`integerp' if all base values are integers
|
||||
`floatp' if all base values are either floating points or integers
|
||||
`stringp' otherwise."
|
||||
(cond
|
||||
((integerp val) 'integerp)
|
||||
((floatp val) 'floatp)
|
||||
((or (listp val) (vectorp val))
|
||||
(let ((type nil))
|
||||
(mapc (lambda (v)
|
||||
(case (org-babel-C-val-to-base-type v)
|
||||
(stringp (setq type 'stringp))
|
||||
(floatp
|
||||
(if (or (not type) (eq type 'integerp))
|
||||
(setq type 'floatp)))
|
||||
(integerp
|
||||
(unless type (setq type 'integerp)))))
|
||||
val)
|
||||
type))
|
||||
(t 'stringp)))
|
||||
|
||||
(defun org-babel-C-var-to-C (pair)
|
||||
"Convert an elisp val into a string of C code specifying a var
|
||||
of the same value."
|
||||
;; TODO list support
|
||||
(let ((var (car pair))
|
||||
(val (cdr pair)))
|
||||
(when (symbolp val)
|
||||
(setq val (symbol-name val))
|
||||
(when (= (length val) 1)
|
||||
(setq val (string-to-char val))))
|
||||
(let* ((type-data (org-babel-C-val-to-C-type val))
|
||||
(type (car type-data))
|
||||
(formated (org-babel-C-format-val type-data val))
|
||||
(suffix (car formated))
|
||||
(data (cdr formated)))
|
||||
(format "%s %s%s = %s;"
|
||||
type
|
||||
var
|
||||
suffix
|
||||
data))))
|
||||
|
||||
(defun org-babel-C-table-sizes-to-C (pair)
|
||||
"Create constants of table dimensions, if PAIR is a table."
|
||||
(when (listp (cdr pair))
|
||||
(cond
|
||||
((listp (cadr pair)) ;; a table
|
||||
(concat
|
||||
(format "const int %s_rows = %d;" (car pair) (length (cdr pair)))
|
||||
"\n"
|
||||
(format "const int %s_cols = %d;" (car pair) (length (cadr pair)))))
|
||||
(t ;; a list declared in the #+begin_src line
|
||||
(format "const int %s_cols = %d;" (car pair) (length (cdr pair)))))))
|
||||
|
||||
(defun org-babel-C-utility-header-to-C ()
|
||||
"Generate a utility function to convert a column name
|
||||
into a column number."
|
||||
(case org-babel-c-variant
|
||||
((c cpp)
|
||||
"int get_column_num (int nbcols, const char** header, const char* column)
|
||||
{
|
||||
int c;
|
||||
for (c=0; c<nbcols; c++)
|
||||
if (strcmp(header[c],column)==0)
|
||||
return c;
|
||||
return -1;
|
||||
}
|
||||
"
|
||||
)
|
||||
(d
|
||||
"int get_column_num (string[] header, string column)
|
||||
{
|
||||
foreach (c, h; header)
|
||||
if (h==column)
|
||||
return to!int(c);
|
||||
return -1;
|
||||
}
|
||||
"
|
||||
)))
|
||||
|
||||
(defun org-babel-C-header-to-C (head)
|
||||
"Convert an elisp list of header table into a C or D vector
|
||||
specifying a variable with the name of the table."
|
||||
(let ((table (car head))
|
||||
(headers (cdr head)))
|
||||
(concat
|
||||
(format
|
||||
(case org-babel-c-variant
|
||||
((c cpp) "const char* %s_header[%d] = {%s};")
|
||||
(d "string %s_header[%d] = [%s];"))
|
||||
table
|
||||
(length headers)
|
||||
(mapconcat (lambda (h) (format "%S" h)) headers ","))
|
||||
"\n"
|
||||
(case org-babel-c-variant
|
||||
((c cpp)
|
||||
(format
|
||||
"const char* %s_h (int row, const char* col) { return %s[row][get_column_num(%d,%s_header,col)]; }"
|
||||
table table (length headers) table))
|
||||
(d
|
||||
(format
|
||||
"string %s_h (size_t row, string col) { return %s[row][get_column_num(%s_header,col)]; }"
|
||||
table table table))))))
|
||||
|
||||
(provide 'ob-C)
|
||||
|
||||
;;; ob-C.el ends here
|
179
elpa/org-20160919/ob-J.el
Normal file
179
elpa/org-20160919/ob-J.el
Normal file
@ -0,0 +1,179 @@
|
||||
;;; ob-J.el --- org-babel functions for J evaluation
|
||||
|
||||
;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Oleh Krehel
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating J code.
|
||||
;;
|
||||
;; Session interaction depends on `j-console' from package `j-mode'
|
||||
;; (available in MELPA).
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function org-trim "org" (S))
|
||||
(declare-function j-console-ensure-session "ext:j-console" ())
|
||||
|
||||
(defun org-babel-expand-body:J (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body.
|
||||
PROCESSED-PARAMS isn't used yet."
|
||||
(org-babel-J-interleave-echos-except-functions body))
|
||||
|
||||
(defun org-babel-J-interleave-echos (body)
|
||||
"Interleave echo',' between each source line of BODY."
|
||||
(mapconcat #'identity (split-string body "\n") "\necho','\n"))
|
||||
|
||||
(defun org-babel-J-interleave-echos-except-functions (body)
|
||||
"Interleave echo',' between source lines of BODY that aren't functions."
|
||||
(if (obj-string-match-m "\\(?:^\\|\n\\)[^\n]*\\(?:0\\|1\\|2\\|3\\|4\\|dyad\\) : 0\n.*\n)\\(?:\n\\|$\\)" body)
|
||||
(let ((s1 (substring body 0 (match-beginning 0)))
|
||||
(s2 (match-string 0 body))
|
||||
(s3 (substring body (match-end 0))))
|
||||
(concat
|
||||
(if (string= s1 "")
|
||||
""
|
||||
(concat (org-babel-J-interleave-echos s1)
|
||||
"\necho','\n"))
|
||||
s2
|
||||
"\necho','\n"
|
||||
(org-babel-J-interleave-echos-except-functions s3)))
|
||||
(org-babel-J-interleave-echos body)))
|
||||
|
||||
(defun org-babel-execute:J (body params)
|
||||
"Execute a block of J code BODY.
|
||||
PARAMS are given by org-babel.
|
||||
This function is called by `org-babel-execute-src-block'"
|
||||
(message "executing J source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(sessionp (cdr (assoc :session params)))
|
||||
(session (org-babel-j-initiate-session sessionp))
|
||||
(vars (nth 2 processed-params))
|
||||
(result-params (nth 3 processed-params))
|
||||
(result-type (nth 4 processed-params))
|
||||
(full-body (org-babel-expand-body:J
|
||||
body params processed-params))
|
||||
(tmp-script-file (org-babel-temp-file "J-src")))
|
||||
(org-babel-J-strip-whitespace
|
||||
(if (string= sessionp "none")
|
||||
(progn
|
||||
(with-temp-file tmp-script-file
|
||||
(insert full-body))
|
||||
(org-babel-eval (format "jconsole < %s" tmp-script-file) ""))
|
||||
(org-babel-J-eval-string full-body)))))
|
||||
|
||||
(defun org-babel-J-eval-string (str)
|
||||
"Sends STR to the `j-console-cmd' session and exectues it."
|
||||
(let ((session (j-console-ensure-session)))
|
||||
(with-current-buffer (process-buffer session)
|
||||
(goto-char (point-max))
|
||||
(insert (format "\n%s\n" str))
|
||||
(let ((beg (point)))
|
||||
(comint-send-input)
|
||||
(sit-for .1)
|
||||
(buffer-substring-no-properties
|
||||
beg (point-max))))))
|
||||
|
||||
(defun org-babel-J-strip-whitespace (str)
|
||||
"Remove whitespace from jconsole output STR."
|
||||
(mapconcat
|
||||
#'identity
|
||||
(delete "" (mapcar
|
||||
#'org-babel-J-print-block
|
||||
(split-string str "^ *,\n" t)))
|
||||
"\n\n"))
|
||||
|
||||
(defun obj-get-string-alignment (str)
|
||||
"Return a number to describe STR alignment.
|
||||
STR represents a table.
|
||||
Positive/negative/zero result means right/left/undetermined.
|
||||
Don't trust first line."
|
||||
(let* ((str (org-trim str))
|
||||
(lines (split-string str "\n" t))
|
||||
n1 n2)
|
||||
(cond ((<= (length lines) 1)
|
||||
0)
|
||||
((= (length lines) 2)
|
||||
;; numbers are right-aligned
|
||||
(if (and
|
||||
(numberp (read (car lines)))
|
||||
(numberp (read (cadr lines)))
|
||||
(setq n1 (obj-match-second-space-right (nth 0 lines)))
|
||||
(setq n2 (obj-match-second-space-right (nth 1 lines))))
|
||||
n2
|
||||
0))
|
||||
((not (obj-match-second-space-left (nth 0 lines)))
|
||||
0)
|
||||
((and
|
||||
(setq n1 (obj-match-second-space-left (nth 1 lines)))
|
||||
(setq n2 (obj-match-second-space-left (nth 2 lines)))
|
||||
(= n1 n2))
|
||||
n1)
|
||||
((and
|
||||
(setq n1 (obj-match-second-space-right (nth 1 lines)))
|
||||
(setq n2 (obj-match-second-space-right (nth 2 lines)))
|
||||
(= n1 n2))
|
||||
(- n1))
|
||||
(t 0))))
|
||||
|
||||
(defun org-babel-J-print-block (x)
|
||||
"Prettify jconsole output X."
|
||||
(let* ((x (org-trim x))
|
||||
(a (obj-get-string-alignment x))
|
||||
(lines (split-string x "\n" t))
|
||||
b)
|
||||
(cond ((< a 0)
|
||||
(setq b (obj-match-second-space-right (nth 0 lines)))
|
||||
(concat (make-string (+ a b) ? ) x))
|
||||
((> a 0)
|
||||
(setq b (obj-match-second-space-left (nth 0 lines)))
|
||||
(concat (make-string (- a b) ? ) x))
|
||||
(t x))))
|
||||
|
||||
(defun obj-match-second-space-left (s)
|
||||
"Return position of leftmost space in second space block of S or nil."
|
||||
(and (string-match "^ *[^ ]+\\( \\)" s)
|
||||
(match-beginning 1)))
|
||||
|
||||
(defun obj-match-second-space-right (s)
|
||||
"Return position of rightmost space in second space block of S or nil."
|
||||
(and (string-match "^ *[^ ]+ *\\( \\)[^ ]" s)
|
||||
(match-beginning 1)))
|
||||
|
||||
(defun obj-string-match-m (regexp string &optional start)
|
||||
"Call (string-match REGEXP STRING START).
|
||||
REGEXP is modified so that .* matches newlines as well."
|
||||
(string-match
|
||||
(replace-regexp-in-string "\\.\\*" "[\0-\377[:nonascii:]]*" regexp)
|
||||
string
|
||||
start))
|
||||
|
||||
(defun org-babel-j-initiate-session (&optional session)
|
||||
"Initiate a J session.
|
||||
SESSION is a parameter given by org-babel."
|
||||
(unless (string= session "none")
|
||||
(require 'j-console)
|
||||
(j-console-ensure-session)))
|
||||
|
||||
(provide 'ob-J)
|
||||
|
||||
;;; ob-J.el ends here
|
469
elpa/org-20160919/ob-R.el
Normal file
469
elpa/org-20160919/ob-R.el
Normal file
@ -0,0 +1,469 @@
|
||||
;;; ob-R.el --- org-babel functions for R code evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Dan Davison
|
||||
;; Keywords: literate programming, reproducible research, R, statistics
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating R code
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function orgtbl-to-tsv "org-table" (table params))
|
||||
(declare-function R "ext:essd-r" (&optional start-args))
|
||||
(declare-function inferior-ess-send-input "ext:ess-inf" ())
|
||||
(declare-function ess-make-buffer-current "ext:ess-inf" ())
|
||||
(declare-function ess-eval-buffer "ext:ess-inf" (vis))
|
||||
(declare-function ess-wait-for-process "ext:ess-inf"
|
||||
(&optional proc sec-prompt wait force-redisplay))
|
||||
(declare-function org-number-sequence "org-compat" (from &optional to inc))
|
||||
(declare-function org-remove-if-not "org" (predicate seq))
|
||||
(declare-function org-every "org" (pred seq))
|
||||
|
||||
(defconst org-babel-header-args:R
|
||||
'((width . :any)
|
||||
(height . :any)
|
||||
(bg . :any)
|
||||
(units . :any)
|
||||
(pointsize . :any)
|
||||
(antialias . :any)
|
||||
(quality . :any)
|
||||
(compression . :any)
|
||||
(res . :any)
|
||||
(type . :any)
|
||||
(family . :any)
|
||||
(title . :any)
|
||||
(fonts . :any)
|
||||
(version . :any)
|
||||
(paper . :any)
|
||||
(encoding . :any)
|
||||
(pagecentre . :any)
|
||||
(colormodel . :any)
|
||||
(useDingbats . :any)
|
||||
(horizontal . :any)
|
||||
(results . ((file list vector table scalar verbatim)
|
||||
(raw html latex org code pp drawer)
|
||||
(replace silent none append prepend)
|
||||
(output value graphics))))
|
||||
"R-specific header arguments.")
|
||||
|
||||
(defconst ob-R-safe-header-args
|
||||
(append org-babel-safe-header-args
|
||||
'(:width :height :bg :units :pointsize :antialias :quality
|
||||
:compression :res :type :family :title :fonts
|
||||
:version :paper :encoding :pagecentre :colormodel
|
||||
:useDingbats :horizontal))
|
||||
"Header args which are safe for R babel blocks.
|
||||
|
||||
See `org-babel-safe-header-args' for documentation of the format of
|
||||
this variable.")
|
||||
|
||||
(defvar org-babel-default-header-args:R '())
|
||||
(put 'org-babel-default-header-args:R 'safe-local-variable
|
||||
(org-babel-header-args-safe-fn ob-R-safe-header-args))
|
||||
|
||||
(defcustom org-babel-R-command "R --slave --no-save"
|
||||
"Name of command to use for executing R code."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defvar ess-current-process-name) ; dynamically scoped
|
||||
(defvar ess-local-process-name) ; dynamically scoped
|
||||
(defun org-babel-edit-prep:R (info)
|
||||
(let ((session (cdr (assoc :session (nth 2 info)))))
|
||||
(when (and session (string-match "^\\*\\(.+?\\)\\*$" session))
|
||||
(save-match-data (org-babel-R-initiate-session session nil)))))
|
||||
|
||||
;; The usage of utils::read.table() ensures that the command
|
||||
;; read.table() can be found even in circumstances when the utils
|
||||
;; package is not in the search path from R.
|
||||
(defconst ob-R-transfer-variable-table-with-header
|
||||
"%s <- local({
|
||||
con <- textConnection(
|
||||
%S
|
||||
)
|
||||
res <- utils::read.table(
|
||||
con,
|
||||
header = %s,
|
||||
row.names = %s,
|
||||
sep = \"\\t\",
|
||||
as.is = TRUE
|
||||
)
|
||||
close(con)
|
||||
res
|
||||
})"
|
||||
"R code used to transfer a table defined as a variable from org to R.
|
||||
|
||||
This function is used when the table contains a header.")
|
||||
|
||||
(defconst ob-R-transfer-variable-table-without-header
|
||||
"%s <- local({
|
||||
con <- textConnection(
|
||||
%S
|
||||
)
|
||||
res <- utils::read.table(
|
||||
con,
|
||||
header = %s,
|
||||
row.names = %s,
|
||||
sep = \"\\t\",
|
||||
as.is = TRUE,
|
||||
fill = TRUE,
|
||||
col.names = paste(\"V\", seq_len(%d), sep =\"\")
|
||||
)
|
||||
close(con)
|
||||
res
|
||||
})"
|
||||
"R code used to transfer a table defined as a variable from org to R.
|
||||
|
||||
This function is used when the table does not contain a header.")
|
||||
|
||||
(defun org-babel-expand-body:R (body params &optional graphics-file)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(mapconcat 'identity
|
||||
(append
|
||||
(when (cdr (assoc :prologue params))
|
||||
(list (cdr (assoc :prologue params))))
|
||||
(org-babel-variable-assignments:R params)
|
||||
(list body)
|
||||
(when (cdr (assoc :epilogue params))
|
||||
(list (cdr (assoc :epilogue params)))))
|
||||
"\n"))
|
||||
|
||||
(defun org-babel-execute:R (body params)
|
||||
"Execute a block of R code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(save-excursion
|
||||
(let* ((result-params (cdr (assoc :result-params params)))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(session (org-babel-R-initiate-session
|
||||
(cdr (assoc :session params)) params))
|
||||
(colnames-p (cdr (assoc :colnames params)))
|
||||
(rownames-p (cdr (assoc :rownames params)))
|
||||
(graphics-file (and (member "graphics" (assq :result-params params))
|
||||
(org-babel-graphical-output-file params)))
|
||||
(full-body
|
||||
(let ((inside
|
||||
(list (org-babel-expand-body:R body params graphics-file))))
|
||||
(mapconcat 'identity
|
||||
(if graphics-file
|
||||
(append
|
||||
(list (org-babel-R-construct-graphics-device-call
|
||||
graphics-file params))
|
||||
inside
|
||||
(list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()"))
|
||||
inside)
|
||||
"\n")))
|
||||
(result
|
||||
(org-babel-R-evaluate
|
||||
session full-body result-type result-params
|
||||
(or (equal "yes" colnames-p)
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) colnames-p))
|
||||
(or (equal "yes" rownames-p)
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) rownames-p)))))
|
||||
(if graphics-file nil result))))
|
||||
|
||||
(defun org-babel-prep-session:R (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-R-initiate-session session params))
|
||||
(var-lines (org-babel-variable-assignments:R params)))
|
||||
(org-babel-comint-in-buffer session
|
||||
(mapc (lambda (var)
|
||||
(end-of-line 1) (insert var) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)) var-lines))
|
||||
session))
|
||||
|
||||
(defun org-babel-load-session:R (session body params)
|
||||
"Load BODY into SESSION."
|
||||
(save-window-excursion
|
||||
(let ((buffer (org-babel-prep-session:R session params)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert (org-babel-chomp body)))
|
||||
buffer)))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-variable-assignments:R (params)
|
||||
"Return list of R statements assigning the block's variables."
|
||||
(let ((vars (mapcar 'cdr (org-babel-get-header params :var))))
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(org-babel-R-assign-elisp
|
||||
(car pair) (cdr pair)
|
||||
(equal "yes" (cdr (assoc :colnames params)))
|
||||
(equal "yes" (cdr (assoc :rownames params)))))
|
||||
(mapcar
|
||||
(lambda (i)
|
||||
(cons (car (nth i vars))
|
||||
(org-babel-reassemble-table
|
||||
(cdr (nth i vars))
|
||||
(cdr (nth i (cdr (assoc :colname-names params))))
|
||||
(cdr (nth i (cdr (assoc :rowname-names params)))))))
|
||||
(org-number-sequence 0 (1- (length vars)))))))
|
||||
|
||||
(defun org-babel-R-quote-tsv-field (s)
|
||||
"Quote field S for export to R."
|
||||
(if (stringp s)
|
||||
(concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")
|
||||
(format "%S" s)))
|
||||
|
||||
(defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
|
||||
"Construct R code assigning the elisp VALUE to a variable named NAME."
|
||||
(if (listp value)
|
||||
(let* ((lengths (mapcar 'length (org-remove-if-not 'sequencep value)))
|
||||
(max (if lengths (apply 'max lengths) 0))
|
||||
(min (if lengths (apply 'min lengths) 0)))
|
||||
;; Ensure VALUE has an orgtbl structure (depth of at least 2).
|
||||
(unless (listp (car value)) (setq value (list value)))
|
||||
(let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field)))
|
||||
(header (if (or (eq (nth 1 value) 'hline) colnames-p)
|
||||
"TRUE" "FALSE"))
|
||||
(row-names (if rownames-p "1" "NULL")))
|
||||
(if (= max min)
|
||||
(format ob-R-transfer-variable-table-with-header
|
||||
name file header row-names)
|
||||
(format ob-R-transfer-variable-table-without-header
|
||||
name file header row-names max))))
|
||||
(cond ((integerp value) (format "%s <- %s" name (concat (number-to-string value) "L")))
|
||||
((floatp value) (format "%s <- %s" name value))
|
||||
((stringp value) (format "%s <- %S" name (org-no-properties value)))
|
||||
(t (format "%s <- %S" name (prin1-to-string value))))))
|
||||
|
||||
|
||||
(defvar ess-ask-for-ess-directory) ; dynamically scoped
|
||||
(defun org-babel-R-initiate-session (session params)
|
||||
"If there is not a current R process then create one."
|
||||
(unless (string= session "none")
|
||||
(let ((session (or session "*R*"))
|
||||
(ess-ask-for-ess-directory
|
||||
(and (boundp 'ess-ask-for-ess-directory)
|
||||
ess-ask-for-ess-directory
|
||||
(not (cdr (assoc :dir params))))))
|
||||
(if (org-babel-comint-buffer-livep session)
|
||||
session
|
||||
(save-window-excursion
|
||||
(when (get-buffer session)
|
||||
;; Session buffer exists, but with dead process
|
||||
(set-buffer session))
|
||||
(require 'ess) (R)
|
||||
(let ((R-proc (get-process (or ess-local-process-name
|
||||
ess-current-process-name))))
|
||||
(while (process-get R-proc 'callbacks)
|
||||
(ess-wait-for-process R-proc)))
|
||||
(rename-buffer
|
||||
(if (bufferp session)
|
||||
(buffer-name session)
|
||||
(if (stringp session)
|
||||
session
|
||||
(buffer-name))))
|
||||
(current-buffer))))))
|
||||
|
||||
(defun org-babel-R-associate-session (session)
|
||||
"Associate R code buffer with an R session.
|
||||
Make SESSION be the inferior ESS process associated with the
|
||||
current code buffer."
|
||||
(setq ess-local-process-name
|
||||
(process-name (get-buffer-process session)))
|
||||
(ess-make-buffer-current))
|
||||
|
||||
(defvar org-babel-R-graphics-devices
|
||||
'((:bmp "bmp" "filename")
|
||||
(:jpg "jpeg" "filename")
|
||||
(:jpeg "jpeg" "filename")
|
||||
(:tikz "tikz" "file")
|
||||
(:tiff "tiff" "filename")
|
||||
(:png "png" "filename")
|
||||
(:svg "svg" "file")
|
||||
(:pdf "pdf" "file")
|
||||
(:ps "postscript" "file")
|
||||
(:postscript "postscript" "file"))
|
||||
"An alist mapping graphics file types to R functions.
|
||||
|
||||
Each member of this list is a list with three members:
|
||||
1. the file extension of the graphics file, as an elisp :keyword
|
||||
2. the R graphics device function to call to generate such a file
|
||||
3. the name of the argument to this function which specifies the
|
||||
file to write to (typically \"file\" or \"filename\")")
|
||||
|
||||
(defun org-babel-R-construct-graphics-device-call (out-file params)
|
||||
"Construct the call to the graphics device."
|
||||
(let* ((allowed-args '(:width :height :bg :units :pointsize
|
||||
:antialias :quality :compression :res
|
||||
:type :family :title :fonts :version
|
||||
:paper :encoding :pagecentre :colormodel
|
||||
:useDingbats :horizontal))
|
||||
(device (and (string-match ".+\\.\\([^.]+\\)" out-file)
|
||||
(match-string 1 out-file)))
|
||||
(device-info (or (assq (intern (concat ":" device))
|
||||
org-babel-R-graphics-devices)
|
||||
(assq :png org-babel-R-graphics-devices)))
|
||||
(extra-args (cdr (assq :R-dev-args params))) filearg args)
|
||||
(setq device (nth 1 device-info))
|
||||
(setq filearg (nth 2 device-info))
|
||||
(setq args (mapconcat
|
||||
(lambda (pair)
|
||||
(if (member (car pair) allowed-args)
|
||||
(format ",%s=%S"
|
||||
(substring (symbol-name (car pair)) 1)
|
||||
(cdr pair)) ""))
|
||||
params ""))
|
||||
(format "%s(%s=\"%s\"%s%s%s); tryCatch({"
|
||||
device filearg out-file args
|
||||
(if extra-args "," "") (or extra-args ""))))
|
||||
|
||||
(defconst org-babel-R-eoe-indicator "'org_babel_R_eoe'")
|
||||
(defconst org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"")
|
||||
|
||||
(defconst org-babel-R-write-object-command "{
|
||||
function(object,transfer.file) {
|
||||
object
|
||||
invisible(
|
||||
if (
|
||||
inherits(
|
||||
try(
|
||||
{
|
||||
tfile<-tempfile()
|
||||
write.table(object, file=tfile, sep=\"\\t\",
|
||||
na=\"nil\",row.names=%s,col.names=%s,
|
||||
quote=FALSE)
|
||||
file.rename(tfile,transfer.file)
|
||||
},
|
||||
silent=TRUE),
|
||||
\"try-error\"))
|
||||
{
|
||||
if(!file.exists(transfer.file))
|
||||
file.create(transfer.file)
|
||||
}
|
||||
)
|
||||
}
|
||||
}(object=%s,transfer.file=\"%s\")"
|
||||
"A template for an R command to evaluate a block of code and write the result to a file.
|
||||
|
||||
Has four %s escapes to be filled in:
|
||||
1. Row names, \"TRUE\" or \"FALSE\"
|
||||
2. Column names, \"TRUE\" or \"FALSE\"
|
||||
3. The code to be run (must be an expression, not a statement)
|
||||
4. The name of the file to write to")
|
||||
|
||||
(defun org-babel-R-evaluate
|
||||
(session body result-type result-params column-names-p row-names-p)
|
||||
"Evaluate R code in BODY."
|
||||
(if session
|
||||
(org-babel-R-evaluate-session
|
||||
session body result-type result-params column-names-p row-names-p)
|
||||
(org-babel-R-evaluate-external-process
|
||||
body result-type result-params column-names-p row-names-p)))
|
||||
|
||||
(defun org-babel-R-evaluate-external-process
|
||||
(body result-type result-params column-names-p row-names-p)
|
||||
"Evaluate BODY in external R process.
|
||||
If RESULT-TYPE equals `output' then return standard output as a
|
||||
string. If RESULT-TYPE equals `value' then return the value of the
|
||||
last statement in BODY, as elisp."
|
||||
(case result-type
|
||||
(value
|
||||
(let ((tmp-file (org-babel-temp-file "R-")))
|
||||
(org-babel-eval org-babel-R-command
|
||||
(format org-babel-R-write-object-command
|
||||
(if row-names-p "TRUE" "FALSE")
|
||||
(if column-names-p
|
||||
(if row-names-p "NA" "TRUE")
|
||||
"FALSE")
|
||||
(format "{function ()\n{\n%s\n}}()" body)
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-R-process-value-result
|
||||
(org-babel-result-cond result-params
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-file)
|
||||
(buffer-string))
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)))
|
||||
column-names-p)))
|
||||
(output (org-babel-eval org-babel-R-command body))))
|
||||
|
||||
(defvar ess-eval-visibly-p)
|
||||
|
||||
(defun org-babel-R-evaluate-session
|
||||
(session body result-type result-params column-names-p row-names-p)
|
||||
"Evaluate BODY in SESSION.
|
||||
If RESULT-TYPE equals `output' then return standard output as a
|
||||
string. If RESULT-TYPE equals `value' then return the value of the
|
||||
last statement in BODY, as elisp."
|
||||
(case result-type
|
||||
(value
|
||||
(with-temp-buffer
|
||||
(insert (org-babel-chomp body))
|
||||
(let ((ess-local-process-name
|
||||
(process-name (get-buffer-process session)))
|
||||
(ess-eval-visibly-p nil))
|
||||
(ess-eval-buffer nil)))
|
||||
(let ((tmp-file (org-babel-temp-file "R-")))
|
||||
(org-babel-comint-eval-invisibly-and-wait-for-file
|
||||
session tmp-file
|
||||
(format org-babel-R-write-object-command
|
||||
(if row-names-p "TRUE" "FALSE")
|
||||
(if column-names-p
|
||||
(if row-names-p "NA" "TRUE")
|
||||
"FALSE")
|
||||
".Last.value" (org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-R-process-value-result
|
||||
(org-babel-result-cond result-params
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-file)
|
||||
(buffer-string))
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)))
|
||||
column-names-p)))
|
||||
(output
|
||||
(mapconcat
|
||||
'org-babel-chomp
|
||||
(butlast
|
||||
(delq nil
|
||||
(mapcar
|
||||
(lambda (line) (when (> (length line) 0) line))
|
||||
(mapcar
|
||||
(lambda (line) ;; cleanup extra prompts left in output
|
||||
(if (string-match
|
||||
"^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
|
||||
(substring line (match-end 1))
|
||||
line))
|
||||
(org-babel-comint-with-output (session org-babel-R-eoe-output)
|
||||
(insert (mapconcat 'org-babel-chomp
|
||||
(list body org-babel-R-eoe-indicator)
|
||||
"\n"))
|
||||
(inferior-ess-send-input)))))) "\n"))))
|
||||
|
||||
(defun org-babel-R-process-value-result (result column-names-p)
|
||||
"R-specific processing of return value.
|
||||
Insert hline if column names in output have been requested."
|
||||
(if column-names-p
|
||||
(cons (car result) (cons 'hline (cdr result)))
|
||||
result))
|
||||
|
||||
(provide 'ob-R)
|
||||
|
||||
|
||||
|
||||
;;; ob-R.el ends here
|
94
elpa/org-20160919/ob-abc.el
Normal file
94
elpa/org-20160919/ob-abc.el
Normal file
@ -0,0 +1,94 @@
|
||||
;;; ob-abc.el --- org-babel functions for template evaluation
|
||||
|
||||
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: William Waites
|
||||
;; Keywords: literate programming, music
|
||||
;; Homepage: http://www.tardis.ed.ac.uk/wwaites
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; This file adds support to Org Babel for music in ABC notation.
|
||||
;;; It requires that the abcm2ps program is installed.
|
||||
;;; See http://moinejf.free.fr/
|
||||
|
||||
(require 'ob)
|
||||
|
||||
;; optionally define a file extension for this language
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("abc" . "abc"))
|
||||
|
||||
;; optionally declare default header arguments for this language
|
||||
(defvar org-babel-default-header-args:abc
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating an ABC source block.")
|
||||
|
||||
(defun org-babel-expand-body:abc (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(let ((name (symbol-name (car pair)))
|
||||
(value (cdr pair)))
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(concat "\$" (regexp-quote name))
|
||||
(if (stringp value) value (format "%S" value))
|
||||
body))))
|
||||
vars)
|
||||
body))
|
||||
|
||||
(defun org-babel-execute:abc (body params)
|
||||
"Execute a block of ABC code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Abc source code block")
|
||||
(let* ((result-params (split-string (or (cdr (assoc :results params)))))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(out-file ((lambda (el)
|
||||
(or el
|
||||
(error "abc code block requires :file header argument")))
|
||||
(replace-regexp-in-string "\.pdf$" ".ps" (cdr (assoc :file params)))))
|
||||
(in-file (org-babel-temp-file "abc-"))
|
||||
(render (concat "abcm2ps" " " cmdline
|
||||
" -O " (org-babel-process-file-name out-file)
|
||||
" " (org-babel-process-file-name in-file))))
|
||||
(with-temp-file in-file (insert (org-babel-expand-body:abc body params)))
|
||||
(org-babel-eval render "")
|
||||
;;; handle where abcm2ps changes the file name (to support multiple files
|
||||
(when (or (string= (file-name-extension out-file) "eps")
|
||||
(string= (file-name-extension out-file) "svg"))
|
||||
(rename-file (concat
|
||||
(file-name-sans-extension out-file) "001."
|
||||
(file-name-extension out-file))
|
||||
out-file t))
|
||||
;;; if we were asked for a pdf...
|
||||
(when (string= (file-name-extension (cdr (assoc :file params))) "pdf")
|
||||
(org-babel-eval (concat "ps2pdf" " " out-file " " (cdr (assoc :file params))) ""))
|
||||
;;; indicate that the file has been written
|
||||
nil))
|
||||
|
||||
;; This function should be used to assign any variables in params in
|
||||
;; the context of the session environment.
|
||||
(defun org-babel-prep-session:abc (session params)
|
||||
"Return an error because abc does not support sessions."
|
||||
(error "ABC does not support sessions"))
|
||||
|
||||
(provide 'ob-abc)
|
||||
;;; ob-abc.el ends here
|
147
elpa/org-20160919/ob-asymptote.el
Normal file
147
elpa/org-20160919/ob-asymptote.el
Normal file
@ -0,0 +1,147 @@
|
||||
;;; ob-asymptote.el --- org-babel functions for asymptote evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating asymptote source code.
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in asymptote
|
||||
;;
|
||||
;; 2) we are generally only going to return results of type "file"
|
||||
;;
|
||||
;; 3) we are adding the "file" and "cmdline" header arguments, if file
|
||||
;; is omitted then the -V option is passed to the asy command for
|
||||
;; interactive viewing
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - The asymptote program :: http://asymptote.sourceforge.net/
|
||||
;;
|
||||
;; - asy-mode :: Major mode for editing asymptote files
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("asymptote" . "asy"))
|
||||
|
||||
(defvar org-babel-default-header-args:asymptote
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments when evaluating an Asymptote source block.")
|
||||
|
||||
(defun org-babel-execute:asymptote (body params)
|
||||
"Execute a block of Asymptote code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(format (or (and out-file
|
||||
(string-match ".+\\.\\(.+\\)" out-file)
|
||||
(match-string 1 out-file))
|
||||
"pdf"))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(in-file (org-babel-temp-file "asymptote-"))
|
||||
(cmd
|
||||
(concat "asy "
|
||||
(if out-file
|
||||
(concat
|
||||
"-globalwrite -f " format
|
||||
" -o " (org-babel-process-file-name out-file))
|
||||
"-V")
|
||||
" " cmdline
|
||||
" " (org-babel-process-file-name in-file))))
|
||||
(with-temp-file in-file
|
||||
(insert (org-babel-expand-body:generic
|
||||
body params
|
||||
(org-babel-variable-assignments:asymptote params))))
|
||||
(message cmd) (shell-command cmd)
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:asymptote (session params)
|
||||
"Return an error if the :session header argument is set.
|
||||
Asymptote does not support sessions"
|
||||
(error "Asymptote does not support sessions"))
|
||||
|
||||
(defun org-babel-variable-assignments:asymptote (params)
|
||||
"Return list of asymptote statements assigning the block's variables."
|
||||
(mapcar #'org-babel-asymptote-var-to-asymptote
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-asymptote-var-to-asymptote (pair)
|
||||
"Convert an elisp value into an Asymptote variable.
|
||||
The elisp value PAIR is converted into Asymptote code specifying
|
||||
a variable of the same value."
|
||||
(let ((var (car pair))
|
||||
(val (let ((v (cdr pair)))
|
||||
(if (symbolp v) (symbol-name v) v))))
|
||||
(cond
|
||||
((integerp val)
|
||||
(format "int %S=%S;" var val))
|
||||
((floatp val)
|
||||
(format "real %S=%S;" var val))
|
||||
((stringp val)
|
||||
(format "string %S=\"%s\";" var val))
|
||||
((and (listp val) (not (listp (car val))))
|
||||
(let* ((type (org-babel-asymptote-define-type val))
|
||||
(fmt (if (eq 'string type) "\"%s\"" "%s"))
|
||||
(vect (mapconcat (lambda (e) (format fmt e)) val ", ")))
|
||||
(format "%s[] %S={%s};" type var vect)))
|
||||
((listp val)
|
||||
(let* ((type (org-babel-asymptote-define-type val))
|
||||
(fmt (if (eq 'string type) "\"%s\"" "%s"))
|
||||
(array (mapconcat (lambda (row)
|
||||
(concat "{"
|
||||
(mapconcat (lambda (e) (format fmt e))
|
||||
row ", ")
|
||||
"}"))
|
||||
val ",")))
|
||||
(format "%S[][] %S={%s};" type var array))))))
|
||||
|
||||
(defun org-babel-asymptote-define-type (data)
|
||||
"Determine type of DATA.
|
||||
|
||||
DATA is a list. Return type as a symbol.
|
||||
|
||||
The type is `string' if any element in DATA is
|
||||
a string. Otherwise, it is either `real', if some elements are
|
||||
floats, or `int'."
|
||||
(let* ((type 'int)
|
||||
find-type ; for byte-compiler
|
||||
(find-type
|
||||
(function
|
||||
(lambda (row)
|
||||
(catch 'exit
|
||||
(mapc (lambda (el)
|
||||
(cond ((listp el) (funcall find-type el))
|
||||
((stringp el) (throw 'exit (setq type 'string)))
|
||||
((floatp el) (setq type 'real))))
|
||||
row))))))
|
||||
(funcall find-type data) type))
|
||||
|
||||
(provide 'ob-asymptote)
|
||||
|
||||
|
||||
|
||||
;;; ob-asymptote.el ends here
|
112
elpa/org-20160919/ob-awk.el
Normal file
112
elpa/org-20160919/ob-awk.el
Normal file
@ -0,0 +1,112 @@
|
||||
;;; ob-awk.el --- org-babel functions for awk evaluation
|
||||
|
||||
;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Babel's awk can use special header argument:
|
||||
;;
|
||||
;; - :in-file takes a path to a file of data to be processed by awk
|
||||
;;
|
||||
;; - :stdin takes an Org-mode data or code block reference, the value
|
||||
;; of which will be passed to the awk process through STDIN
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'org-compat)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-babel-ref-resolve "ob-ref" (ref))
|
||||
(declare-function orgtbl-to-generic "org-table" (table params))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("awk" . "awk"))
|
||||
|
||||
(defvar org-babel-awk-command "awk"
|
||||
"Name of the awk executable command.")
|
||||
|
||||
(defun org-babel-expand-body:awk (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
body)
|
||||
|
||||
(defun org-babel-execute:awk (body params)
|
||||
"Execute a block of Awk code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Awk source code block")
|
||||
(let* ((result-params (cdr (assoc :result-params params)))
|
||||
(cmd-line (cdr (assoc :cmd-line params)))
|
||||
(in-file (cdr (assoc :in-file params)))
|
||||
(full-body (org-babel-expand-body:awk body params))
|
||||
(code-file (let ((file (org-babel-temp-file "awk-")))
|
||||
(with-temp-file file (insert full-body)) file))
|
||||
(stdin (let ((stdin (cdr (assoc :stdin params))))
|
||||
(when stdin
|
||||
(let ((tmp (org-babel-temp-file "awk-stdin-"))
|
||||
(res (org-babel-ref-resolve stdin)))
|
||||
(with-temp-file tmp
|
||||
(insert (org-babel-awk-var-to-awk res)))
|
||||
tmp))))
|
||||
(cmd (mapconcat #'identity
|
||||
(append
|
||||
(list org-babel-awk-command
|
||||
"-f" code-file cmd-line)
|
||||
(mapcar (lambda (pair)
|
||||
(format "-v %s='%s'"
|
||||
(cadr pair)
|
||||
(org-babel-awk-var-to-awk
|
||||
(cddr pair))))
|
||||
(org-babel-get-header params :var))
|
||||
(list in-file))
|
||||
" ")))
|
||||
(org-babel-reassemble-table
|
||||
(let ((results
|
||||
(cond
|
||||
(stdin (with-temp-buffer
|
||||
(call-process-shell-command cmd stdin (current-buffer))
|
||||
(buffer-string)))
|
||||
(t (org-babel-eval cmd "")))))
|
||||
(when results
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(let ((tmp (org-babel-temp-file "awk-results-")))
|
||||
(with-temp-file tmp (insert results))
|
||||
(org-babel-import-elisp-from-file tmp)))))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-awk-var-to-awk (var &optional sep)
|
||||
"Return a printed value of VAR suitable for parsing with awk."
|
||||
(let ((echo-var (lambda (v) (if (stringp v) v (format "%S" v)))))
|
||||
(cond
|
||||
((and (listp var) (listp (car var)))
|
||||
(orgtbl-to-generic var (list :sep (or sep "\t") :fmt echo-var)))
|
||||
((listp var)
|
||||
(mapconcat echo-var var "\n"))
|
||||
(t (funcall echo-var var)))))
|
||||
|
||||
(provide 'ob-awk)
|
||||
|
||||
|
||||
|
||||
;;; ob-awk.el ends here
|
108
elpa/org-20160919/ob-calc.el
Normal file
108
elpa/org-20160919/ob-calc.el
Normal file
@ -0,0 +1,108 @@
|
||||
;;; ob-calc.el --- org-babel functions for calc code evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating calc code
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'calc)
|
||||
(unless (featurep 'xemacs)
|
||||
(require 'calc-trail)
|
||||
(require 'calc-store))
|
||||
|
||||
(declare-function calc-store-into "calc-store" (&optional var))
|
||||
(declare-function calc-recall "calc-store" (&optional var))
|
||||
(declare-function math-evaluate-expr "calc-ext" (x))
|
||||
|
||||
(defvar org-babel-default-header-args:calc nil
|
||||
"Default arguments for evaluating an calc source block.")
|
||||
|
||||
(defun org-babel-expand-body:calc (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defvar org--var-syms) ; Dynamically scoped from org-babel-execute:calc
|
||||
|
||||
(defun org-babel-execute:calc (body params)
|
||||
"Execute a block of calc code with Babel."
|
||||
(unless (get-buffer "*Calculator*")
|
||||
(save-window-excursion (calc) (calc-quit)))
|
||||
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(org--var-syms (mapcar #'car vars))
|
||||
(var-names (mapcar #'symbol-name org--var-syms)))
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(calc-push-list (list (cdr pair)))
|
||||
(calc-store-into (car pair)))
|
||||
vars)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(when (> (length line) 0)
|
||||
(cond
|
||||
;; simple variable name
|
||||
((member line var-names) (calc-recall (intern line)))
|
||||
;; stack operation
|
||||
((string= "'" (substring line 0 1))
|
||||
(funcall (lookup-key calc-mode-map (substring line 1)) nil))
|
||||
;; complex expression
|
||||
(t
|
||||
(calc-push-list
|
||||
(list (let ((res (calc-eval line)))
|
||||
(cond
|
||||
((numberp res) res)
|
||||
((math-read-number res) (math-read-number res))
|
||||
((listp res) (error "Calc error \"%s\" on input \"%s\""
|
||||
(cadr res) line))
|
||||
(t (replace-regexp-in-string
|
||||
"'" ""
|
||||
(calc-eval
|
||||
(math-evaluate-expr
|
||||
;; resolve user variables, calc built in
|
||||
;; variables are handled automatically
|
||||
;; upstream by calc
|
||||
(mapcar #'org-babel-calc-maybe-resolve-var
|
||||
;; parse line into calc objects
|
||||
(car (math-read-exprs line)))))))))
|
||||
))))))
|
||||
(mapcar #'org-babel-trim
|
||||
(split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
|
||||
(save-excursion
|
||||
(with-current-buffer (get-buffer "*Calculator*")
|
||||
(calc-eval (calc-top 1)))))
|
||||
|
||||
(defun org-babel-calc-maybe-resolve-var (el)
|
||||
(if (consp el)
|
||||
(if (and (equal 'var (car el)) (member (cadr el) org--var-syms))
|
||||
(progn
|
||||
(calc-recall (cadr el))
|
||||
(prog1 (calc-top 1)
|
||||
(calc-pop 1)))
|
||||
(mapcar #'org-babel-calc-maybe-resolve-var el))
|
||||
el))
|
||||
|
||||
(provide 'ob-calc)
|
||||
|
||||
|
||||
|
||||
;;; ob-calc.el ends here
|
119
elpa/org-20160919/ob-clojure.el
Normal file
119
elpa/org-20160919/ob-clojure.el
Normal file
@ -0,0 +1,119 @@
|
||||
;;; ob-clojure.el --- org-babel functions for clojure evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Joel Boehland, Eric Schulte, Oleh Krehel
|
||||
;;
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Support for evaluating clojure code
|
||||
|
||||
;; Requirements:
|
||||
|
||||
;; - clojure (at least 1.2.0)
|
||||
;; - clojure-mode
|
||||
;; - either cider or SLIME
|
||||
|
||||
;; For Cider, see https://github.com/clojure-emacs/cider
|
||||
|
||||
;; For SLIME, the best way to install these components is by following
|
||||
;; the directions as set out by Phil Hagelberg (Technomancy) on the
|
||||
;; web page: http://technomancy.us/126
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(declare-function cider-current-connection "ext:cider-client" (&optional type))
|
||||
(declare-function cider-current-session "ext:cider-client" ())
|
||||
(declare-function nrepl-dict-get "ext:nrepl-client" (dict key))
|
||||
(declare-function nrepl-sync-request:eval "ext:nrepl-client"
|
||||
(input connection session &optional ns))
|
||||
(declare-function slime-eval "ext:slime" (sexp &optional package))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
|
||||
|
||||
(defvar org-babel-default-header-args:clojure '())
|
||||
(defvar org-babel-header-args:clojure '((package . :any)))
|
||||
|
||||
(defcustom org-babel-clojure-backend
|
||||
(cond ((featurep 'cider) 'cider)
|
||||
(t 'slime))
|
||||
"Backend used to evaluate Clojure code blocks."
|
||||
:group 'org-babel
|
||||
:type '(choice
|
||||
(const :tag "cider" cider)
|
||||
(const :tag "SLIME" slime)))
|
||||
|
||||
(defun org-babel-expand-body:clojure (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(print-level nil) (print-length nil)
|
||||
(body (org-babel-trim
|
||||
(if (> (length vars) 0)
|
||||
(concat "(let ["
|
||||
(mapconcat
|
||||
(lambda (var)
|
||||
(format "%S (quote %S)" (car var) (cdr var)))
|
||||
vars "\n ")
|
||||
"]\n" body ")")
|
||||
body))))
|
||||
(if (or (member "code" result-params)
|
||||
(member "pp" result-params))
|
||||
(format "(clojure.pprint/pprint (do %s))" body)
|
||||
body)))
|
||||
|
||||
(defun org-babel-execute:clojure (body params)
|
||||
"Execute a block of Clojure code with Babel."
|
||||
(let ((expanded (org-babel-expand-body:clojure body params))
|
||||
result)
|
||||
(case org-babel-clojure-backend
|
||||
(cider
|
||||
(require 'cider)
|
||||
(let ((result-params (cdr (assoc :result-params params))))
|
||||
(setq result
|
||||
(nrepl-dict-get
|
||||
(nrepl-sync-request:eval
|
||||
expanded (cider-current-connection) (cider-current-session))
|
||||
(if (or (member "output" result-params)
|
||||
(member "pp" result-params))
|
||||
"out"
|
||||
"value")))))
|
||||
(slime
|
||||
(require 'slime)
|
||||
(with-temp-buffer
|
||||
(insert expanded)
|
||||
(setq result
|
||||
(slime-eval
|
||||
`(swank:eval-and-grab-output
|
||||
,(buffer-substring-no-properties (point-min) (point-max)))
|
||||
(cdr (assoc :package params)))))))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
result
|
||||
(condition-case nil (org-babel-script-escape result)
|
||||
(error result)))))
|
||||
|
||||
(provide 'ob-clojure)
|
||||
|
||||
;;; ob-clojure.el ends here
|
164
elpa/org-20160919/ob-comint.el
Normal file
164
elpa/org-20160919/ob-comint.el
Normal file
@ -0,0 +1,164 @@
|
||||
;;; ob-comint.el --- org-babel functions for interaction with comint buffers
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, comint
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; These functions build on comint to ease the sending and receiving
|
||||
;; of commands and results from comint buffers.
|
||||
|
||||
;; Note that the buffers in this file are analogous to sessions in
|
||||
;; org-babel at large.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob-core)
|
||||
(require 'org-compat)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
(declare-function with-parsed-tramp-file-name "tramp"
|
||||
(filename var &rest body) t)
|
||||
(declare-function tramp-flush-directory-property "tramp-cache" (key directory))
|
||||
|
||||
(defun org-babel-comint-buffer-livep (buffer)
|
||||
"Check if BUFFER is a comint buffer with a live process."
|
||||
(let ((buffer (if buffer (get-buffer buffer))))
|
||||
(and buffer (buffer-live-p buffer) (get-buffer-process buffer) buffer)))
|
||||
|
||||
(defmacro org-babel-comint-in-buffer (buffer &rest body)
|
||||
"Check BUFFER and execute BODY.
|
||||
BUFFER is checked with `org-babel-comint-buffer-livep'. BODY is
|
||||
executed inside the protection of `save-excursion' and
|
||||
`save-match-data'."
|
||||
(declare (indent 1))
|
||||
`(progn
|
||||
(unless (org-babel-comint-buffer-livep ,buffer)
|
||||
(error "Buffer %s does not exist or has no process" ,buffer))
|
||||
(save-match-data
|
||||
(with-current-buffer ,buffer
|
||||
(let ((comint-input-filter (lambda (input) nil)))
|
||||
,@body)))))
|
||||
(def-edebug-spec org-babel-comint-in-buffer (form body))
|
||||
|
||||
(defmacro org-babel-comint-with-output (meta &rest body)
|
||||
"Evaluate BODY in BUFFER and return process output.
|
||||
Will wait until EOE-INDICATOR appears in the output, then return
|
||||
all process output. If REMOVE-ECHO and FULL-BODY are present and
|
||||
non-nil, then strip echo'd body from the returned output. META
|
||||
should be a list containing the following where the last two
|
||||
elements are optional.
|
||||
|
||||
(BUFFER EOE-INDICATOR REMOVE-ECHO FULL-BODY)
|
||||
|
||||
This macro ensures that the filter is removed in case of an error
|
||||
or user `keyboard-quit' during execution of body."
|
||||
(declare (indent 1))
|
||||
(let ((buffer (nth 0 meta))
|
||||
(eoe-indicator (nth 1 meta))
|
||||
(remove-echo (nth 2 meta))
|
||||
(full-body (nth 3 meta)))
|
||||
`(org-babel-comint-in-buffer ,buffer
|
||||
(let* ((string-buffer "")
|
||||
(comint-output-filter-functions
|
||||
(cons (lambda (text) (setq string-buffer (concat string-buffer text)))
|
||||
comint-output-filter-functions))
|
||||
dangling-text raw)
|
||||
;; got located, and save dangling text
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(let ((start (point))
|
||||
(end (point-max)))
|
||||
(setq dangling-text (buffer-substring start end))
|
||||
(delete-region start end))
|
||||
;; pass FULL-BODY to process
|
||||
,@body
|
||||
;; wait for end-of-evaluation indicator
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (save-excursion
|
||||
(and (re-search-forward
|
||||
(regexp-quote ,eoe-indicator) nil t)
|
||||
(re-search-forward
|
||||
comint-prompt-regexp nil t)))))
|
||||
(accept-process-output (get-buffer-process (current-buffer)))
|
||||
;; thought the following this would allow async
|
||||
;; background running, but I was wrong...
|
||||
;; (run-with-timer .5 .5 'accept-process-output
|
||||
;; (get-buffer-process (current-buffer)))
|
||||
)
|
||||
;; replace cut dangling text
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert dangling-text)
|
||||
|
||||
;; remove echo'd FULL-BODY from input
|
||||
(if (and ,remove-echo ,full-body
|
||||
(string-match
|
||||
(replace-regexp-in-string
|
||||
"\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
|
||||
string-buffer))
|
||||
(setq raw (substring string-buffer (match-end 0))))
|
||||
(split-string string-buffer comint-prompt-regexp)))))
|
||||
(def-edebug-spec org-babel-comint-with-output (sexp body))
|
||||
|
||||
(defun org-babel-comint-input-command (buffer cmd)
|
||||
"Pass CMD to BUFFER.
|
||||
The input will not be echoed."
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process buffer)))
|
||||
(insert cmd)
|
||||
(comint-send-input)
|
||||
(org-babel-comint-wait-for-output buffer)))
|
||||
|
||||
(defun org-babel-comint-wait-for-output (buffer)
|
||||
"Wait until output arrives from BUFFER.
|
||||
Note: this is only safe when waiting for the result of a single
|
||||
statement (not large blocks of code)."
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (and (re-search-forward comint-prompt-regexp nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(string= (face-name (face-at-point))
|
||||
"comint-highlight-prompt"))))
|
||||
(accept-process-output (get-buffer-process buffer)))))
|
||||
|
||||
(defun org-babel-comint-eval-invisibly-and-wait-for-file
|
||||
(buffer file string &optional period)
|
||||
"Evaluate STRING in BUFFER invisibly.
|
||||
Don't return until FILE exists. Code in STRING must ensure that
|
||||
FILE exists at end of evaluation."
|
||||
(unless (org-babel-comint-buffer-livep buffer)
|
||||
(error "Buffer %s does not exist or has no process" buffer))
|
||||
(if (file-exists-p file) (delete-file file))
|
||||
(process-send-string
|
||||
(get-buffer-process buffer)
|
||||
(if (= (aref string (1- (length string))) ?\n) string (concat string "\n")))
|
||||
;; From Tramp 2.1.19 the following cache flush is not necessary
|
||||
(if (file-remote-p default-directory)
|
||||
(let (v)
|
||||
(with-parsed-tramp-file-name default-directory nil
|
||||
(tramp-flush-directory-property v ""))))
|
||||
(while (not (file-exists-p file)) (sit-for (or period 0.25))))
|
||||
|
||||
(provide 'ob-comint)
|
||||
|
||||
|
||||
|
||||
;;; ob-comint.el ends here
|
77
elpa/org-20160919/ob-coq.el
Normal file
77
elpa/org-20160919/ob-coq.el
Normal file
@ -0,0 +1,77 @@
|
||||
;;; ob-coq.el --- org-babel functions for Coq
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Rudimentary support for evaluating Coq code blocks. Currently only
|
||||
;; session evaluation is supported. Requires both coq.el and
|
||||
;; coq-inferior.el, both of which are distributed with Coq.
|
||||
;;
|
||||
;; http://coq.inria.fr/
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function run-coq "ext:coq-inferior.el" (cmd))
|
||||
(declare-function coq-proc "ext:coq-inferior.el" ())
|
||||
|
||||
(defvar org-babel-coq-buffer "*coq*"
|
||||
"Buffer in which to evaluate coq code blocks.")
|
||||
|
||||
(defvar org-babel-coq-eoe "org-babel-coq-eoe")
|
||||
|
||||
(defun org-babel-coq-clean-prompt (string)
|
||||
(if (string-match "^[^[:space:]]+ < " string)
|
||||
(substring string 0 (match-beginning 0))
|
||||
string))
|
||||
|
||||
(defun org-babel-execute:coq (body params)
|
||||
(let ((full-body (org-babel-expand-body:generic body params))
|
||||
(session (org-babel-coq-initiate-session))
|
||||
(pt (lambda ()
|
||||
(marker-position
|
||||
(process-mark (get-buffer-process (current-buffer)))))))
|
||||
(org-babel-coq-clean-prompt
|
||||
(org-babel-comint-in-buffer session
|
||||
(let ((start (funcall pt)))
|
||||
(with-temp-buffer
|
||||
(insert full-body)
|
||||
(comint-send-region (coq-proc) (point-min) (point-max))
|
||||
(comint-send-string (coq-proc)
|
||||
(if (string= (buffer-substring (- (point-max) 1) (point-max)) ".")
|
||||
"\n"
|
||||
".\n")))
|
||||
(while (equal start (funcall pt)) (sleep-for 0.1))
|
||||
(buffer-substring start (funcall pt)))))))
|
||||
|
||||
(defun org-babel-coq-initiate-session ()
|
||||
"Initiate a coq session.
|
||||
If there is not a current inferior-process-buffer in SESSION then
|
||||
create one. Return the initialized session."
|
||||
(unless (fboundp 'run-coq)
|
||||
(error "`run-coq' not defined, load coq-inferior.el"))
|
||||
(save-window-excursion (run-coq "coqtop"))
|
||||
(sit-for 0.1)
|
||||
(get-buffer org-babel-coq-buffer))
|
||||
|
||||
(provide 'ob-coq)
|
3143
elpa/org-20160919/ob-core.el
Normal file
3143
elpa/org-20160919/ob-core.el
Normal file
File diff suppressed because it is too large
Load Diff
48
elpa/org-20160919/ob-css.el
Normal file
48
elpa/org-20160919/ob-css.el
Normal file
@ -0,0 +1,48 @@
|
||||
;;; ob-css.el --- org-babel functions for css evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Since CSS can't be executed, this file exists solely for tangling
|
||||
;; CSS from org-mode files.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:css '())
|
||||
|
||||
(defun org-babel-execute:css (body params)
|
||||
"Execute a block of CSS code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
body)
|
||||
|
||||
(defun org-babel-prep-session:css (session params)
|
||||
"Return an error if the :session header argument is set.
|
||||
CSS does not support sessions."
|
||||
(error "CSS sessions are nonsensical"))
|
||||
|
||||
(provide 'ob-css)
|
||||
|
||||
|
||||
|
||||
;;; ob-css.el ends here
|
126
elpa/org-20160919/ob-ditaa.el
Normal file
126
elpa/org-20160919/ob-ditaa.el
Normal file
@ -0,0 +1,126 @@
|
||||
;;; ob-ditaa.el --- org-babel functions for ditaa evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating ditaa source code.
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in ditaa
|
||||
;;
|
||||
;; 2) we are generally only going to return results of type "file"
|
||||
;;
|
||||
;; 3) we are adding the "file" and "cmdline" header arguments
|
||||
;;
|
||||
;; 4) there are no variables (at least for now)
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'org-compat)
|
||||
|
||||
(defvar org-babel-default-header-args:ditaa
|
||||
'((:results . "file")
|
||||
(:exports . "results")
|
||||
(:java . "-Dfile.encoding=UTF-8"))
|
||||
"Default arguments for evaluating a ditaa source block.")
|
||||
|
||||
(defcustom org-ditaa-jar-path (expand-file-name
|
||||
"ditaa.jar"
|
||||
(file-name-as-directory
|
||||
(expand-file-name
|
||||
"scripts"
|
||||
(file-name-as-directory
|
||||
(expand-file-name
|
||||
"../contrib"
|
||||
(file-name-directory (org-find-library-dir "org")))))))
|
||||
"Path to the ditaa jar executable."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-ditaa-java-cmd "java"
|
||||
"Java executable to use when evaluating ditaa blocks."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-ditaa-eps-jar-path
|
||||
(expand-file-name "DitaaEps.jar" (file-name-directory org-ditaa-jar-path))
|
||||
"Path to the DitaaEps.jar executable."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-ditaa-jar-option "-jar"
|
||||
"Option for the ditaa jar file.
|
||||
Do not leave leading or trailing spaces in this string."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:ditaa (body params)
|
||||
"Execute a block of Ditaa code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(out-file (let ((el (cdr (assoc :file params))))
|
||||
(or el
|
||||
(error
|
||||
"ditaa code block requires :file header argument"))))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(java (cdr (assoc :java params)))
|
||||
(in-file (org-babel-temp-file "ditaa-"))
|
||||
(eps (cdr (assoc :eps params)))
|
||||
(eps-file (when eps
|
||||
(org-babel-process-file-name (concat in-file ".eps"))))
|
||||
(pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf")
|
||||
(cdr (assoc :pdf params))))
|
||||
(concat
|
||||
"epstopdf"
|
||||
" " eps-file
|
||||
" -o=" (org-babel-process-file-name out-file))))
|
||||
(cmd (concat org-babel-ditaa-java-cmd
|
||||
" " java " " org-ditaa-jar-option " "
|
||||
(shell-quote-argument
|
||||
(expand-file-name
|
||||
(if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
|
||||
" " cmdline
|
||||
" " (org-babel-process-file-name in-file)
|
||||
" " (if pdf-cmd
|
||||
eps-file
|
||||
(org-babel-process-file-name out-file)))))
|
||||
(unless (file-exists-p org-ditaa-jar-path)
|
||||
(error "Could not find ditaa.jar at %s" org-ditaa-jar-path))
|
||||
(with-temp-file in-file (insert body))
|
||||
(message cmd) (shell-command cmd)
|
||||
(when pdf-cmd (message pdf-cmd) (shell-command pdf-cmd))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:ditaa (session params)
|
||||
"Return an error because ditaa does not support sessions."
|
||||
(error "Ditaa does not support sessions"))
|
||||
|
||||
(provide 'ob-ditaa)
|
||||
|
||||
|
||||
|
||||
;;; ob-ditaa.el ends here
|
91
elpa/org-20160919/ob-dot.el
Normal file
91
elpa/org-20160919/ob-dot.el
Normal file
@ -0,0 +1,91 @@
|
||||
;;; ob-dot.el --- org-babel functions for dot evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating dot source code.
|
||||
;;
|
||||
;; For information on dot see http://www.graphviz.org/
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in dot
|
||||
;;
|
||||
;; 2) we are generally only going to return results of type "file"
|
||||
;;
|
||||
;; 3) we are adding the "file" and "cmdline" header arguments
|
||||
;;
|
||||
;; 4) there are no variables (at least for now)
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:dot
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a dot source block.")
|
||||
|
||||
(defun org-babel-expand-body:dot (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(let ((name (symbol-name (car pair)))
|
||||
(value (cdr pair)))
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(concat "$" (regexp-quote name))
|
||||
(if (stringp value) value (format "%S" value))
|
||||
body
|
||||
t
|
||||
t))))
|
||||
vars)
|
||||
body))
|
||||
|
||||
(defun org-babel-execute:dot (body params)
|
||||
"Execute a block of Dot code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (cdr (assoc :result-params params)))
|
||||
(out-file (cdr (or (assoc :file params)
|
||||
(error "You need to specify a :file parameter"))))
|
||||
(cmdline (or (cdr (assoc :cmdline params))
|
||||
(format "-T%s" (file-name-extension out-file))))
|
||||
(cmd (or (cdr (assoc :cmd params)) "dot"))
|
||||
(in-file (org-babel-temp-file "dot-")))
|
||||
(with-temp-file in-file
|
||||
(insert (org-babel-expand-body:dot body params)))
|
||||
(org-babel-eval
|
||||
(concat cmd
|
||||
" " (org-babel-process-file-name in-file)
|
||||
" " cmdline
|
||||
" -o " (org-babel-process-file-name out-file)) "")
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:dot (session params)
|
||||
"Return an error because Dot does not support sessions."
|
||||
(error "Dot does not support sessions"))
|
||||
|
||||
(provide 'ob-dot)
|
||||
|
||||
|
||||
|
||||
;;; ob-dot.el ends here
|
85
elpa/org-20160919/ob-ebnf.el
Normal file
85
elpa/org-20160919/ob-ebnf.el
Normal file
@ -0,0 +1,85 @@
|
||||
;;; ob-ebnf.el --- org-babel functions for ebnf evaluation
|
||||
|
||||
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Michael Gauland
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 1.00
|
||||
|
||||
;;; License:
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program 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; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Org-Babel support for using ebnf2ps to generate encapsulated postscript
|
||||
;;; railroad diagrams. It recogises these arguments:
|
||||
;;;
|
||||
;;; :file is required; it must include the extension '.eps.' All the rules
|
||||
;;; in the block will be drawn in the same file. This is done by
|
||||
;;; inserting a '[<file>' comment at the start of the block (see the
|
||||
;;; documentation for ebnf-eps-buffer for more information).
|
||||
;;;
|
||||
;;; :style specifies a value in ebnf-style-database. This provides the
|
||||
;;; ability to customise the output. The style can also specify the
|
||||
;;; grammar syntax (by setting ebnf-syntax); note that only ebnf,
|
||||
;;; iso-ebnf, and yacc are supported by this file.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ebnf2ps)
|
||||
|
||||
;; optionally declare default header arguments for this language
|
||||
(defvar org-babel-default-header-args:ebnf '((:style . nil)))
|
||||
|
||||
;; Use ebnf-eps-buffer to produce an encapsulated postscript file.
|
||||
;;
|
||||
(defun org-babel-execute:ebnf (body params)
|
||||
"Execute a block of Ebnf code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(save-excursion
|
||||
(let* ((dest-file (cdr (assoc :file params)))
|
||||
(dest-dir (file-name-directory dest-file))
|
||||
(dest-root (file-name-sans-extension
|
||||
(file-name-nondirectory dest-file)))
|
||||
(dest-ext (file-name-extension dest-file))
|
||||
(style (cdr (assoc :style params)))
|
||||
(current-dir default-directory)
|
||||
(result nil))
|
||||
(with-temp-buffer
|
||||
(when style (ebnf-push-style style))
|
||||
(let ((comment-format
|
||||
(cond ((string= ebnf-syntax 'yacc) "/*%s*/")
|
||||
((string= ebnf-syntax 'ebnf) ";%s")
|
||||
((string= ebnf-syntax 'iso-ebnf) "(*%s*)")
|
||||
(t (setq result
|
||||
(format "EBNF error: format %s not supported."
|
||||
ebnf-syntax))))))
|
||||
(setq ebnf-eps-prefix dest-dir)
|
||||
(insert (format comment-format (format "[%s" dest-root)))
|
||||
(newline)
|
||||
(insert body)
|
||||
(newline)
|
||||
(insert (format comment-format (format "]%s" dest-root)))
|
||||
(ebnf-eps-buffer)
|
||||
(when style (ebnf-pop-style))))
|
||||
result)))
|
||||
|
||||
(provide 'ob-ebnf)
|
||||
;;; ob-ebnf.el ends here
|
79
elpa/org-20160919/ob-emacs-lisp.el
Normal file
79
elpa/org-20160919/ob-emacs-lisp.el
Normal file
@ -0,0 +1,79 @@
|
||||
;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating emacs-lisp code
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:emacs-lisp nil
|
||||
"Default arguments for evaluating an emacs-lisp source block.")
|
||||
|
||||
(defun org-babel-expand-body:emacs-lisp (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(print-level nil) (print-length nil)
|
||||
(body (if (> (length vars) 0)
|
||||
(concat "(let ("
|
||||
(mapconcat
|
||||
(lambda (var)
|
||||
(format "%S" (print `(,(car var) ',(cdr var)))))
|
||||
vars "\n ")
|
||||
")\n" body "\n)")
|
||||
(concat body "\n"))))
|
||||
(if (or (member "code" result-params)
|
||||
(member "pp" result-params))
|
||||
(concat "(pp " body ")") body)))
|
||||
|
||||
(defun org-babel-execute:emacs-lisp (body params)
|
||||
"Execute a block of emacs-lisp code with Babel."
|
||||
(save-window-excursion
|
||||
(let ((result
|
||||
(eval (read (format (if (member "output"
|
||||
(cdr (assoc :result-params params)))
|
||||
"(with-output-to-string %s)"
|
||||
"(progn %s)")
|
||||
(org-babel-expand-body:emacs-lisp
|
||||
body params))))))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(let ((print-level nil)
|
||||
(print-length nil))
|
||||
(if (or (member "scalar" (cdr (assoc :result-params params)))
|
||||
(member "verbatim" (cdr (assoc :result-params params))))
|
||||
(format "%S" result)
|
||||
(format "%s" result)))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params))))))))
|
||||
|
||||
(provide 'ob-emacs-lisp)
|
||||
|
||||
|
||||
|
||||
;;; ob-emacs-lisp.el ends here
|
150
elpa/org-20160919/ob-eval.el
Normal file
150
elpa/org-20160919/ob-eval.el
Normal file
@ -0,0 +1,150 @@
|
||||
;;; ob-eval.el --- org-babel functions for external code evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, comint
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; These functions build existing Emacs support for executing external
|
||||
;; shell commands.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-macs)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
|
||||
(declare-function org-babel-temp-file "ob-core" (prefix &optional suffix))
|
||||
|
||||
(defun org-babel-eval-error-notify (exit-code stderr)
|
||||
"Open a buffer to display STDERR and a message with the value of EXIT-CODE."
|
||||
(let ((buf (get-buffer-create org-babel-error-buffer-name)))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-max))
|
||||
(save-excursion (insert stderr)))
|
||||
(display-buffer buf))
|
||||
(message "Babel evaluation exited with code %S" exit-code))
|
||||
|
||||
(defun org-babel-eval (cmd body)
|
||||
"Run CMD on BODY.
|
||||
If CMD succeeds then return its results, otherwise display
|
||||
STDERR with `org-babel-eval-error-notify'."
|
||||
(let ((err-buff (get-buffer-create " *Org-Babel Error*")) exit-code)
|
||||
(with-current-buffer err-buff (erase-buffer))
|
||||
(with-temp-buffer
|
||||
(insert body)
|
||||
(setq exit-code
|
||||
(org-babel--shell-command-on-region
|
||||
(point-min) (point-max) cmd err-buff))
|
||||
(if (or (not (numberp exit-code)) (> exit-code 0))
|
||||
(progn
|
||||
(with-current-buffer err-buff
|
||||
(org-babel-eval-error-notify exit-code (buffer-string)))
|
||||
(save-excursion
|
||||
(when (get-buffer org-babel-error-buffer-name)
|
||||
(with-current-buffer org-babel-error-buffer-name
|
||||
(unless (derived-mode-p 'compilation-mode)
|
||||
(compilation-mode))
|
||||
;; Compilation-mode enforces read-only, but Babel expects the buffer modifiable.
|
||||
(setq buffer-read-only nil))))
|
||||
nil)
|
||||
(buffer-string)))))
|
||||
|
||||
(defun org-babel-eval-read-file (file)
|
||||
"Return the contents of FILE as a string."
|
||||
(with-temp-buffer (insert-file-contents file)
|
||||
(buffer-string)))
|
||||
|
||||
(defun org-babel--shell-command-on-region (start end command error-buffer)
|
||||
"Execute COMMAND in an inferior shell with region as input.
|
||||
|
||||
Stripped down version of shell-command-on-region for internal use
|
||||
in Babel only. This lets us work around errors in the original
|
||||
function in various versions of Emacs.
|
||||
"
|
||||
(let ((input-file (org-babel-temp-file "ob-input-"))
|
||||
(error-file (if error-buffer (org-babel-temp-file "ob-error-") nil))
|
||||
;; Unfortunately, `executable-find' does not support file name
|
||||
;; handlers. Therefore, we could use it in the local case
|
||||
;; only.
|
||||
(shell-file-name
|
||||
(cond ((and (not (file-remote-p default-directory))
|
||||
(executable-find shell-file-name))
|
||||
shell-file-name)
|
||||
((file-executable-p
|
||||
(concat (file-remote-p default-directory) shell-file-name))
|
||||
shell-file-name)
|
||||
("/bin/sh")))
|
||||
exit-status)
|
||||
;; There is an error in `process-file' when `error-file' exists.
|
||||
;; This is fixed in Emacs trunk as of 2012-12-21; let's use this
|
||||
;; workaround for now.
|
||||
(unless (file-remote-p default-directory)
|
||||
(delete-file error-file))
|
||||
;; we always call this with 'replace, remove conditional
|
||||
;; Replace specified region with output from command.
|
||||
(let ((swap (< start end)))
|
||||
(goto-char start)
|
||||
(push-mark (point) 'nomsg)
|
||||
(write-region start end input-file)
|
||||
(delete-region start end)
|
||||
(setq exit-status
|
||||
(process-file shell-file-name input-file
|
||||
(if error-file
|
||||
(list t error-file)
|
||||
t)
|
||||
nil shell-command-switch command))
|
||||
(when swap (exchange-point-and-mark)))
|
||||
|
||||
(when (and input-file (file-exists-p input-file)
|
||||
;; bind org-babel--debug-input around the call to keep
|
||||
;; the temporary input files available for inspection
|
||||
(not (when (boundp 'org-babel--debug-input)
|
||||
org-babel--debug-input)))
|
||||
(delete-file input-file))
|
||||
|
||||
(when (and error-file (file-exists-p error-file))
|
||||
(if (< 0 (nth 7 (file-attributes error-file)))
|
||||
(with-current-buffer (get-buffer-create error-buffer)
|
||||
(let ((pos-from-end (- (point-max) (point))))
|
||||
(or (bobp)
|
||||
(insert "\f\n"))
|
||||
;; Do no formatting while reading error file,
|
||||
;; because that can run a shell command, and we
|
||||
;; don't want that to cause an infinite recursion.
|
||||
(format-insert-file error-file nil)
|
||||
;; Put point after the inserted errors.
|
||||
(goto-char (- (point-max) pos-from-end)))
|
||||
(current-buffer)))
|
||||
(delete-file error-file))
|
||||
exit-status))
|
||||
|
||||
(defun org-babel-eval-wipe-error-buffer ()
|
||||
"Delete the contents of the Org code block error buffer.
|
||||
This buffer is named by `org-babel-error-buffer-name'."
|
||||
(when (get-buffer org-babel-error-buffer-name)
|
||||
(with-current-buffer org-babel-error-buffer-name
|
||||
(delete-region (point-min) (point-max)))))
|
||||
|
||||
(provide 'ob-eval)
|
||||
|
||||
|
||||
|
||||
;;; ob-eval.el ends here
|
448
elpa/org-20160919/ob-exp.el
Normal file
448
elpa/org-20160919/ob-exp.el
Normal file
@ -0,0 +1,448 @@
|
||||
;;; ob-exp.el --- Exportation of org-babel source blocks
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Eric Schulte
|
||||
;; Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob-core)
|
||||
(require 'org-src)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defvar org-babel-lob-one-liner-regexp)
|
||||
(defvar org-babel-ref-split-regexp)
|
||||
(defvar org-list-forbidden-blocks)
|
||||
|
||||
(declare-function org-babel-lob-get-info "ob-lob" ())
|
||||
(declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
|
||||
(declare-function org-between-regexps-p "ob-eval" (start-re end-re &optional lim-up lim-down))
|
||||
(declare-function org-get-indentation "org" (&optional line))
|
||||
(declare-function org-heading-components "org" ())
|
||||
(declare-function org-in-block-p "org" (names))
|
||||
(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
|
||||
(declare-function org-in-verbatim-emphasis "org" ())
|
||||
(declare-function org-link-search "org" (s &optional avoid-pos stealth))
|
||||
(declare-function org-fill-template "org" (template alist))
|
||||
(declare-function org-split-string "org" (string &optional separators))
|
||||
(declare-function org-element-at-point "org-element" ())
|
||||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-property "org-element" (property element))
|
||||
(declare-function org-element-type "org-element" (element))
|
||||
(declare-function org-id-get "org-id" (&optional pom create prefix))
|
||||
(declare-function org-escape-code-in-string "org-src" (s))
|
||||
|
||||
(defcustom org-export-babel-evaluate t
|
||||
"Switch controlling code evaluation during export.
|
||||
When set to nil no code will be evaluated as part of the export
|
||||
process. When set to `inline-only', only inline code blocks will
|
||||
be executed."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type '(choice (const :tag "Never" nil)
|
||||
(const :tag "Only inline code" inline-only)
|
||||
(const :tag "Always" t)))
|
||||
(put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil)))
|
||||
|
||||
(defvar org-link-search-inhibit-query)
|
||||
(defmacro org-babel-exp-in-export-file (lang &rest body)
|
||||
(declare (indent 1))
|
||||
`(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang)))
|
||||
(heading-query (or (org-id-get)
|
||||
;; CUSTOM_IDs don't work, maybe they are
|
||||
;; stripped, or maybe they resolve too
|
||||
;; late in `org-link-search'.
|
||||
;; (org-entry-get nil "CUSTOM_ID")
|
||||
(nth 4 (ignore-errors (org-heading-components)))))
|
||||
(export-buffer (current-buffer))
|
||||
results)
|
||||
(when org-babel-exp-reference-buffer
|
||||
;; Resolve parameters in the original file so that headline and
|
||||
;; file-wide parameters are included, attempt to go to the same
|
||||
;; heading in the original file
|
||||
(set-buffer org-babel-exp-reference-buffer)
|
||||
(save-restriction
|
||||
(when heading-query
|
||||
(condition-case nil
|
||||
(let ((org-link-search-inhibit-query t))
|
||||
;; TODO: When multiple headings have the same title,
|
||||
;; this returns the first, which is not always
|
||||
;; the right heading. Consider a better way to
|
||||
;; find the proper heading.
|
||||
(org-link-search heading-query))
|
||||
(error (when heading-query
|
||||
(goto-char (point-min))
|
||||
(re-search-forward (regexp-quote heading-query) nil t)))))
|
||||
(setq results ,@body))
|
||||
(set-buffer export-buffer)
|
||||
results)))
|
||||
(def-edebug-spec org-babel-exp-in-export-file (form body))
|
||||
|
||||
(defun org-babel-exp-src-block (&rest headers)
|
||||
"Process source block for export.
|
||||
Depending on the `export' headers argument, replace the source
|
||||
code block like this:
|
||||
|
||||
both ---- display the code and the results
|
||||
|
||||
code ---- the default, display the code inside the block but do
|
||||
not process
|
||||
|
||||
results - just like none only the block is run on export ensuring
|
||||
that its results are present in the org-mode buffer
|
||||
|
||||
none ---- do not display either code or results upon export
|
||||
|
||||
Assume point is at the beginning of block's starting line."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(let* ((info (org-babel-get-src-block-info 'light))
|
||||
(line (org-current-line))
|
||||
(lang (nth 0 info))
|
||||
(raw-params (nth 2 info)) hash)
|
||||
;; bail if we couldn't get any info from the block
|
||||
(unless noninteractive
|
||||
(message "org-babel-exp process %s at line %d..." lang line))
|
||||
(when info
|
||||
;; if we're actually going to need the parameters
|
||||
(when (member (cdr (assoc :exports (nth 2 info))) '("both" "results"))
|
||||
(org-babel-exp-in-export-file lang
|
||||
(setf (nth 2 info)
|
||||
(org-babel-process-params
|
||||
(apply #'org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
(if (boundp lang-headers) (eval lang-headers) nil)
|
||||
(append (org-babel-params-from-properties lang)
|
||||
(list raw-params))))))
|
||||
(setf hash (org-babel-sha1-hash info)))
|
||||
(org-babel-exp-do-export info 'block hash)))))
|
||||
|
||||
(defcustom org-babel-exp-call-line-template
|
||||
""
|
||||
"Template used to export call lines.
|
||||
This template may be customized to include the call line name
|
||||
with any export markup. The template is filled out using
|
||||
`org-fill-template', and the following %keys may be used.
|
||||
|
||||
line --- call line
|
||||
|
||||
An example value would be \"\\n: call: %line\" to export the call line
|
||||
wrapped in a verbatim environment.
|
||||
|
||||
Note: the results are inserted separately after the contents of
|
||||
this template."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defvar org-babel-default-lob-header-args)
|
||||
(defun org-babel-exp-process-buffer (reference-buffer)
|
||||
"Execute all Babel blocks in current buffer.
|
||||
REFERENCE-BUFFER is the buffer containing a pristine copy of the
|
||||
buffer being processed. It is used to properly resolve
|
||||
references in source blocks, as modifications in current buffer
|
||||
may make them unreachable."
|
||||
(interactive)
|
||||
(save-window-excursion
|
||||
(save-excursion
|
||||
(let ((case-fold-search t)
|
||||
(org-babel-exp-reference-buffer reference-buffer)
|
||||
(regexp (concat org-babel-inline-src-block-regexp "\\|"
|
||||
org-babel-lob-one-liner-regexp "\\|"
|
||||
"^[ \t]*#\\+BEGIN_SRC")))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward regexp nil t)
|
||||
(unless (save-match-data (org-in-commented-heading-p))
|
||||
(let* ((element (save-excursion
|
||||
;; If match is inline, point is at its
|
||||
;; end. Move backward so
|
||||
;; `org-element-context' can get the
|
||||
;; object, not the following one.
|
||||
(backward-char)
|
||||
(save-match-data (org-element-context))))
|
||||
(type (org-element-type element))
|
||||
(begin (copy-marker (org-element-property :begin element)))
|
||||
(end (copy-marker
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(point)))))
|
||||
(case type
|
||||
(inline-src-block
|
||||
(let* ((head (match-beginning 0))
|
||||
(info (append (org-babel-parse-inline-src-block-match)
|
||||
(list nil nil head)))
|
||||
(params (nth 2 info)))
|
||||
(setf (nth 1 info)
|
||||
(if (and (cdr (assoc :noweb params))
|
||||
(string= "yes" (cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info org-babel-exp-reference-buffer)
|
||||
(nth 1 info)))
|
||||
(goto-char begin)
|
||||
(let ((replacement (org-babel-exp-do-export info 'inline)))
|
||||
(if (equal replacement "")
|
||||
;; Replacement code is empty: remove inline
|
||||
;; source block, including extra white space
|
||||
;; that might have been created when
|
||||
;; inserting results.
|
||||
(delete-region begin
|
||||
(progn (goto-char end)
|
||||
(skip-chars-forward " \t")
|
||||
(point)))
|
||||
;; Otherwise: remove inline src block but
|
||||
;; preserve following white spaces. Then
|
||||
;; insert value.
|
||||
(delete-region begin end)
|
||||
(insert replacement)))))
|
||||
((babel-call inline-babel-call)
|
||||
(let* ((lob-info (org-babel-lob-get-info))
|
||||
(results
|
||||
(org-babel-exp-do-export
|
||||
(list "emacs-lisp" "results"
|
||||
(apply #'org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-lob-header-args
|
||||
(append
|
||||
(org-babel-params-from-properties)
|
||||
(list
|
||||
(org-babel-parse-header-arguments
|
||||
(org-no-properties
|
||||
(concat
|
||||
":var results="
|
||||
(mapconcat 'identity
|
||||
(butlast lob-info 2)
|
||||
" ")))))))
|
||||
"" (nth 3 lob-info) (nth 2 lob-info))
|
||||
'lob))
|
||||
(rep (org-fill-template
|
||||
org-babel-exp-call-line-template
|
||||
`(("line" . ,(nth 0 lob-info))))))
|
||||
;; If replacement is empty, completely remove the
|
||||
;; object/element, including any extra white space
|
||||
;; that might have been created when including
|
||||
;; results.
|
||||
(if (equal rep "")
|
||||
(delete-region
|
||||
begin
|
||||
(progn (goto-char end)
|
||||
(if (not (eq type 'babel-call))
|
||||
(progn (skip-chars-forward " \t") (point))
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(line-beginning-position))))
|
||||
;; Otherwise, preserve following white
|
||||
;; spaces/newlines and then, insert replacement
|
||||
;; string.
|
||||
(goto-char begin)
|
||||
(delete-region begin end)
|
||||
(insert rep))))
|
||||
(src-block
|
||||
(let* ((match-start (copy-marker (match-beginning 0)))
|
||||
(ind (org-get-indentation))
|
||||
(lang (or (org-element-property :language element)
|
||||
(user-error
|
||||
"No language for src block: %s"
|
||||
(or (org-element-property :name element)
|
||||
"(unnamed)"))))
|
||||
(headers
|
||||
(cons lang
|
||||
(let ((params
|
||||
(org-element-property
|
||||
:parameters element)))
|
||||
(and params (org-split-string params))))))
|
||||
;; Take care of matched block: compute replacement
|
||||
;; string. In particular, a nil REPLACEMENT means
|
||||
;; the block should be left as-is while an empty
|
||||
;; string should remove the block.
|
||||
(let ((replacement
|
||||
(progn (goto-char match-start)
|
||||
(org-babel-exp-src-block headers))))
|
||||
(cond ((not replacement) (goto-char end))
|
||||
((equal replacement "")
|
||||
(goto-char end)
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(beginning-of-line)
|
||||
(delete-region begin (point)))
|
||||
(t
|
||||
(goto-char match-start)
|
||||
(delete-region (point)
|
||||
(save-excursion (goto-char end)
|
||||
(line-end-position)))
|
||||
(insert replacement)
|
||||
(if (or org-src-preserve-indentation
|
||||
(org-element-property :preserve-indent
|
||||
element))
|
||||
;; Indent only the code block markers.
|
||||
(save-excursion (skip-chars-backward " \r\t\n")
|
||||
(indent-line-to ind)
|
||||
(goto-char match-start)
|
||||
(indent-line-to ind))
|
||||
;; Indent everything.
|
||||
(indent-rigidly match-start (point) ind)))))
|
||||
(set-marker match-start nil))))
|
||||
(set-marker begin nil)
|
||||
(set-marker end nil))))))))
|
||||
|
||||
(defun org-babel-in-example-or-verbatim ()
|
||||
"Return true if point is in example or verbatim code.
|
||||
Example and verbatim code include escaped portions of
|
||||
an org-mode buffer code that should be treated as normal
|
||||
org-mode text."
|
||||
(or (save-match-data
|
||||
(save-excursion
|
||||
(goto-char (point-at-bol))
|
||||
(looking-at "[ \t]*:[ \t]")))
|
||||
(org-in-verbatim-emphasis)
|
||||
(org-in-block-p org-list-forbidden-blocks)
|
||||
(org-between-regexps-p "^[ \t]*#\\+begin_src" "^[ \t]*#\\+end_src")))
|
||||
|
||||
(defun org-babel-exp-do-export (info type &optional hash)
|
||||
"Return a string with the exported content of a code block.
|
||||
The function respects the value of the :exports header argument."
|
||||
(let ((silently (lambda () (let ((session (cdr (assoc :session (nth 2 info)))))
|
||||
(when (not (and session (equal "none" session)))
|
||||
(org-babel-exp-results info type 'silent)))))
|
||||
(clean (lambda () (if (eq type 'inline)
|
||||
(org-babel-remove-inline-result)
|
||||
(org-babel-remove-result info)))))
|
||||
(case (intern (or (cdr (assoc :exports (nth 2 info))) "code"))
|
||||
('none (funcall silently) (funcall clean) "")
|
||||
('code (funcall silently) (funcall clean) (org-babel-exp-code info type))
|
||||
('results (org-babel-exp-results info type nil hash) "")
|
||||
('both (org-babel-exp-results info type nil hash)
|
||||
(org-babel-exp-code info type)))))
|
||||
|
||||
(defcustom org-babel-exp-code-template
|
||||
"#+BEGIN_SRC %lang%switches%flags\n%body\n#+END_SRC"
|
||||
"Template used to export the body of code blocks.
|
||||
This template may be customized to include additional information
|
||||
such as the code block name, or the values of particular header
|
||||
arguments. The template is filled out using `org-fill-template',
|
||||
and the following %keys may be used.
|
||||
|
||||
lang ------ the language of the code block
|
||||
name ------ the name of the code block
|
||||
body ------ the body of the code block
|
||||
switches -- the switches associated to the code block
|
||||
flags ----- the flags passed to the code block
|
||||
|
||||
In addition to the keys mentioned above, every header argument
|
||||
defined for the code block may be used as a key and will be
|
||||
replaced with its value."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-exp-inline-code-template
|
||||
"src_%lang[%switches%flags]{%body}"
|
||||
"Template used to export the body of inline code blocks.
|
||||
This template may be customized to include additional information
|
||||
such as the code block name, or the values of particular header
|
||||
arguments. The template is filled out using `org-fill-template',
|
||||
and the following %keys may be used.
|
||||
|
||||
lang ------ the language of the code block
|
||||
name ------ the name of the code block
|
||||
body ------ the body of the code block
|
||||
switches -- the switches associated to the code block
|
||||
flags ----- the flags passed to the code block
|
||||
|
||||
In addition to the keys mentioned above, every header argument
|
||||
defined for the code block may be used as a key and will be
|
||||
replaced with its value."
|
||||
:group 'org-babel
|
||||
:type 'string
|
||||
:version "25.1"
|
||||
:package-version '(Org . "8.3"))
|
||||
|
||||
(defun org-babel-exp-code (info type)
|
||||
"Return the original code block formatted for export."
|
||||
(setf (nth 1 info)
|
||||
(if (string= "strip-export" (cdr (assoc :noweb (nth 2 info))))
|
||||
(replace-regexp-in-string
|
||||
(org-babel-noweb-wrap) "" (nth 1 info))
|
||||
(if (org-babel-noweb-p (nth 2 info) :export)
|
||||
(org-babel-expand-noweb-references
|
||||
info org-babel-exp-reference-buffer)
|
||||
(nth 1 info))))
|
||||
(org-fill-template
|
||||
(if (eq type 'inline)
|
||||
org-babel-exp-inline-code-template
|
||||
org-babel-exp-code-template)
|
||||
`(("lang" . ,(nth 0 info))
|
||||
("body" . ,(org-escape-code-in-string (nth 1 info)))
|
||||
("switches" . ,(let ((f (nth 3 info)))
|
||||
(and (org-string-nw-p f) (concat " " f))))
|
||||
("flags" . ,(let ((f (assq :flags (nth 2 info))))
|
||||
(and f (concat " " (cdr f)))))
|
||||
,@(mapcar (lambda (pair)
|
||||
(cons (substring (symbol-name (car pair)) 1)
|
||||
(format "%S" (cdr pair))))
|
||||
(nth 2 info))
|
||||
("name" . ,(or (nth 4 info) "")))))
|
||||
|
||||
(defun org-babel-exp-results (info type &optional silent hash)
|
||||
"Evaluate and return the results of the current code block for export.
|
||||
Results are prepared in a manner suitable for export by org-mode.
|
||||
This function is called by `org-babel-exp-do-export'. The code
|
||||
block will be evaluated. Optional argument SILENT can be used to
|
||||
inhibit insertion of results into the buffer."
|
||||
(when (and (or (eq org-export-babel-evaluate t)
|
||||
(and (eq type 'inline)
|
||||
(eq org-export-babel-evaluate 'inline-only)))
|
||||
(not (and hash (equal hash (org-babel-current-result-hash)))))
|
||||
(let ((lang (nth 0 info))
|
||||
(body (if (org-babel-noweb-p (nth 2 info) :eval)
|
||||
(org-babel-expand-noweb-references
|
||||
info org-babel-exp-reference-buffer)
|
||||
(nth 1 info)))
|
||||
(info (copy-sequence info))
|
||||
(org-babel-current-src-block-location (point-marker)))
|
||||
;; skip code blocks which we can't evaluate
|
||||
(when (fboundp (intern (concat "org-babel-execute:" lang)))
|
||||
(org-babel-eval-wipe-error-buffer)
|
||||
(prog1 nil
|
||||
(setf (nth 1 info) body)
|
||||
(setf (nth 2 info)
|
||||
(org-babel-exp-in-export-file lang
|
||||
(org-babel-process-params
|
||||
(org-babel-merge-params
|
||||
(nth 2 info)
|
||||
`((:results . ,(if silent "silent" "replace")))))))
|
||||
(cond
|
||||
((equal type 'block)
|
||||
(org-babel-execute-src-block nil info))
|
||||
((equal type 'inline)
|
||||
;; position the point on the inline source block allowing
|
||||
;; `org-babel-insert-result' to check that the block is
|
||||
;; inline
|
||||
(re-search-backward "[ \f\t\n\r\v]" nil t)
|
||||
(re-search-forward org-babel-inline-src-block-regexp nil t)
|
||||
(re-search-backward "src_" nil t)
|
||||
(org-babel-execute-src-block nil info))
|
||||
((equal type 'lob)
|
||||
(save-excursion
|
||||
(re-search-backward org-babel-lob-one-liner-regexp nil t)
|
||||
(let (org-confirm-babel-evaluate)
|
||||
(org-babel-execute-src-block nil info))))))))))
|
||||
|
||||
|
||||
(provide 'ob-exp)
|
||||
|
||||
;;; ob-exp.el ends here
|
86
elpa/org-20160919/ob-forth.el
Normal file
86
elpa/org-20160919/ob-forth.el
Normal file
@ -0,0 +1,86 @@
|
||||
;;; ob-forth.el --- org-babel functions for Forth
|
||||
|
||||
;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, forth
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Requires the gforth forth compiler and `forth-mode' (see below).
|
||||
;; https://www.gnu.org/software/gforth/
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; Session evaluation requires the gforth forth compiler as well as
|
||||
;; `forth-mode' which is distributed with gforth (in gforth.el).
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function forth-proc "ext:gforth" ())
|
||||
|
||||
(defvar org-babel-default-header-args:forth '((:session . "yes"))
|
||||
"Default header arguments for forth code blocks.")
|
||||
|
||||
(defun org-babel-execute:forth (body params)
|
||||
"Execute a block of Forth code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'"
|
||||
(if (string= "none" (cdr (assoc :session params)))
|
||||
(error "Non-session evaluation not supported for Forth code blocks")
|
||||
(let ((all-results (org-babel-forth-session-execute body params)))
|
||||
(if (member "output" (cdr (assoc :result-params params)))
|
||||
(mapconcat #'identity all-results "\n")
|
||||
(car (last all-results))))))
|
||||
|
||||
(defun org-babel-forth-session-execute (body params)
|
||||
(require 'forth-mode)
|
||||
(let ((proc (forth-proc))
|
||||
(rx " \\(\n:\\|compiled\n\\\|ok\n\\)")
|
||||
(result-start))
|
||||
(with-current-buffer (process-buffer (forth-proc))
|
||||
(mapcar (lambda (line)
|
||||
(setq result-start (progn (goto-char (process-mark proc))
|
||||
(point)))
|
||||
(comint-send-string proc (concat line "\n"))
|
||||
;; wait for forth to say "ok"
|
||||
(while (not (progn (goto-char result-start)
|
||||
(re-search-forward rx nil t)))
|
||||
(accept-process-output proc 0.01))
|
||||
(let ((case (match-string 1)))
|
||||
(cond
|
||||
((string= "ok\n" case)
|
||||
;; Collect intermediate output.
|
||||
(buffer-substring (+ result-start 1 (length line))
|
||||
(match-beginning 0)))
|
||||
((string= "compiled\n" case))
|
||||
;; Ignore partial compilation.
|
||||
((string= "\n:" case)
|
||||
;; Report errors.
|
||||
(org-babel-eval-error-notify 1
|
||||
(buffer-substring
|
||||
(+ (match-beginning 0) 1) (point-max))) nil))))
|
||||
(split-string (org-babel-trim
|
||||
(org-babel-expand-body:generic
|
||||
body params))
|
||||
"\n" 'omit-nulls)))))
|
||||
|
||||
(provide 'ob-forth)
|
||||
|
||||
;;; ob-forth.el ends here
|
169
elpa/org-20160919/ob-fortran.el
Normal file
169
elpa/org-20160919/ob-fortran.el
Normal file
@ -0,0 +1,169 @@
|
||||
;;; ob-fortran.el --- org-babel functions for fortran
|
||||
|
||||
;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Sergey Litvinov
|
||||
;; Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, fortran
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating fortran code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'cc-mode)
|
||||
|
||||
(declare-function org-entry-get "org"
|
||||
(pom property &optional inherit literal-nil))
|
||||
(declare-function org-every "org" (pred seq))
|
||||
(declare-function org-remove-indentation "org" (code &optional n))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("fortran" . "F90"))
|
||||
|
||||
(defvar org-babel-default-header-args:fortran '())
|
||||
|
||||
(defvar org-babel-fortran-compiler "gfortran"
|
||||
"fortran command used to compile a fortran source code file into an
|
||||
executable.")
|
||||
|
||||
(defun org-babel-execute:fortran (body params)
|
||||
"This function should only be called by `org-babel-execute:fortran'"
|
||||
(let* ((tmp-src-file (org-babel-temp-file "fortran-src-" ".F90"))
|
||||
(tmp-bin-file (org-babel-temp-file "fortran-bin-" org-babel-exeext))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(flags (cdr (assoc :flags params)))
|
||||
(full-body (org-babel-expand-body:fortran body params))
|
||||
(compile
|
||||
(progn
|
||||
(with-temp-file tmp-src-file (insert full-body))
|
||||
(org-babel-eval
|
||||
(format "%s -o %s %s %s"
|
||||
org-babel-fortran-compiler
|
||||
(org-babel-process-file-name tmp-bin-file)
|
||||
(mapconcat 'identity
|
||||
(if (listp flags) flags (list flags)) " ")
|
||||
(org-babel-process-file-name tmp-src-file)) ""))))
|
||||
(let ((results
|
||||
(org-babel-trim
|
||||
(org-remove-indentation
|
||||
(org-babel-eval
|
||||
(concat tmp-bin-file (if cmdline (concat " " cmdline) "")) "")))))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(org-babel-read results)
|
||||
(let ((tmp-file (org-babel-temp-file "f-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
|
||||
|
||||
(defun org-babel-expand-body:fortran (body params)
|
||||
"Expand a block of fortran or fortran code with org-babel according to
|
||||
its header arguments."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(main-p (not (string= (cdr (assoc :main params)) "no")))
|
||||
(includes (or (cdr (assoc :includes params))
|
||||
(org-babel-read (org-entry-get nil "includes" t))))
|
||||
(defines (org-babel-read
|
||||
(or (cdr (assoc :defines params))
|
||||
(org-babel-read (org-entry-get nil "defines" t))))))
|
||||
(mapconcat 'identity
|
||||
(list
|
||||
;; includes
|
||||
(mapconcat
|
||||
(lambda (inc) (format "#include %s" inc))
|
||||
(if (listp includes) includes (list includes)) "\n")
|
||||
;; defines
|
||||
(mapconcat
|
||||
(lambda (inc) (format "#define %s" inc))
|
||||
(if (listp defines) defines (list defines)) "\n")
|
||||
;; body
|
||||
(if main-p
|
||||
(org-babel-fortran-ensure-main-wrap
|
||||
(concat
|
||||
;; variables
|
||||
(mapconcat 'org-babel-fortran-var-to-fortran vars "\n")
|
||||
body) params)
|
||||
body) "\n") "\n")))
|
||||
|
||||
(defun org-babel-fortran-ensure-main-wrap (body params)
|
||||
"Wrap body in a \"program ... end program\" block if none exists."
|
||||
(if (string-match "^[ \t]*program[ \t]*.*" (capitalize body))
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(if vars (error "Cannot use :vars if `program' statement is present"))
|
||||
body)
|
||||
(format "program main\n%s\nend program main\n" body)))
|
||||
|
||||
(defun org-babel-prep-session:fortran (session params)
|
||||
"This function does nothing as fortran is a compiled language with no
|
||||
support for sessions"
|
||||
(error "Fortran is a compiled languages -- no support for sessions"))
|
||||
|
||||
(defun org-babel-load-session:fortran (session body params)
|
||||
"This function does nothing as fortran is a compiled language with no
|
||||
support for sessions"
|
||||
(error "Fortran is a compiled languages -- no support for sessions"))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-fortran-var-to-fortran (pair)
|
||||
"Convert an elisp val into a string of fortran code specifying a var
|
||||
of the same value."
|
||||
;; TODO list support
|
||||
(let ((var (car pair))
|
||||
(val (cdr pair)))
|
||||
(when (symbolp val)
|
||||
(setq val (symbol-name val))
|
||||
(when (= (length val) 1)
|
||||
(setq val (string-to-char val))))
|
||||
(cond
|
||||
((integerp val)
|
||||
(format "integer, parameter :: %S = %S\n" var val))
|
||||
((floatp val)
|
||||
(format "real, parameter :: %S = %S\n" var val))
|
||||
((or (integerp val))
|
||||
(format "character, parameter :: %S = '%S'\n" var val))
|
||||
((stringp val)
|
||||
(format "character(len=%d), parameter :: %S = '%s'\n"
|
||||
(length val) var val))
|
||||
;; val is a matrix
|
||||
((and (listp val) (org-every #'listp val))
|
||||
(format "real, parameter :: %S(%d,%d) = transpose( reshape( %s , (/ %d, %d /) ) )\n"
|
||||
var (length val) (length (car val))
|
||||
(org-babel-fortran-transform-list val)
|
||||
(length (car val)) (length val)))
|
||||
((listp val)
|
||||
(format "real, parameter :: %S(%d) = %s\n"
|
||||
var (length val) (org-babel-fortran-transform-list val)))
|
||||
(t
|
||||
(error "the type of parameter %s is not supported by ob-fortran" var)))))
|
||||
|
||||
(defun org-babel-fortran-transform-list (val)
|
||||
"Return a fortran representation of enclose syntactic lists."
|
||||
(if (listp val)
|
||||
(concat "(/" (mapconcat #'org-babel-fortran-transform-list val ", ") "/)")
|
||||
(format "%S" val)))
|
||||
|
||||
(provide 'ob-fortran)
|
||||
|
||||
;;; ob-fortran.el ends here
|
280
elpa/org-20160919/ob-gnuplot.el
Normal file
280
elpa/org-20160919/ob-gnuplot.el
Normal file
@ -0,0 +1,280 @@
|
||||
;;; ob-gnuplot.el --- org-babel functions for gnuplot evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating gnuplot source code.
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) we are generally only going to return results of type "file"
|
||||
;;
|
||||
;; 2) we are adding the "file" and "cmdline" header arguments
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - gnuplot :: http://www.gnuplot.info/
|
||||
;;
|
||||
;; - gnuplot-mode :: http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-time-string-to-time "org" (s &optional buffer pos))
|
||||
(declare-function org-combine-plists "org" (&rest plists))
|
||||
(declare-function orgtbl-to-generic "org-table" (table params))
|
||||
(declare-function gnuplot-mode "ext:gnuplot-mode" ())
|
||||
(declare-function gnuplot-send-string-to-gnuplot "ext:gnuplot-mode" (str txt))
|
||||
(declare-function gnuplot-send-buffer-to-gnuplot "ext:gnuplot-mode" ())
|
||||
|
||||
(defvar org-babel-default-header-args:gnuplot
|
||||
'((:results . "file") (:exports . "results") (:session . nil))
|
||||
"Default arguments to use when evaluating a gnuplot source block.")
|
||||
|
||||
(defvar org-babel-header-args:gnuplot
|
||||
'((title . :any)
|
||||
(lines . :any)
|
||||
(sets . :any)
|
||||
(x-labels . :any)
|
||||
(y-labels . :any)
|
||||
(timefmt . :any)
|
||||
(time-ind . :any)
|
||||
(missing . :any)
|
||||
(term . :any))
|
||||
"Gnuplot specific header args.")
|
||||
|
||||
(defvar org-babel-gnuplot-timestamp-fmt nil) ; Dynamically scoped.
|
||||
|
||||
(defvar *org-babel-gnuplot-missing* nil)
|
||||
|
||||
(defcustom *org-babel-gnuplot-terms*
|
||||
'((eps . "postscript eps"))
|
||||
"List of file extensions and the associated gnuplot terminal."
|
||||
:group 'org-babel
|
||||
:type '(repeat (cons (symbol :tag "File extension")
|
||||
(string :tag "Gnuplot terminal"))))
|
||||
|
||||
(defun org-babel-gnuplot-process-vars (params)
|
||||
"Extract variables from PARAMS and process the variables.
|
||||
Dumps all vectors into files and returns an association list
|
||||
of variable names and the related value to be used in the gnuplot
|
||||
code."
|
||||
(let ((*org-babel-gnuplot-missing* (cdr (assoc :missing params))))
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(cons
|
||||
(car pair) ;; variable name
|
||||
(let* ((val (cdr pair)) ;; variable value
|
||||
(lp (listp val)))
|
||||
(if lp
|
||||
(org-babel-gnuplot-table-to-data
|
||||
(let* ((first (car val))
|
||||
(tablep (or (listp first) (symbolp first))))
|
||||
(if tablep val (mapcar 'list val)))
|
||||
(org-babel-temp-file "gnuplot-") params)
|
||||
val))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var)))))
|
||||
|
||||
(defun org-babel-expand-body:gnuplot (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(save-window-excursion
|
||||
(let* ((vars (org-babel-gnuplot-process-vars params))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(prologue (cdr (assoc :prologue params)))
|
||||
(epilogue (cdr (assoc :epilogue params)))
|
||||
(term (or (cdr (assoc :term params))
|
||||
(when out-file
|
||||
(let ((ext (file-name-extension out-file)))
|
||||
(or (cdr (assoc (intern (downcase ext))
|
||||
*org-babel-gnuplot-terms*))
|
||||
ext)))))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(title (cdr (assoc :title params)))
|
||||
(lines (cdr (assoc :line params)))
|
||||
(sets (cdr (assoc :set params)))
|
||||
(x-labels (cdr (assoc :xlabels params)))
|
||||
(y-labels (cdr (assoc :ylabels params)))
|
||||
(timefmt (cdr (assoc :timefmt params)))
|
||||
(time-ind (or (cdr (assoc :timeind params))
|
||||
(when timefmt 1)))
|
||||
(add-to-body (lambda (text) (setq body (concat text "\n" body))))
|
||||
output)
|
||||
;; append header argument settings to body
|
||||
(when title (funcall add-to-body (format "set title '%s'" title)))
|
||||
(when lines (mapc (lambda (el) (funcall add-to-body el)) lines))
|
||||
(when sets
|
||||
(mapc (lambda (el) (funcall add-to-body (format "set %s" el))) sets))
|
||||
(when x-labels
|
||||
(funcall add-to-body
|
||||
(format "set xtics (%s)"
|
||||
(mapconcat (lambda (pair)
|
||||
(format "\"%s\" %d"
|
||||
(cdr pair) (car pair)))
|
||||
x-labels ", "))))
|
||||
(when y-labels
|
||||
(funcall add-to-body
|
||||
(format "set ytics (%s)"
|
||||
(mapconcat (lambda (pair)
|
||||
(format "\"%s\" %d"
|
||||
(cdr pair) (car pair)))
|
||||
y-labels ", "))))
|
||||
(when time-ind
|
||||
(funcall add-to-body "set xdata time")
|
||||
(funcall add-to-body (concat "set timefmt \""
|
||||
(or timefmt
|
||||
"%Y-%m-%d-%H:%M:%S") "\"")))
|
||||
(when out-file
|
||||
;; set the terminal at the top of the block
|
||||
(funcall add-to-body (format "set output \"%s\"" out-file))
|
||||
;; and close the terminal at the bottom of the block
|
||||
(setq body (concat body "\nset output\n")))
|
||||
(when term (funcall add-to-body (format "set term %s" term)))
|
||||
;; insert variables into code body: this should happen last
|
||||
;; placing the variables at the *top* of the code in case their
|
||||
;; values are used later
|
||||
(funcall add-to-body
|
||||
(mapconcat #'identity
|
||||
(org-babel-variable-assignments:gnuplot params)
|
||||
"\n"))
|
||||
;; replace any variable names preceded by '$' with the actual
|
||||
;; value of the variable
|
||||
(mapc (lambda (pair)
|
||||
(setq body (replace-regexp-in-string
|
||||
(format "\\$%s" (car pair)) (cdr pair) body)))
|
||||
vars)
|
||||
(when prologue (funcall add-to-body prologue))
|
||||
(when epilogue (setq body (concat body "\n" epilogue))))
|
||||
body))
|
||||
|
||||
(defun org-babel-execute:gnuplot (body params)
|
||||
"Execute a block of Gnuplot code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(require 'gnuplot)
|
||||
(let ((session (cdr (assoc :session params)))
|
||||
(result-type (cdr (assoc :results params)))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(body (org-babel-expand-body:gnuplot body params))
|
||||
output)
|
||||
(save-window-excursion
|
||||
;; evaluate the code body with gnuplot
|
||||
(if (string= session "none")
|
||||
(let ((script-file (org-babel-temp-file "gnuplot-script-")))
|
||||
(with-temp-file script-file
|
||||
(insert (concat body "\n")))
|
||||
(message "gnuplot \"%s\"" script-file)
|
||||
(setq output
|
||||
(shell-command-to-string
|
||||
(format
|
||||
"gnuplot \"%s\""
|
||||
(org-babel-process-file-name
|
||||
script-file
|
||||
(if (member system-type '(cygwin windows-nt ms-dos))
|
||||
t nil)))))
|
||||
(message output))
|
||||
(with-temp-buffer
|
||||
(insert (concat body "\n"))
|
||||
(gnuplot-mode)
|
||||
(gnuplot-send-buffer-to-gnuplot)))
|
||||
(if (member "output" (split-string result-type))
|
||||
output
|
||||
nil)))) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:gnuplot (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS."
|
||||
(let* ((session (org-babel-gnuplot-initiate-session session))
|
||||
(var-lines (org-babel-variable-assignments:gnuplot params)))
|
||||
(message "%S" session)
|
||||
(org-babel-comint-in-buffer session
|
||||
(mapc (lambda (var-line)
|
||||
(insert var-line) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)
|
||||
(sit-for .1) (goto-char (point-max))) var-lines))
|
||||
session))
|
||||
|
||||
(defun org-babel-load-session:gnuplot (session body params)
|
||||
"Load BODY into SESSION."
|
||||
(save-window-excursion
|
||||
(let ((buffer (org-babel-prep-session:gnuplot session params)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert (org-babel-chomp body)))
|
||||
buffer)))
|
||||
|
||||
(defun org-babel-variable-assignments:gnuplot (params)
|
||||
"Return list of gnuplot statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair)))
|
||||
(org-babel-gnuplot-process-vars params)))
|
||||
|
||||
(defvar gnuplot-buffer)
|
||||
(defun org-babel-gnuplot-initiate-session (&optional session params)
|
||||
"Initiate a gnuplot session.
|
||||
If there is not a current inferior-process-buffer in SESSION
|
||||
then create one. Return the initialized session. The current
|
||||
`gnuplot-mode' doesn't provide support for multiple sessions."
|
||||
(require 'gnuplot)
|
||||
(unless (string= session "none")
|
||||
(save-window-excursion
|
||||
(gnuplot-send-string-to-gnuplot "" "line")
|
||||
gnuplot-buffer)))
|
||||
|
||||
(defun org-babel-gnuplot-quote-timestamp-field (s)
|
||||
"Convert S from timestamp to Unix time and export to gnuplot."
|
||||
(format-time-string org-babel-gnuplot-timestamp-fmt
|
||||
(org-time-string-to-time s)))
|
||||
|
||||
(defvar org-table-number-regexp)
|
||||
(defvar org-ts-regexp3)
|
||||
(defun org-babel-gnuplot-quote-tsv-field (s)
|
||||
"Quote S for export to gnuplot."
|
||||
(unless (stringp s)
|
||||
(setq s (format "%s" s)))
|
||||
(if (string-match org-table-number-regexp s) s
|
||||
(if (string-match org-ts-regexp3 s)
|
||||
(org-babel-gnuplot-quote-timestamp-field s)
|
||||
(if (zerop (length s))
|
||||
(or *org-babel-gnuplot-missing* s)
|
||||
(if (string-match "[ \"]" s)
|
||||
(concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"")
|
||||
"\"")
|
||||
s)))))
|
||||
|
||||
(defun org-babel-gnuplot-table-to-data (table data-file params)
|
||||
"Export TABLE to DATA-FILE in a format readable by gnuplot.
|
||||
Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
|
||||
(with-temp-file data-file
|
||||
(insert (let ((org-babel-gnuplot-timestamp-fmt
|
||||
(or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S")))
|
||||
(orgtbl-to-generic
|
||||
table
|
||||
(org-combine-plists
|
||||
'(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field)
|
||||
params)))))
|
||||
data-file)
|
||||
|
||||
(provide 'ob-gnuplot)
|
||||
|
||||
|
||||
|
||||
;;; ob-gnuplot.el ends here
|
118
elpa/org-20160919/ob-groovy.el
Normal file
118
elpa/org-20160919/ob-groovy.el
Normal file
@ -0,0 +1,118 @@
|
||||
;;; ob-groovy.el --- org-babel functions for Groovy evaluation
|
||||
|
||||
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Miro Bezjak
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;; Currently only supports the external execution. No session support yet.
|
||||
|
||||
;;; Requirements:
|
||||
;; - Groovy language :: http://groovy.codehaus.org
|
||||
;; - Groovy major mode :: Can be installed from MELPA or
|
||||
;; https://github.com/russel/Emacs-Groovy-Mode
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts) ;; Autoloaded
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("groovy" . "groovy"))
|
||||
(defvar org-babel-default-header-args:groovy '())
|
||||
(defcustom org-babel-groovy-command "groovy"
|
||||
"Name of the command to use for executing Groovy code.
|
||||
May be either a command in the path, like groovy
|
||||
or an absolute path name, like /usr/local/bin/groovy
|
||||
parameters may be used, like groovy -v"
|
||||
:group 'org-babel
|
||||
:version "24.3"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:groovy (body params)
|
||||
"Execute a block of Groovy code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Groovy source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-groovy-initiate-session (nth 0 processed-params)))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params))
|
||||
(result (org-babel-groovy-evaluate
|
||||
session full-body result-type result-params)))
|
||||
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defvar org-babel-groovy-wrapper-method
|
||||
|
||||
"class Runner extends Script {
|
||||
def out = new PrintWriter(new ByteArrayOutputStream())
|
||||
def run() { %s }
|
||||
}
|
||||
|
||||
println(new Runner().run())
|
||||
")
|
||||
|
||||
|
||||
(defun org-babel-groovy-evaluate
|
||||
(session body &optional result-type result-params)
|
||||
"Evaluate BODY in external Groovy process.
|
||||
If RESULT-TYPE equals `output' then return standard output as a string.
|
||||
If RESULT-TYPE equals `value' then return the value of the last statement
|
||||
in BODY as elisp."
|
||||
(when session (error "Sessions are not (yet) supported for Groovy"))
|
||||
(case result-type
|
||||
(output
|
||||
(let ((src-file (org-babel-temp-file "groovy-")))
|
||||
(progn (with-temp-file src-file (insert body))
|
||||
(org-babel-eval
|
||||
(concat org-babel-groovy-command " " src-file) ""))))
|
||||
(value
|
||||
(let* ((src-file (org-babel-temp-file "groovy-"))
|
||||
(wrapper (format org-babel-groovy-wrapper-method body)))
|
||||
(with-temp-file src-file (insert wrapper))
|
||||
(let ((raw (org-babel-eval
|
||||
(concat org-babel-groovy-command " " src-file) "")))
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-script-escape raw)))))))
|
||||
|
||||
|
||||
(defun org-babel-prep-session:groovy (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "Sessions are not (yet) supported for Groovy"))
|
||||
|
||||
(defun org-babel-groovy-initiate-session (&optional session)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session. Sessions are not
|
||||
supported in Groovy."
|
||||
nil)
|
||||
|
||||
(provide 'ob-groovy)
|
||||
|
||||
|
||||
|
||||
;;; ob-groovy.el ends here
|
220
elpa/org-20160919/ob-haskell.el
Normal file
220
elpa/org-20160919/ob-haskell.el
Normal file
@ -0,0 +1,220 @@
|
||||
;;; ob-haskell.el --- org-babel functions for haskell evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating haskell source code. This one will
|
||||
;; be sort of tricky because haskell programs must be compiled before
|
||||
;; they can be run, but haskell code can also be run through an
|
||||
;; interactive interpreter.
|
||||
;;
|
||||
;; For now lets only allow evaluation using the haskell interpreter.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - haskell-mode :: http://www.iro.umontreal.ca/~monnier/elisp/#haskell-mode
|
||||
;;
|
||||
;; - inf-haskell :: http://www.iro.umontreal.ca/~monnier/elisp/#haskell-mode
|
||||
;;
|
||||
;; - (optionally) lhs2tex :: http://people.cs.uu.nl/andres/lhs2tex/
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-remove-indentation "org" (code &optional n))
|
||||
(declare-function haskell-mode "ext:haskell-mode" ())
|
||||
(declare-function run-haskell "ext:inf-haskell" (&optional arg))
|
||||
(declare-function inferior-haskell-load-file
|
||||
"ext:inf-haskell" (&optional reload))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("haskell" . "hs"))
|
||||
|
||||
(defvar org-babel-default-header-args:haskell
|
||||
'((:padlines . "no")))
|
||||
|
||||
(defvar org-babel-haskell-lhs2tex-command "lhs2tex")
|
||||
|
||||
(defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"")
|
||||
|
||||
(defun org-babel-execute:haskell (body params)
|
||||
"Execute a block of Haskell code."
|
||||
(let* ((session (cdr (assoc :session params)))
|
||||
(vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params
|
||||
(org-babel-variable-assignments:haskell params)))
|
||||
(session (org-babel-haskell-initiate-session session params))
|
||||
(raw (org-babel-comint-with-output
|
||||
(session org-babel-haskell-eoe t full-body)
|
||||
(insert (org-babel-trim full-body))
|
||||
(comint-send-input nil t)
|
||||
(insert org-babel-haskell-eoe)
|
||||
(comint-send-input nil t)))
|
||||
(results (mapcar
|
||||
#'org-babel-haskell-read-string
|
||||
(cdr (member org-babel-haskell-eoe
|
||||
(reverse (mapcar #'org-babel-trim raw)))))))
|
||||
(org-babel-reassemble-table
|
||||
(let ((result
|
||||
(case result-type
|
||||
(output (mapconcat #'identity (reverse (cdr results)) "\n"))
|
||||
(value (car results)))))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
result (org-babel-script-escape result)))
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colname-names params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rowname-names params))))))
|
||||
|
||||
(defun org-babel-haskell-read-string (string)
|
||||
"Strip \\\"s from around a haskell string."
|
||||
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(defun org-babel-haskell-initiate-session (&optional session params)
|
||||
"Initiate a haskell session.
|
||||
If there is not a current inferior-process-buffer in SESSION
|
||||
then create one. Return the initialized session."
|
||||
(require 'inf-haskell)
|
||||
(or (get-buffer "*haskell*")
|
||||
(save-window-excursion (run-haskell) (sleep-for 0.25) (current-buffer))))
|
||||
|
||||
(defun org-babel-load-session:haskell (session body params)
|
||||
"Load BODY into SESSION."
|
||||
(save-window-excursion
|
||||
(let* ((buffer (org-babel-prep-session:haskell session params))
|
||||
(load-file (concat (org-babel-temp-file "haskell-load-") ".hs")))
|
||||
(with-temp-buffer
|
||||
(insert body) (write-file load-file)
|
||||
(haskell-mode) (inferior-haskell-load-file))
|
||||
buffer)))
|
||||
|
||||
(defun org-babel-prep-session:haskell (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS."
|
||||
(save-window-excursion
|
||||
(let ((buffer (org-babel-haskell-initiate-session session)))
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(mapc (lambda (line)
|
||||
(insert line)
|
||||
(comint-send-input nil t))
|
||||
(org-babel-variable-assignments:haskell params)))
|
||||
(current-buffer))))
|
||||
|
||||
(defun org-babel-variable-assignments:haskell (params)
|
||||
"Return list of haskell statements assigning the block's variables."
|
||||
(mapcar (lambda (pair)
|
||||
(format "let %s = %s"
|
||||
(car pair)
|
||||
(org-babel-haskell-var-to-haskell (cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-haskell-var-to-haskell (var)
|
||||
"Convert an elisp value VAR into a haskell variable.
|
||||
The elisp VAR is converted to a string of haskell source code
|
||||
specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-haskell-var-to-haskell var ", ") "]")
|
||||
(format "%S" var)))
|
||||
|
||||
(defvar org-export-copy-to-kill-ring)
|
||||
(declare-function org-export-to-file "ox"
|
||||
(backend file
|
||||
&optional async subtreep visible-only body-only
|
||||
ext-plist post-process))
|
||||
(defun org-babel-haskell-export-to-lhs (&optional arg)
|
||||
"Export to a .lhs file with all haskell code blocks escaped.
|
||||
When called with a prefix argument the resulting
|
||||
.lhs file will be exported to a .tex file. This function will
|
||||
create two new files, base-name.lhs and base-name.tex where
|
||||
base-name is the name of the current org-mode file.
|
||||
|
||||
Note that all standard Babel literate programming
|
||||
constructs (header arguments, no-web syntax etc...) are ignored."
|
||||
(interactive "P")
|
||||
(let* ((contents (buffer-string))
|
||||
(haskell-regexp
|
||||
(concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]"
|
||||
"\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*"))
|
||||
(base-name (file-name-sans-extension (buffer-file-name)))
|
||||
(tmp-file (org-babel-temp-file "haskell-"))
|
||||
(tmp-org-file (concat tmp-file ".org"))
|
||||
(tmp-tex-file (concat tmp-file ".tex"))
|
||||
(lhs-file (concat base-name ".lhs"))
|
||||
(tex-file (concat base-name ".tex"))
|
||||
(command (concat org-babel-haskell-lhs2tex-command
|
||||
" " (org-babel-process-file-name lhs-file)
|
||||
" > " (org-babel-process-file-name tex-file)))
|
||||
(preserve-indentp org-src-preserve-indentation)
|
||||
indentation)
|
||||
;; escape haskell source-code blocks
|
||||
(with-temp-file tmp-org-file
|
||||
(insert contents)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward haskell-regexp nil t)
|
||||
(save-match-data (setq indentation (length (match-string 1))))
|
||||
(replace-match (save-match-data
|
||||
(concat
|
||||
"#+begin_latex\n\\begin{code}\n"
|
||||
(if (or preserve-indentp
|
||||
(string-match "-i" (match-string 2)))
|
||||
(match-string 3)
|
||||
(org-remove-indentation (match-string 3)))
|
||||
"\n\\end{code}\n#+end_latex\n"))
|
||||
t t)
|
||||
(indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))
|
||||
(save-excursion
|
||||
;; export to latex w/org and save as .lhs
|
||||
(require 'ox-latex)
|
||||
(find-file tmp-org-file)
|
||||
;; Ensure we do not clutter kill ring with incomplete results.
|
||||
(let (org-export-copy-to-kill-ring)
|
||||
(org-export-to-file 'latex tmp-tex-file))
|
||||
(kill-buffer nil)
|
||||
(delete-file tmp-org-file)
|
||||
(find-file tmp-tex-file)
|
||||
(goto-char (point-min)) (forward-line 2)
|
||||
(insert "%include polycode.fmt\n")
|
||||
;; ensure all \begin/end{code} statements start at the first column
|
||||
(while (re-search-forward "^[ \t]+\\\\begin{code}[^\000]+\\\\end{code}" nil t)
|
||||
(replace-match (save-match-data (org-remove-indentation (match-string 0)))
|
||||
t t))
|
||||
(setq contents (buffer-string))
|
||||
(save-buffer) (kill-buffer nil))
|
||||
(delete-file tmp-tex-file)
|
||||
;; save org exported latex to a .lhs file
|
||||
(with-temp-file lhs-file (insert contents))
|
||||
(if (not arg)
|
||||
(find-file lhs-file)
|
||||
;; process .lhs file with lhs2tex
|
||||
(message "running %s" command) (shell-command command) (find-file tex-file))))
|
||||
|
||||
(provide 'ob-haskell)
|
||||
|
||||
|
||||
|
||||
;;; ob-haskell.el ends here
|
110
elpa/org-20160919/ob-io.el
Normal file
110
elpa/org-20160919/ob-io.el
Normal file
@ -0,0 +1,110 @@
|
||||
;;; ob-io.el --- org-babel functions for Io evaluation
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Andrzej Lichnerowicz
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;; Currently only supports the external execution. No session support yet.
|
||||
;; :results output -- runs in scripting mode
|
||||
;; :results output repl -- runs in repl mode
|
||||
|
||||
;;; Requirements:
|
||||
;; - Io language :: http://iolanguage.org/
|
||||
;; - Io major mode :: Can be installed from Io sources
|
||||
;; https://github.com/stevedekorte/io/blob/master/extras/SyntaxHighlighters/Emacs/io-mode.el
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts) ;; Autoloaded
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("io" . "io"))
|
||||
(defvar org-babel-default-header-args:io '())
|
||||
(defvar org-babel-io-command "io"
|
||||
"Name of the command to use for executing Io code.")
|
||||
|
||||
(defun org-babel-execute:io (body params)
|
||||
"Execute a block of Io code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Io source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-io-initiate-session (nth 0 processed-params)))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params))
|
||||
(result (org-babel-io-evaluate
|
||||
session full-body result-type result-params)))
|
||||
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defvar org-babel-io-wrapper-method
|
||||
"(
|
||||
%s
|
||||
) asString print
|
||||
")
|
||||
|
||||
|
||||
(defun org-babel-io-evaluate (session body &optional result-type result-params)
|
||||
"Evaluate BODY in external Io process.
|
||||
If RESULT-TYPE equals `output' then return standard output as a string.
|
||||
If RESULT-TYPE equals `value' then return the value of the last statement
|
||||
in BODY as elisp."
|
||||
(when session (error "Sessions are not (yet) supported for Io"))
|
||||
(case result-type
|
||||
(output
|
||||
(if (member "repl" result-params)
|
||||
(org-babel-eval org-babel-io-command body)
|
||||
(let ((src-file (org-babel-temp-file "io-")))
|
||||
(progn (with-temp-file src-file (insert body))
|
||||
(org-babel-eval
|
||||
(concat org-babel-io-command " " src-file) "")))))
|
||||
(value (let* ((src-file (org-babel-temp-file "io-"))
|
||||
(wrapper (format org-babel-io-wrapper-method body)))
|
||||
(with-temp-file src-file (insert wrapper))
|
||||
(let ((raw (org-babel-eval
|
||||
(concat org-babel-io-command " " src-file) "")))
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-script-escape raw)))))))
|
||||
|
||||
|
||||
(defun org-babel-prep-session:io (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "Sessions are not (yet) supported for Io"))
|
||||
|
||||
(defun org-babel-io-initiate-session (&optional session)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session. Sessions are not
|
||||
supported in Io."
|
||||
nil)
|
||||
|
||||
(provide 'ob-io)
|
||||
|
||||
|
||||
|
||||
;;; ob-io.el ends here
|
87
elpa/org-20160919/ob-java.el
Normal file
87
elpa/org-20160919/ob-java.el
Normal file
@ -0,0 +1,87 @@
|
||||
;;; ob-java.el --- org-babel functions for java evaluation
|
||||
|
||||
;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Currently this only supports the external compilation and execution
|
||||
;; of java code blocks (i.e., no session support).
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("java" . "java"))
|
||||
|
||||
(defcustom org-babel-java-command "java"
|
||||
"Name of the java command.
|
||||
May be either a command in the path, like java
|
||||
or an absolute path name, like /usr/local/bin/java
|
||||
parameters may be used, like java -verbose"
|
||||
:group 'org-babel
|
||||
:version "24.3"
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-java-compiler "javac"
|
||||
"Name of the java compiler.
|
||||
May be either a command in the path, like javac
|
||||
or an absolute path name, like /usr/local/bin/javac
|
||||
parameters may be used, like javac -verbose"
|
||||
:group 'org-babel
|
||||
:version "24.3"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:java (body params)
|
||||
(let* ((classname (or (cdr (assoc :classname params))
|
||||
(error
|
||||
"Can't compile a java block without a classname")))
|
||||
(packagename (file-name-directory classname))
|
||||
(src-file (concat classname ".java"))
|
||||
(cmpflag (or (cdr (assoc :cmpflag params)) ""))
|
||||
(cmdline (or (cdr (assoc :cmdline params)) ""))
|
||||
(full-body (org-babel-expand-body:generic body params))
|
||||
(compile
|
||||
(progn (with-temp-file src-file (insert full-body))
|
||||
(org-babel-eval
|
||||
(concat org-babel-java-compiler
|
||||
" " cmpflag " " src-file) ""))))
|
||||
;; created package-name directories if missing
|
||||
(unless (or (not packagename) (file-exists-p packagename))
|
||||
(make-directory packagename 'parents))
|
||||
(let ((results (org-babel-eval (concat org-babel-java-command
|
||||
" " cmdline " " classname) "")))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
(org-babel-read results)
|
||||
(let ((tmp-file (org-babel-temp-file "c-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
|
||||
|
||||
(provide 'ob-java)
|
||||
|
||||
|
||||
|
||||
;;; ob-java.el ends here
|
163
elpa/org-20160919/ob-js.el
Normal file
163
elpa/org-20160919/ob-js.el
Normal file
@ -0,0 +1,163 @@
|
||||
;;; ob-js.el --- org-babel functions for Javascript
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, js
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Now working with SBCL for both session and external evaluation.
|
||||
;;
|
||||
;; This certainly isn't optimally robust, but it seems to be working
|
||||
;; for the basic use cases.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - a non-browser javascript engine such as node.js http://nodejs.org/
|
||||
;; or mozrepl http://wiki.github.com/bard/mozrepl/
|
||||
;;
|
||||
;; - for session based evaluation mozrepl and moz.el are required see
|
||||
;; http://wiki.github.com/bard/mozrepl/emacs-integration for
|
||||
;; configuration instructions
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function run-mozilla "ext:moz" (arg))
|
||||
|
||||
(defvar org-babel-default-header-args:js '()
|
||||
"Default header arguments for js code blocks.")
|
||||
|
||||
(defvar org-babel-js-eoe "org-babel-js-eoe"
|
||||
"String to indicate that evaluation has completed.")
|
||||
|
||||
(defcustom org-babel-js-cmd "node"
|
||||
"Name of command used to evaluate js blocks."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defvar org-babel-js-function-wrapper
|
||||
"require('sys').print(require('sys').inspect(function(){%s}()));"
|
||||
"Javascript code to print value of body.")
|
||||
|
||||
(defun org-babel-execute:js (body params)
|
||||
"Execute a block of Javascript code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'"
|
||||
(let* ((org-babel-js-cmd (or (cdr (assoc :cmd params)) org-babel-js-cmd))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:js params)))
|
||||
(result (if (not (string= (cdr (assoc :session params)) "none"))
|
||||
;; session evaluation
|
||||
(let ((session (org-babel-prep-session:js
|
||||
(cdr (assoc :session params)) params)))
|
||||
(nth 1
|
||||
(org-babel-comint-with-output
|
||||
(session (format "%S" org-babel-js-eoe) t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line))
|
||||
(comint-send-input nil t))
|
||||
(list body (format "%S" org-babel-js-eoe))))))
|
||||
;; external evaluation
|
||||
(let ((script-file (org-babel-temp-file "js-script-")))
|
||||
(with-temp-file script-file
|
||||
(insert
|
||||
;; return the value or the output
|
||||
(if (string= result-type "value")
|
||||
(format org-babel-js-function-wrapper full-body)
|
||||
full-body)))
|
||||
(org-babel-eval
|
||||
(format "%s %s" org-babel-js-cmd
|
||||
(org-babel-process-file-name script-file)) "")))))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
result (org-babel-js-read result))))
|
||||
|
||||
(defun org-babel-js-read (results)
|
||||
"Convert RESULTS into an appropriate elisp value.
|
||||
If RESULTS look like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(org-babel-read
|
||||
(if (and (stringp results) (string-match "^\\[[^\000]+\\]$" results))
|
||||
(org-babel-read
|
||||
(concat "'"
|
||||
(replace-regexp-in-string
|
||||
"\\[" "(" (replace-regexp-in-string
|
||||
"\\]" ")" (replace-regexp-in-string
|
||||
",[[:space:]]" " "
|
||||
(replace-regexp-in-string
|
||||
"'" "\"" results))))))
|
||||
results)))
|
||||
|
||||
(defun org-babel-js-var-to-js (var)
|
||||
"Convert VAR into a js variable.
|
||||
Convert an elisp value into a string of js source code
|
||||
specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-js-var-to-js var ", ") "]")
|
||||
(replace-regexp-in-string "\n" "\\\\n" (format "%S" var))))
|
||||
|
||||
(defun org-babel-prep-session:js (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-js-initiate-session session))
|
||||
(var-lines (org-babel-variable-assignments:js params)))
|
||||
(when session
|
||||
(org-babel-comint-in-buffer session
|
||||
(sit-for .5) (goto-char (point-max))
|
||||
(mapc (lambda (var)
|
||||
(insert var) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)
|
||||
(sit-for .1) (goto-char (point-max))) var-lines)))
|
||||
session))
|
||||
|
||||
(defun org-babel-variable-assignments:js (params)
|
||||
"Return list of Javascript statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair) (format "var %s=%s;"
|
||||
(car pair) (org-babel-js-var-to-js (cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-js-initiate-session (&optional session)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
(unless (string= session "none")
|
||||
(cond
|
||||
((string= "mozrepl" org-babel-js-cmd)
|
||||
(require 'moz)
|
||||
(let ((session-buffer (save-window-excursion
|
||||
(run-mozilla nil)
|
||||
(rename-buffer session)
|
||||
(current-buffer))))
|
||||
(if (org-babel-comint-buffer-livep session-buffer)
|
||||
(progn (sit-for .25) session-buffer)
|
||||
(sit-for .5)
|
||||
(org-babel-js-initiate-session session))))
|
||||
((string= "node" org-babel-js-cmd )
|
||||
(error "Session evaluation with node.js is not supported"))
|
||||
(t
|
||||
(error "Sessions are only supported with mozrepl add \":cmd mozrepl\"")))))
|
||||
|
||||
(provide 'ob-js)
|
||||
|
||||
|
||||
|
||||
;;; ob-js.el ends here
|
106
elpa/org-20160919/ob-keys.el
Normal file
106
elpa/org-20160919/ob-keys.el
Normal file
@ -0,0 +1,106 @@
|
||||
;;; ob-keys.el --- key bindings for org-babel
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Add org-babel keybindings to the org-mode keymap for exposing
|
||||
;; org-babel functions. These will all share a common prefix. See
|
||||
;; the value of `org-babel-key-bindings' for a list of interactive
|
||||
;; functions and their associated keys.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob-core)
|
||||
|
||||
(defvar org-babel-key-prefix "\C-c\C-v"
|
||||
"The key prefix for Babel interactive key-bindings.
|
||||
See `org-babel-key-bindings' for the list of interactive babel
|
||||
functions which are assigned key bindings, and see
|
||||
`org-babel-map' for the actual babel keymap.")
|
||||
|
||||
(defvar org-babel-map (make-sparse-keymap)
|
||||
"The keymap for interactive Babel functions.")
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-describe-bindings ()
|
||||
"Describe all keybindings behind `org-babel-key-prefix'."
|
||||
(interactive)
|
||||
(describe-bindings org-babel-key-prefix))
|
||||
|
||||
(defvar org-babel-key-bindings
|
||||
'(("p" . org-babel-previous-src-block)
|
||||
("\C-p" . org-babel-previous-src-block)
|
||||
("n" . org-babel-next-src-block)
|
||||
("\C-n" . org-babel-next-src-block)
|
||||
("e" . org-babel-execute-maybe)
|
||||
("\C-e" . org-babel-execute-maybe)
|
||||
("o" . org-babel-open-src-block-result)
|
||||
("\C-o" . org-babel-open-src-block-result)
|
||||
("\C-v" . org-babel-expand-src-block)
|
||||
("v" . org-babel-expand-src-block)
|
||||
("u" . org-babel-goto-src-block-head)
|
||||
("\C-u" . org-babel-goto-src-block-head)
|
||||
("g" . org-babel-goto-named-src-block)
|
||||
("r" . org-babel-goto-named-result)
|
||||
("\C-r" . org-babel-goto-named-result)
|
||||
("\C-b" . org-babel-execute-buffer)
|
||||
("b" . org-babel-execute-buffer)
|
||||
("\C-s" . org-babel-execute-subtree)
|
||||
("s" . org-babel-execute-subtree)
|
||||
("\C-d" . org-babel-demarcate-block)
|
||||
("d" . org-babel-demarcate-block)
|
||||
("\C-t" . org-babel-tangle)
|
||||
("t" . org-babel-tangle)
|
||||
("\C-f" . org-babel-tangle-file)
|
||||
("f" . org-babel-tangle-file)
|
||||
("\C-c" . org-babel-check-src-block)
|
||||
("c" . org-babel-check-src-block)
|
||||
("\C-j" . org-babel-insert-header-arg)
|
||||
("j" . org-babel-insert-header-arg)
|
||||
("\C-l" . org-babel-load-in-session)
|
||||
("l" . org-babel-load-in-session)
|
||||
("\C-i" . org-babel-lob-ingest)
|
||||
("i" . org-babel-lob-ingest)
|
||||
("\C-I" . org-babel-view-src-block-info)
|
||||
("I" . org-babel-view-src-block-info)
|
||||
("\C-z" . org-babel-switch-to-session)
|
||||
("z" . org-babel-switch-to-session-with-code)
|
||||
("\C-a" . org-babel-sha1-hash)
|
||||
("a" . org-babel-sha1-hash)
|
||||
("h" . org-babel-describe-bindings)
|
||||
("\C-x" . org-babel-do-key-sequence-in-edit-buffer)
|
||||
("x" . org-babel-do-key-sequence-in-edit-buffer)
|
||||
("k" . org-babel-remove-result-one-or-many)
|
||||
("\C-\M-h" . org-babel-mark-block))
|
||||
"Alist of key bindings and interactive Babel functions.
|
||||
This list associates interactive Babel functions
|
||||
with keys. Each element of this list will add an entry to the
|
||||
`org-babel-map' using the letter key which is the `car' of the
|
||||
a-list placed behind the generic `org-babel-key-prefix'.")
|
||||
|
||||
(provide 'ob-keys)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ob-keys.el ends here
|
223
elpa/org-20160919/ob-latex.el
Normal file
223
elpa/org-20160919/ob-latex.el
Normal file
@ -0,0 +1,223 @@
|
||||
;;; ob-latex.el --- org-babel functions for latex "evaluation"
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating LaTeX source code.
|
||||
;;
|
||||
;; Currently on evaluation this returns raw LaTeX code, unless a :file
|
||||
;; header argument is given in which case small png or pdf files will
|
||||
;; be created directly form the latex source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function org-create-formula-image "org"
|
||||
(string tofile options buffer &optional type))
|
||||
(declare-function org-splice-latex-header "org"
|
||||
(tpl def-pkg pkg snippets-p &optional extra))
|
||||
(declare-function org-latex-guess-inputenc "ox-latex" (header))
|
||||
(declare-function org-latex-compile "ox-latex" (texfile &optional snippet))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
|
||||
|
||||
(defvar org-format-latex-header) ; From org.el
|
||||
(defvar org-format-latex-options) ; From org.el
|
||||
(defvar org-latex-default-packages-alist) ; From org.el
|
||||
(defvar org-latex-packages-alist) ; From org.el
|
||||
|
||||
(defvar org-babel-default-header-args:latex
|
||||
'((:results . "latex") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a LaTeX source block.")
|
||||
|
||||
(defconst org-babel-header-args:latex
|
||||
'((border . :any)
|
||||
(fit . :any)
|
||||
(iminoptions . :any)
|
||||
(imoutoptions . :any)
|
||||
(packages . :any)
|
||||
(pdfheight . :any)
|
||||
(pdfpng . :any)
|
||||
(pdfwidth . :any))
|
||||
"LaTeX-specific header arguments.")
|
||||
|
||||
(defcustom org-babel-latex-htlatex "htlatex"
|
||||
"The htlatex command to enable conversion of latex to SVG or HTML."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-latex-htlatex-packages
|
||||
'("[usenames]{color}" "{tikz}" "{color}" "{listings}" "{amsmath}")
|
||||
"Packages to use for htlatex export."
|
||||
:group 'org-babel
|
||||
:type '(repeat (string)))
|
||||
|
||||
(defun org-babel-expand-body:latex (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(mapc (lambda (pair) ;; replace variables
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(regexp-quote (format "%S" (car pair)))
|
||||
(if (stringp (cdr pair))
|
||||
(cdr pair) (format "%S" (cdr pair)))
|
||||
body))) (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(org-babel-trim body))
|
||||
|
||||
(defun org-babel-execute:latex (body params)
|
||||
"Execute a block of Latex code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(setq body (org-babel-expand-body:latex body params))
|
||||
(if (cdr (assoc :file params))
|
||||
(let* ((out-file (cdr (assoc :file params)))
|
||||
(tex-file (org-babel-temp-file "latex-" ".tex"))
|
||||
(border (cdr (assoc :border params)))
|
||||
(imagemagick (cdr (assoc :imagemagick params)))
|
||||
(im-in-options (cdr (assoc :iminoptions params)))
|
||||
(im-out-options (cdr (assoc :imoutoptions params)))
|
||||
(pdfpng (cdr (assoc :pdfpng params)))
|
||||
(fit (or (cdr (assoc :fit params)) border))
|
||||
(height (and fit (cdr (assoc :pdfheight params))))
|
||||
(width (and fit (cdr (assoc :pdfwidth params))))
|
||||
(headers (cdr (assoc :headers params)))
|
||||
(in-buffer (not (string= "no" (cdr (assoc :buffer params)))))
|
||||
(org-latex-packages-alist
|
||||
(append (cdr (assoc :packages params)) org-latex-packages-alist)))
|
||||
(cond
|
||||
((and (string-match "\\.png$" out-file) (not imagemagick))
|
||||
(org-create-formula-image
|
||||
body out-file org-format-latex-options in-buffer))
|
||||
((string-match "\\.tikz$" out-file)
|
||||
(when (file-exists-p out-file) (delete-file out-file))
|
||||
(with-temp-file out-file
|
||||
(insert body)))
|
||||
((and (or (string-match "\\.svg$" out-file)
|
||||
(string-match "\\.html$" out-file))
|
||||
(executable-find org-babel-latex-htlatex))
|
||||
;; TODO: this is a very different way of generating the
|
||||
;; frame latex document than in the pdf case. Ideally, both
|
||||
;; would be unified. This would prevent bugs creeping in
|
||||
;; such as the one fixed on Aug 16 2014 whereby :headers was
|
||||
;; not included in the SVG/HTML case.
|
||||
(with-temp-file tex-file
|
||||
(insert (concat
|
||||
"\\documentclass[preview]{standalone}
|
||||
\\def\\pgfsysdriver{pgfsys-tex4ht.def}
|
||||
"
|
||||
(mapconcat (lambda (pkg)
|
||||
(concat "\\usepackage" pkg))
|
||||
org-babel-latex-htlatex-packages
|
||||
"\n")
|
||||
(if headers
|
||||
(concat "\n"
|
||||
(if (listp headers)
|
||||
(mapconcat #'identity headers "\n")
|
||||
headers) "\n")
|
||||
"")
|
||||
"\\begin{document}"
|
||||
body
|
||||
"\\end{document}")))
|
||||
(when (file-exists-p out-file) (delete-file out-file))
|
||||
(let ((default-directory (file-name-directory tex-file)))
|
||||
(shell-command (format "%s %s" org-babel-latex-htlatex tex-file)))
|
||||
(cond
|
||||
((file-exists-p (concat (file-name-sans-extension tex-file) "-1.svg"))
|
||||
(if (string-match "\\.svg$" out-file)
|
||||
(progn
|
||||
(shell-command "pwd")
|
||||
(shell-command (format "mv %s %s"
|
||||
(concat (file-name-sans-extension tex-file) "-1.svg")
|
||||
out-file)))
|
||||
(error "SVG file produced but HTML file requested")))
|
||||
((file-exists-p (concat (file-name-sans-extension tex-file) ".html"))
|
||||
(if (string-match "\\.html$" out-file)
|
||||
(shell-command "mv %s %s"
|
||||
(concat (file-name-sans-extension tex-file)
|
||||
".html")
|
||||
out-file)
|
||||
(error "HTML file produced but SVG file requested")))))
|
||||
((or (string-match "\\.pdf$" out-file) imagemagick)
|
||||
(with-temp-file tex-file
|
||||
(require 'ox-latex)
|
||||
(insert
|
||||
(org-latex-guess-inputenc
|
||||
(org-splice-latex-header
|
||||
org-format-latex-header
|
||||
(delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (el)
|
||||
(unless (and (listp el) (string= "hyperref" (cadr el)))
|
||||
el))
|
||||
org-latex-default-packages-alist))
|
||||
org-latex-packages-alist
|
||||
nil))
|
||||
(if fit "\n\\usepackage[active, tightpage]{preview}\n" "")
|
||||
(if border (format "\\setlength{\\PreviewBorder}{%s}" border) "")
|
||||
(if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
|
||||
(if width (concat "\n" (format "\\pdfpagewidth %s" width)) "")
|
||||
(if headers
|
||||
(concat "\n"
|
||||
(if (listp headers)
|
||||
(mapconcat #'identity headers "\n")
|
||||
headers) "\n")
|
||||
"")
|
||||
(if fit
|
||||
(concat "\n\\begin{document}\n\\begin{preview}\n" body
|
||||
"\n\\end{preview}\n\\end{document}\n")
|
||||
(concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))
|
||||
(when (file-exists-p out-file) (delete-file out-file))
|
||||
(let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
|
||||
(cond
|
||||
((string-match "\\.pdf$" out-file)
|
||||
(rename-file transient-pdf-file out-file))
|
||||
(imagemagick
|
||||
(org-babel-latex-convert-pdf
|
||||
transient-pdf-file out-file im-in-options im-out-options)
|
||||
(when (file-exists-p transient-pdf-file)
|
||||
(delete-file transient-pdf-file))))))
|
||||
((string-match "\\.\\([^\\.]+\\)$" out-file)
|
||||
(error "Can not create %s files, please specify a .png or .pdf file or try the :imagemagick header argument"
|
||||
(match-string 1 out-file))))
|
||||
nil) ;; signal that output has already been written to file
|
||||
body))
|
||||
|
||||
(defun org-babel-latex-convert-pdf (pdffile out-file im-in-options im-out-options)
|
||||
"Generate a file from a pdf file using imagemagick."
|
||||
(let ((cmd (concat "convert " im-in-options " " pdffile " "
|
||||
im-out-options " " out-file)))
|
||||
(message "Converting pdffile file %s..." cmd)
|
||||
(shell-command cmd)))
|
||||
|
||||
(defun org-babel-latex-tex-to-pdf (file)
|
||||
"Generate a pdf file according to the contents FILE."
|
||||
(require 'ox-latex)
|
||||
(org-latex-compile file))
|
||||
|
||||
(defun org-babel-prep-session:latex (session params)
|
||||
"Return an error because LaTeX doesn't support sessions."
|
||||
(error "LaTeX does not support sessions"))
|
||||
|
||||
|
||||
(provide 'ob-latex)
|
||||
;;; ob-latex.el ends here
|
71
elpa/org-20160919/ob-ledger.el
Normal file
71
elpa/org-20160919/ob-ledger.el
Normal file
@ -0,0 +1,71 @@
|
||||
;;; ob-ledger.el --- org-babel functions for ledger evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric S Fraga
|
||||
;; Keywords: literate programming, reproducible research, accounting
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating ledger entries.
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in ledger
|
||||
;;
|
||||
;; 2) we are generally only going to return output from the ledger program
|
||||
;;
|
||||
;; 3) we are adding the "cmdline" header argument
|
||||
;;
|
||||
;; 4) there are no variables
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:ledger
|
||||
'((:results . "output") (:cmdline . "bal"))
|
||||
"Default arguments to use when evaluating a ledger source block.")
|
||||
|
||||
(defun org-babel-execute:ledger (body params)
|
||||
"Execute a block of Ledger entries with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
(message "executing Ledger source code block")
|
||||
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(in-file (org-babel-temp-file "ledger-"))
|
||||
(out-file (org-babel-temp-file "ledger-output-")))
|
||||
(with-temp-file in-file (insert body))
|
||||
(message "%s" (concat "ledger"
|
||||
" -f " (org-babel-process-file-name in-file)
|
||||
" " cmdline))
|
||||
(with-output-to-string
|
||||
(shell-command (concat "ledger"
|
||||
" -f " (org-babel-process-file-name in-file)
|
||||
" " cmdline
|
||||
" > " (org-babel-process-file-name out-file))))
|
||||
(with-temp-buffer (insert-file-contents out-file) (buffer-string))))
|
||||
|
||||
(defun org-babel-prep-session:ledger (session params)
|
||||
(error "Ledger does not support sessions"))
|
||||
|
||||
(provide 'ob-ledger)
|
||||
|
||||
|
||||
|
||||
;;; ob-ledger.el ends here
|
419
elpa/org-20160919/ob-lilypond.el
Normal file
419
elpa/org-20160919/ob-lilypond.el
Normal file
@ -0,0 +1,419 @@
|
||||
;;; ob-lilypond.el --- org-babel functions for lilypond evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Martyn Jago
|
||||
;; Keywords: babel language, literate programming
|
||||
;; Homepage: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Installation, ob-lilypond documentation, and examples are available at
|
||||
;; http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
|
||||
;;
|
||||
;; Lilypond documentation can be found at
|
||||
;; http://lilypond.org/manuals.html
|
||||
;;
|
||||
;; This depends on epstopdf --- See http://www.ctan.org/pkg/epstopdf.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'outline)
|
||||
(defalias 'lilypond-mode 'LilyPond-mode)
|
||||
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("LilyPond" . "ly"))
|
||||
|
||||
(defvar org-babel-default-header-args:lilypond '()
|
||||
"Default header arguments for lilypond code blocks.
|
||||
NOTE: The arguments are determined at lilypond compile time.
|
||||
See (org-babel-lilypond-set-header-args)")
|
||||
|
||||
(defvar org-babel-lilypond-compile-post-tangle t
|
||||
"Following the org-babel-tangle (C-c C-v t) command,
|
||||
org-babel-lilypond-compile-post-tangle determines whether ob-lilypond should
|
||||
automatically attempt to compile the resultant tangled file.
|
||||
If the value is nil, no automated compilation takes place.
|
||||
Default value is t")
|
||||
|
||||
(defvar org-babel-lilypond-display-pdf-post-tangle t
|
||||
"Following a successful LilyPond compilation
|
||||
org-babel-lilypond-display-pdf-post-tangle determines whether to automate the
|
||||
drawing / redrawing of the resultant pdf. If the value is nil,
|
||||
the pdf is not automatically redrawn. Default value is t")
|
||||
|
||||
(defvar org-babel-lilypond-play-midi-post-tangle t
|
||||
"Following a successful LilyPond compilation
|
||||
org-babel-lilypond-play-midi-post-tangle determines whether to automate the
|
||||
playing of the resultant midi file. If the value is nil,
|
||||
the midi file is not automatically played. Default value is t")
|
||||
|
||||
(defvar org-babel-lilypond-ly-command ""
|
||||
"Command to execute lilypond on your system.
|
||||
Do not set it directly. Customize `org-babel-lilypond-commands' instead.")
|
||||
(defvar org-babel-lilypond-pdf-command ""
|
||||
"Command to show a PDF file on your system.
|
||||
Do not set it directly. Customize `org-babel-lilypond-commands' instead.")
|
||||
(defvar org-babel-lilypond-midi-command ""
|
||||
"Command to play a MIDI file on your system.
|
||||
Do not set it directly. Customize `org-babel-lilypond-commands' instead.")
|
||||
(defcustom org-babel-lilypond-commands
|
||||
(cond
|
||||
((eq system-type 'darwin)
|
||||
'("/Applications/lilypond.app/Contents/Resources/bin/lilypond" "open" "open"))
|
||||
((eq system-type 'windows-nt)
|
||||
'("lilypond" "" ""))
|
||||
(t
|
||||
'("lilypond" "xdg-open" "xdg-open")))
|
||||
"Commands to run lilypond and view or play the results.
|
||||
These should be executables that take a filename as an argument.
|
||||
On some system it is possible to specify the filename directly
|
||||
and the viewer or player will be determined from the file type;
|
||||
you can leave the string empty on this case."
|
||||
:group 'org-babel
|
||||
:type '(list
|
||||
(string :tag "Lilypond ")
|
||||
(string :tag "PDF Viewer ")
|
||||
(string :tag "MIDI Player"))
|
||||
:version "24.3"
|
||||
:package-version '(Org . "8.2.7")
|
||||
:set
|
||||
(lambda (symbol value)
|
||||
(setq
|
||||
org-babel-lilypond-ly-command (nth 0 value)
|
||||
org-babel-lilypond-pdf-command (nth 1 value)
|
||||
org-babel-lilypond-midi-command (nth 2 value))))
|
||||
|
||||
(defvar org-babel-lilypond-gen-png nil
|
||||
"Non-nil means image generation (PNG) is turned on by default.")
|
||||
|
||||
(defvar org-babel-lilypond-gen-svg nil
|
||||
"Non-nil means image generation (SVG) is be turned on by default.")
|
||||
|
||||
(defvar org-babel-lilypond-gen-html nil
|
||||
"Non-nil means HTML generation is turned on by default.")
|
||||
|
||||
(defvar org-babel-lilypond-gen-pdf nil
|
||||
"Non-nil means PDF generation is be turned on by default.")
|
||||
|
||||
(defvar org-babel-lilypond-use-eps nil
|
||||
"Non-nil forces the compiler to use the EPS backend.")
|
||||
|
||||
(defvar org-babel-lilypond-arrange-mode nil
|
||||
"Non-nil turns Arrange mode on.
|
||||
In Arrange mode the following settings are altered from default:
|
||||
:tangle yes, :noweb yes
|
||||
:results silent :comments yes.
|
||||
In addition lilypond block execution causes tangling of all lilypond
|
||||
blocks.")
|
||||
|
||||
(defun org-babel-expand-body:lilypond (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(let ((name (symbol-name (car pair)))
|
||||
(value (cdr pair)))
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(concat "$" (regexp-quote name))
|
||||
(if (stringp value) value (format "%S" value))
|
||||
body))))
|
||||
vars)
|
||||
body))
|
||||
|
||||
(defun org-babel-execute:lilypond (body params)
|
||||
"This function is called by `org-babel-execute-src-block'.
|
||||
Depending on whether we are in arrange mode either:
|
||||
1. Attempt to execute lilypond block according to header settings
|
||||
(This is the default basic mode)
|
||||
2. Tangle all lilypond blocks and process the result (arrange mode)"
|
||||
(org-babel-lilypond-set-header-args org-babel-lilypond-arrange-mode)
|
||||
(if org-babel-lilypond-arrange-mode
|
||||
(org-babel-lilypond-tangle)
|
||||
(org-babel-lilypond-process-basic body params)))
|
||||
|
||||
(defun org-babel-lilypond-tangle ()
|
||||
"ob-lilypond specific tangle, attempts to invoke
|
||||
=ly-execute-tangled-ly= if tangle is successful. Also passes
|
||||
specific arguments to =org-babel-tangle="
|
||||
(interactive)
|
||||
(if (org-babel-tangle nil "yes" "lilypond")
|
||||
(org-babel-lilypond-execute-tangled-ly) nil))
|
||||
|
||||
(defun org-babel-lilypond-process-basic (body params)
|
||||
"Execute a lilypond block in basic mode."
|
||||
(let* ((result-params (cdr (assoc :result-params params)))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(cmdline (or (cdr (assoc :cmdline params))
|
||||
""))
|
||||
(in-file (org-babel-temp-file "lilypond-")))
|
||||
|
||||
(with-temp-file in-file
|
||||
(insert (org-babel-expand-body:generic body params)))
|
||||
(org-babel-eval
|
||||
(concat
|
||||
org-babel-lilypond-ly-command
|
||||
" -dbackend=eps "
|
||||
"-dno-gs-load-fonts "
|
||||
"-dinclude-eps-fonts "
|
||||
(or (cdr (assoc (file-name-extension out-file)
|
||||
'(("pdf" . "--pdf ")
|
||||
("ps" . "--ps ")
|
||||
("png" . "--png "))))
|
||||
"--png ")
|
||||
"--output="
|
||||
(file-name-sans-extension out-file)
|
||||
" "
|
||||
cmdline
|
||||
in-file) "")) nil)
|
||||
|
||||
(defun org-babel-prep-session:lilypond (session params)
|
||||
"Return an error because LilyPond exporter does not support sessions."
|
||||
(error "Sorry, LilyPond does not currently support sessions!"))
|
||||
|
||||
(defun org-babel-lilypond-execute-tangled-ly ()
|
||||
"Compile result of block tangle with lilypond.
|
||||
If error in compilation, attempt to mark the error in lilypond org file"
|
||||
(when org-babel-lilypond-compile-post-tangle
|
||||
(let ((org-babel-lilypond-tangled-file (org-babel-lilypond-switch-extension
|
||||
(buffer-file-name) ".lilypond"))
|
||||
(org-babel-lilypond-temp-file (org-babel-lilypond-switch-extension
|
||||
(buffer-file-name) ".ly")))
|
||||
(if (not (file-exists-p org-babel-lilypond-tangled-file))
|
||||
(error "Error: Tangle Failed!")
|
||||
(when (file-exists-p org-babel-lilypond-temp-file)
|
||||
(delete-file org-babel-lilypond-temp-file))
|
||||
(rename-file org-babel-lilypond-tangled-file
|
||||
org-babel-lilypond-temp-file))
|
||||
(switch-to-buffer-other-window "*lilypond*")
|
||||
(erase-buffer)
|
||||
(org-babel-lilypond-compile-lilyfile org-babel-lilypond-temp-file)
|
||||
(goto-char (point-min))
|
||||
(if (org-babel-lilypond-check-for-compile-error org-babel-lilypond-temp-file)
|
||||
(error "Error in Compilation!")
|
||||
(other-window -1)
|
||||
(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
|
||||
(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)))))
|
||||
|
||||
(defun org-babel-lilypond-compile-lilyfile (file-name &optional test)
|
||||
"Compile lilypond file and check for compile errors
|
||||
FILE-NAME is full path to lilypond (.ly) file"
|
||||
(message "Compiling LilyPond...")
|
||||
(let ((arg-1 org-babel-lilypond-ly-command) ;program
|
||||
(arg-2 nil) ;infile
|
||||
(arg-3 "*lilypond*") ;buffer
|
||||
(arg-4 t) ;display
|
||||
(arg-5 (if org-babel-lilypond-gen-png "--png" "")) ;&rest...
|
||||
(arg-6 (if org-babel-lilypond-gen-html "--html" ""))
|
||||
(arg-7 (if org-babel-lilypond-gen-pdf "--pdf" ""))
|
||||
(arg-8 (if org-babel-lilypond-use-eps "-dbackend=eps" ""))
|
||||
(arg-9 (if org-babel-lilypond-gen-svg "-dbackend=svg" ""))
|
||||
(arg-10 (concat "--output=" (file-name-sans-extension file-name)))
|
||||
(arg-11 file-name))
|
||||
(if test
|
||||
`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5 ,arg-6
|
||||
,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
|
||||
(call-process
|
||||
arg-1 arg-2 arg-3 arg-4 arg-5 arg-6
|
||||
arg-7 arg-8 arg-9 arg-10 arg-11))))
|
||||
|
||||
(defun org-babel-lilypond-check-for-compile-error (file-name &optional test)
|
||||
"Check for compile error.
|
||||
This is performed by parsing the *lilypond* buffer
|
||||
containing the output message from the compilation.
|
||||
FILE-NAME is full path to lilypond file.
|
||||
If TEST is t just return nil if no error found, and pass
|
||||
nil as file-name since it is unused in this context"
|
||||
(let ((is-error (search-forward "error:" nil t)))
|
||||
(if test
|
||||
is-error
|
||||
(when is-error
|
||||
(org-babel-lilypond-process-compile-error file-name)))))
|
||||
|
||||
(defun org-babel-lilypond-process-compile-error (file-name)
|
||||
"Process the compilation error that has occurred.
|
||||
FILE-NAME is full path to lilypond file"
|
||||
(let ((line-num (org-babel-lilypond-parse-line-num)))
|
||||
(let ((error-lines (org-babel-lilypond-parse-error-line file-name line-num)))
|
||||
(org-babel-lilypond-mark-error-line file-name error-lines)
|
||||
(error "Error: Compilation Failed!"))))
|
||||
|
||||
(defun org-babel-lilypond-mark-error-line (file-name line)
|
||||
"Mark the erroneous lines in the lilypond org buffer.
|
||||
FILE-NAME is full path to lilypond file.
|
||||
LINE is the erroneous line"
|
||||
(switch-to-buffer-other-window
|
||||
(concat (file-name-nondirectory
|
||||
(org-babel-lilypond-switch-extension file-name ".org"))))
|
||||
(let ((temp (point)))
|
||||
(goto-char (point-min))
|
||||
(setq case-fold-search nil)
|
||||
(if (search-forward line nil t)
|
||||
(progn
|
||||
(outline-show-all)
|
||||
(set-mark (point))
|
||||
(goto-char (- (point) (length line))))
|
||||
(goto-char temp))))
|
||||
|
||||
(defun org-babel-lilypond-parse-line-num (&optional buffer)
|
||||
"Extract error line number."
|
||||
(when buffer
|
||||
(set-buffer buffer))
|
||||
(let ((start
|
||||
(and (search-backward ":" nil t)
|
||||
(search-backward ":" nil t)
|
||||
(search-backward ":" nil t)
|
||||
(search-backward ":" nil t)))
|
||||
(num nil))
|
||||
(if start
|
||||
(progn
|
||||
(forward-char)
|
||||
(let ((num (buffer-substring
|
||||
(+ 1 start)
|
||||
(- (search-forward ":" nil t) 1))))
|
||||
(setq num (string-to-number num))
|
||||
(if (numberp num)
|
||||
num
|
||||
nil)))
|
||||
nil)))
|
||||
|
||||
(defun org-babel-lilypond-parse-error-line (file-name lineNo)
|
||||
"Extract the erroneous line from the tangled .ly file
|
||||
FILE-NAME is full path to lilypond file.
|
||||
LINENO is the number of the erroneous line"
|
||||
(with-temp-buffer
|
||||
(insert-file-contents (org-babel-lilypond-switch-extension file-name ".ly")
|
||||
nil nil nil t)
|
||||
(if (> lineNo 0)
|
||||
(progn
|
||||
(goto-char (point-min))
|
||||
(forward-line (- lineNo 1))
|
||||
(buffer-substring (point) (point-at-eol)))
|
||||
nil)))
|
||||
|
||||
(defun org-babel-lilypond-attempt-to-open-pdf (file-name &optional test)
|
||||
"Attempt to display the generated pdf file
|
||||
FILE-NAME is full path to lilypond file
|
||||
If TEST is non-nil, the shell command is returned and is not run"
|
||||
(when org-babel-lilypond-display-pdf-post-tangle
|
||||
(let ((pdf-file (org-babel-lilypond-switch-extension file-name ".pdf")))
|
||||
(if (file-exists-p pdf-file)
|
||||
(let ((cmd-string
|
||||
(concat org-babel-lilypond-pdf-command " " pdf-file)))
|
||||
(if test
|
||||
cmd-string
|
||||
(start-process
|
||||
"\"Audition pdf\""
|
||||
"*lilypond*"
|
||||
org-babel-lilypond-pdf-command
|
||||
pdf-file)))
|
||||
(message "No pdf file generated so can't display!")))))
|
||||
|
||||
(defun org-babel-lilypond-attempt-to-play-midi (file-name &optional test)
|
||||
"Attempt to play the generated MIDI file
|
||||
FILE-NAME is full path to lilypond file
|
||||
If TEST is non-nil, the shell command is returned and is not run"
|
||||
(when org-babel-lilypond-play-midi-post-tangle
|
||||
(let ((midi-file (org-babel-lilypond-switch-extension file-name ".midi")))
|
||||
(if (file-exists-p midi-file)
|
||||
(let ((cmd-string
|
||||
(concat org-babel-lilypond-midi-command " " midi-file)))
|
||||
(if test
|
||||
cmd-string
|
||||
(start-process
|
||||
"\"Audition midi\""
|
||||
"*lilypond*"
|
||||
org-babel-lilypond-midi-command
|
||||
midi-file)))
|
||||
(message "No midi file generated so can't play!")))))
|
||||
|
||||
(defun org-babel-lilypond-toggle-midi-play ()
|
||||
"Toggle whether midi will be played following a successful compilation."
|
||||
(interactive)
|
||||
(setq org-babel-lilypond-play-midi-post-tangle
|
||||
(not org-babel-lilypond-play-midi-post-tangle))
|
||||
(message (concat "Post-Tangle MIDI play has been "
|
||||
(if org-babel-lilypond-play-midi-post-tangle
|
||||
"ENABLED." "DISABLED."))))
|
||||
|
||||
(defun org-babel-lilypond-toggle-pdf-display ()
|
||||
"Toggle whether pdf will be displayed following a successful compilation."
|
||||
(interactive)
|
||||
(setq org-babel-lilypond-display-pdf-post-tangle
|
||||
(not org-babel-lilypond-display-pdf-post-tangle))
|
||||
(message (concat "Post-Tangle PDF display has been "
|
||||
(if org-babel-lilypond-display-pdf-post-tangle
|
||||
"ENABLED." "DISABLED."))))
|
||||
|
||||
(defun org-babel-lilypond-toggle-png-generation ()
|
||||
"Toggle whether png image will be generated by compilation."
|
||||
(interactive)
|
||||
(setq org-babel-lilypond-gen-png (not org-babel-lilypond-gen-png))
|
||||
(message (concat "PNG image generation has been "
|
||||
(if org-babel-lilypond-gen-png "ENABLED." "DISABLED."))))
|
||||
|
||||
(defun org-babel-lilypond-toggle-html-generation ()
|
||||
"Toggle whether html will be generated by compilation."
|
||||
(interactive)
|
||||
(setq org-babel-lilypond-gen-html (not org-babel-lilypond-gen-html))
|
||||
(message (concat "HTML generation has been "
|
||||
(if org-babel-lilypond-gen-html "ENABLED." "DISABLED."))))
|
||||
|
||||
(defun org-babel-lilypond-toggle-pdf-generation ()
|
||||
"Toggle whether pdf will be generated by compilation."
|
||||
(interactive)
|
||||
(setq org-babel-lilypond-gen-pdf (not org-babel-lilypond-gen-pdf))
|
||||
(message (concat "PDF generation has been "
|
||||
(if org-babel-lilypond-gen-pdf "ENABLED." "DISABLED."))))
|
||||
|
||||
(defun org-babel-lilypond-toggle-arrange-mode ()
|
||||
"Toggle whether in Arrange mode or Basic mode."
|
||||
(interactive)
|
||||
(setq org-babel-lilypond-arrange-mode
|
||||
(not org-babel-lilypond-arrange-mode))
|
||||
(message (concat "Arrange mode has been "
|
||||
(if org-babel-lilypond-arrange-mode "ENABLED." "DISABLED."))))
|
||||
|
||||
(defun org-babel-lilypond-switch-extension (file-name ext)
|
||||
"Utility command to swap current FILE-NAME extension with EXT"
|
||||
(concat (file-name-sans-extension
|
||||
file-name) ext))
|
||||
|
||||
(defun org-babel-lilypond-get-header-args (mode)
|
||||
"Default arguments to use when evaluating a lilypond
|
||||
source block. These depend upon whether we are in arrange
|
||||
mode i.e. ARRANGE-MODE is t"
|
||||
(cond (mode
|
||||
'((:tangle . "yes")
|
||||
(:noweb . "yes")
|
||||
(:results . "silent")
|
||||
(:cache . "yes")
|
||||
(:comments . "yes")))
|
||||
(t
|
||||
'((:results . "file")
|
||||
(:exports . "results")))))
|
||||
|
||||
(defun org-babel-lilypond-set-header-args (mode)
|
||||
"Set org-babel-default-header-args:lilypond
|
||||
dependent on ORG-BABEL-LILYPOND-ARRANGE-MODE"
|
||||
(setq org-babel-default-header-args:lilypond
|
||||
(org-babel-lilypond-get-header-args mode)))
|
||||
|
||||
(provide 'ob-lilypond)
|
||||
|
||||
;;; ob-lilypond.el ends here
|
111
elpa/org-20160919/ob-lisp.el
Normal file
111
elpa/org-20160919/ob-lisp.el
Normal file
@ -0,0 +1,111 @@
|
||||
;;; ob-lisp.el --- org-babel functions for common lisp evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Joel Boehland
|
||||
;; Eric Schulte
|
||||
;; David T. O'Toole <dto@gnu.org>
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; support for evaluating common lisp code, relies on slime for all eval
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.)
|
||||
;; See http://common-lisp.net/project/slime/
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function slime-eval "ext:slime" (sexp &optional package))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("lisp" . "lisp"))
|
||||
|
||||
(defvar org-babel-default-header-args:lisp '())
|
||||
(defvar org-babel-header-args:lisp '((package . :any)))
|
||||
|
||||
(defcustom org-babel-lisp-dir-fmt
|
||||
"(let ((*default-pathname-defaults* #P%S\n)) %%s\n)"
|
||||
"Format string used to wrap code bodies to set the current directory.
|
||||
For example a value of \"(progn ;; %s\\n %%s)\" would ignore the
|
||||
current directory string."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-expand-body:lisp (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(print-level nil) (print-length nil)
|
||||
(body (org-babel-trim
|
||||
(if (> (length vars) 0)
|
||||
(concat "(let ("
|
||||
(mapconcat
|
||||
(lambda (var)
|
||||
(format "(%S (quote %S))" (car var) (cdr var)))
|
||||
vars "\n ")
|
||||
")\n" body ")")
|
||||
body))))
|
||||
(if (or (member "code" result-params)
|
||||
(member "pp" result-params))
|
||||
(format "(pprint %s)" body)
|
||||
body)))
|
||||
|
||||
(defun org-babel-execute:lisp (body params)
|
||||
"Execute a block of Common Lisp code with Babel."
|
||||
(require 'slime)
|
||||
(org-babel-reassemble-table
|
||||
(let ((result
|
||||
(funcall (if (member "output" (cdr (assoc :result-params params)))
|
||||
#'car #'cadr)
|
||||
(with-temp-buffer
|
||||
(insert (org-babel-expand-body:lisp body params))
|
||||
(slime-eval `(swank:eval-and-grab-output
|
||||
,(let ((dir (if (assoc :dir params)
|
||||
(cdr (assoc :dir params))
|
||||
default-directory)))
|
||||
(format
|
||||
(if dir (format org-babel-lisp-dir-fmt dir)
|
||||
"(progn %s\n)")
|
||||
(buffer-substring-no-properties
|
||||
(point-min) (point-max)))))
|
||||
(cdr (assoc :package params)))))))
|
||||
(org-babel-result-cond (cdr (assoc :result-params params))
|
||||
result
|
||||
(condition-case nil
|
||||
(read (org-babel-lisp-vector-to-list result))
|
||||
(error result))))
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params)))))
|
||||
|
||||
(defun org-babel-lisp-vector-to-list (results)
|
||||
;; TODO: better would be to replace #(...) with [...]
|
||||
(replace-regexp-in-string "#(" "(" results))
|
||||
|
||||
(provide 'ob-lisp)
|
||||
|
||||
|
||||
|
||||
;;; ob-lisp.el ends here
|
179
elpa/org-20160919/ob-lob.el
Normal file
179
elpa/org-20160919/ob-lob.el
Normal file
@ -0,0 +1,179 @@
|
||||
;;; ob-lob.el --- functions supporting the Library of Babel
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Eric Schulte
|
||||
;; Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'ob-core)
|
||||
(require 'ob-table)
|
||||
|
||||
(declare-function org-babel-in-example-or-verbatim "ob-exp" nil)
|
||||
|
||||
(defvar org-babel-library-of-babel nil
|
||||
"Library of source-code blocks.
|
||||
This is an association list. Populate the library by adding
|
||||
files to `org-babel-lob-files'.")
|
||||
|
||||
(defcustom org-babel-lob-files nil
|
||||
"Files used to populate the `org-babel-library-of-babel'.
|
||||
To add files to this list use the `org-babel-lob-ingest' command."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type '(repeat file))
|
||||
|
||||
(defvar org-babel-default-lob-header-args '((:exports . "results"))
|
||||
"Default header arguments to use when exporting #+lob/call lines.")
|
||||
|
||||
(defun org-babel-lob-ingest (&optional file)
|
||||
"Add all named source blocks defined in FILE to `org-babel-library-of-babel'."
|
||||
(interactive "fFile: ")
|
||||
(let ((lob-ingest-count 0))
|
||||
(org-babel-map-src-blocks file
|
||||
(let* ((info (org-babel-get-src-block-info 'light))
|
||||
(source-name (nth 4 info)))
|
||||
(when source-name
|
||||
(setq source-name (intern source-name)
|
||||
org-babel-library-of-babel
|
||||
(cons (cons source-name info)
|
||||
(assq-delete-all source-name org-babel-library-of-babel))
|
||||
lob-ingest-count (1+ lob-ingest-count)))))
|
||||
(message "%d src block%s added to Library of Babel"
|
||||
lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
|
||||
lob-ingest-count))
|
||||
|
||||
(defconst org-babel-block-lob-one-liner-regexp
|
||||
(concat
|
||||
"^\\([ \t]*?\\)#\\+call:[ \t]+\\([^()\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
|
||||
"(\\([^\n]*?\\))\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
|
||||
"Regexp to match non-inline calls to predefined source block functions.")
|
||||
|
||||
(defconst org-babel-inline-lob-one-liner-regexp
|
||||
(concat
|
||||
"\\([^\n]*?\\)call_\\([^()[:space:]\n]+?\\)\\(\\[\\(.*?\\)\\]\\|\\(\\)\\)"
|
||||
"(\\(.*?\\))\\(\\[\\(.*?\\)\\]\\)?")
|
||||
"Regexp to match inline calls to predefined source block functions.")
|
||||
|
||||
(defconst org-babel-lob-one-liner-regexp
|
||||
(concat "\\(" org-babel-block-lob-one-liner-regexp
|
||||
"\\|" org-babel-inline-lob-one-liner-regexp "\\)")
|
||||
"Regexp to match calls to predefined source block functions.")
|
||||
|
||||
;; functions for executing lob one-liners
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-lob-execute-maybe ()
|
||||
"Execute a Library of Babel source block, if appropriate.
|
||||
Detect if this is context for a Library Of Babel source block and
|
||||
if so then run the appropriate source block from the Library."
|
||||
(interactive)
|
||||
(let ((info (org-babel-lob-get-info)))
|
||||
(if (and (nth 0 info) (not (org-babel-in-example-or-verbatim)))
|
||||
(progn (org-babel-lob-execute info) t)
|
||||
nil)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-lob-get-info ()
|
||||
"Return a Library of Babel function call as a string."
|
||||
(let ((case-fold-search t)
|
||||
(nonempty (lambda (a b)
|
||||
(let ((it (match-string a)))
|
||||
(if (= (length it) 0) (match-string b) it)))))
|
||||
(save-excursion
|
||||
(beginning-of-line 1)
|
||||
(when (looking-at org-babel-lob-one-liner-regexp)
|
||||
(append
|
||||
(mapcar #'org-no-properties
|
||||
(list
|
||||
(format "%s%s(%s)%s"
|
||||
(funcall nonempty 3 12)
|
||||
(if (not (= 0 (length (funcall nonempty 5 14))))
|
||||
(concat "[" (funcall nonempty 5 14) "]") "")
|
||||
(or (funcall nonempty 7 16) "")
|
||||
(or (funcall nonempty 8 19) ""))
|
||||
(funcall nonempty 9 18)))
|
||||
(list (length (if (= (length (match-string 12)) 0)
|
||||
(match-string 2) (match-string 11)))
|
||||
(save-excursion
|
||||
(forward-line -1)
|
||||
(save-match-data
|
||||
(and (looking-at (concat org-babel-src-name-regexp
|
||||
"\\([^\n]*\\)$"))
|
||||
(org-no-properties (match-string 1)))))))))))
|
||||
|
||||
(defvar org-babel-default-header-args:emacs-lisp) ; Defined in ob-emacs-lisp.el
|
||||
(defun org-babel-lob-execute (info)
|
||||
"Execute the lob call specified by INFO."
|
||||
(let* ((mkinfo (lambda (p)
|
||||
(list "emacs-lisp" "results" p nil
|
||||
(nth 3 info) ;; name
|
||||
(nth 2 info))))
|
||||
(pre-params (apply #'org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-header-args:emacs-lisp
|
||||
(append
|
||||
(org-babel-params-from-properties)
|
||||
(list
|
||||
(org-babel-parse-header-arguments
|
||||
(org-no-properties
|
||||
(concat
|
||||
":var results="
|
||||
(mapconcat #'identity (butlast info 2)
|
||||
" "))))))))
|
||||
(pre-info (funcall mkinfo pre-params))
|
||||
(cache-p (and (cdr (assoc :cache pre-params))
|
||||
(string= "yes" (cdr (assoc :cache pre-params)))))
|
||||
(new-hash (when cache-p
|
||||
(org-babel-sha1-hash
|
||||
;; Do *not* pre-process params for call line
|
||||
;; hash evaluation, since for a call line :var
|
||||
;; extension *is* execution.
|
||||
(let* ((params (nth 2 pre-info))
|
||||
(sha1-nth2 (list
|
||||
(cons
|
||||
(cons :c-var (cdr (assoc :var params)))
|
||||
(assq-delete-all :var (copy-tree params)))))
|
||||
(sha1-info (copy-tree pre-info)))
|
||||
(prog1 sha1-info
|
||||
(setcar (cddr sha1-info) sha1-nth2))))))
|
||||
(old-hash (when cache-p (org-babel-current-result-hash pre-info)))
|
||||
(org-babel-current-src-block-location (point-marker)))
|
||||
(if (and cache-p (equal new-hash old-hash))
|
||||
(save-excursion (goto-char (org-babel-where-is-src-block-result
|
||||
nil pre-info))
|
||||
(forward-line 1)
|
||||
(message "%S" (org-babel-read-result)))
|
||||
(prog1 (let* ((proc-params (org-babel-process-params pre-params))
|
||||
org-confirm-babel-evaluate)
|
||||
(org-babel-execute-src-block nil (funcall mkinfo proc-params)))
|
||||
;; update the hash
|
||||
(when new-hash
|
||||
(org-babel-set-current-result-hash new-hash pre-info))))))
|
||||
|
||||
(provide 'ob-lob)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ob-lob.el ends here
|
48
elpa/org-20160919/ob-makefile.el
Normal file
48
elpa/org-20160919/ob-makefile.el
Normal file
@ -0,0 +1,48 @@
|
||||
;;; ob-makefile.el --- org-babel functions for makefile evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Thomas S. Dye
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This file exists solely for tangling a Makefile from org-mode files.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:makefile '())
|
||||
|
||||
(defun org-babel-execute:makefile (body params)
|
||||
"Execute a block of makefile code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
body)
|
||||
|
||||
(defun org-babel-prep-session:makefile (session params)
|
||||
"Return an error if the :session header argument is set. Make
|
||||
does not support sessions."
|
||||
(error "Makefile sessions are nonsensical"))
|
||||
|
||||
(provide 'ob-makefile)
|
||||
|
||||
|
||||
|
||||
;;; ob-makefile.el ends here
|
47
elpa/org-20160919/ob-matlab.el
Normal file
47
elpa/org-20160919/ob-matlab.el
Normal file
@ -0,0 +1,47 @@
|
||||
;;; ob-matlab.el --- org-babel support for matlab evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Functions that are common to org-babel support for matlab and
|
||||
;; octave are in org-babel-octave.el
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; Matlab
|
||||
|
||||
;; matlab.el required for interactive emacs sessions and matlab-mode
|
||||
;; major mode for source code editing buffer
|
||||
;; http://matlab-emacs.sourceforge.net/
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-octave)
|
||||
|
||||
;; see ob-octave for matlab implementation
|
||||
|
||||
(provide 'ob-matlab)
|
||||
|
||||
|
||||
|
||||
;;; ob-matlab.el ends here
|
127
elpa/org-20160919/ob-maxima.el
Normal file
127
elpa/org-20160919/ob-maxima.el
Normal file
@ -0,0 +1,127 @@
|
||||
;;; ob-maxima.el --- org-babel functions for maxima evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric S Fraga
|
||||
;; Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, maxima
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating maxima entries.
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in maxima
|
||||
;;
|
||||
;; 2) we are adding the "cmdline" header argument
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("maxima" . "max"))
|
||||
|
||||
(defvar org-babel-default-header-args:maxima '())
|
||||
|
||||
(defcustom org-babel-maxima-command
|
||||
(if (boundp 'maxima-command) maxima-command "maxima")
|
||||
"Command used to call maxima on the shell."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-maxima-expand (body params)
|
||||
"Expand a block of Maxima code according to its header arguments."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(mapconcat 'identity
|
||||
(list
|
||||
;; graphic output
|
||||
(let ((graphic-file (ignore-errors (org-babel-graphical-output-file params))))
|
||||
(if graphic-file
|
||||
(format
|
||||
"set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]);"
|
||||
graphic-file)
|
||||
""))
|
||||
;; variables
|
||||
(mapconcat 'org-babel-maxima-var-to-maxima vars "\n")
|
||||
;; body
|
||||
body
|
||||
"gnuplot_close ()$")
|
||||
"\n")))
|
||||
|
||||
(defun org-babel-execute:maxima (body params)
|
||||
"Execute a block of Maxima entries with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(message "executing Maxima source code block")
|
||||
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(result
|
||||
(let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
|
||||
(in-file (org-babel-temp-file "maxima-" ".max"))
|
||||
(cmd (format "%s --very-quiet -r 'batchload(%S)$' %s"
|
||||
org-babel-maxima-command in-file cmdline)))
|
||||
(with-temp-file in-file (insert (org-babel-maxima-expand body params)))
|
||||
(message cmd)
|
||||
;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
|
||||
(let ((raw (org-babel-eval cmd "")))
|
||||
(mapconcat
|
||||
#'identity
|
||||
(delq nil
|
||||
(mapcar (lambda (line)
|
||||
(unless (or (string-match "batch" line)
|
||||
(string-match "^rat: replaced .*$" line)
|
||||
(string-match "^;;; Loading #P" line)
|
||||
(= 0 (length line)))
|
||||
line))
|
||||
(split-string raw "[\r\n]"))) "\n")))))
|
||||
(if (ignore-errors (org-babel-graphical-output-file params))
|
||||
nil
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(let ((tmp-file (org-babel-temp-file "maxima-res-")))
|
||||
(with-temp-file tmp-file (insert result))
|
||||
(org-babel-import-elisp-from-file tmp-file))))))
|
||||
|
||||
|
||||
(defun org-babel-prep-session:maxima (session params)
|
||||
(error "Maxima does not support sessions"))
|
||||
|
||||
(defun org-babel-maxima-var-to-maxima (pair)
|
||||
"Convert an elisp val into a string of maxima code specifying a var
|
||||
of the same value."
|
||||
(let ((var (car pair))
|
||||
(val (cdr pair)))
|
||||
(when (symbolp val)
|
||||
(setq val (symbol-name val))
|
||||
(when (= (length val) 1)
|
||||
(setq val (string-to-char val))))
|
||||
(format "%S: %s$" var
|
||||
(org-babel-maxima-elisp-to-maxima val))))
|
||||
|
||||
(defun org-babel-maxima-elisp-to-maxima (val)
|
||||
"Return a string of maxima code which evaluates to VAL."
|
||||
(if (listp val)
|
||||
(concat "[" (mapconcat #'org-babel-maxima-elisp-to-maxima val ", ") "]")
|
||||
(format "%s" val)))
|
||||
|
||||
|
||||
(provide 'ob-maxima)
|
||||
|
||||
|
||||
|
||||
;;; ob-maxima.el ends here
|
84
elpa/org-20160919/ob-mscgen.el
Normal file
84
elpa/org-20160919/ob-mscgen.el
Normal file
@ -0,0 +1,84 @@
|
||||
;;; ob-msc.el --- org-babel functions for mscgen evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Juan Pechiar
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This software provides EMACS org-babel export support for message
|
||||
;; sequence charts. The mscgen utility is used for processing the
|
||||
;; sequence definition, and must therefore be installed in the system.
|
||||
;;
|
||||
;; Mscgen is available and documented at
|
||||
;; http://www.mcternan.me.uk/mscgen/index.html
|
||||
;;
|
||||
;; This code is directly inspired by Eric Schulte's ob-dot.el
|
||||
;;
|
||||
;; Example:
|
||||
;;
|
||||
;; #+begin_src mscgen :file example.png
|
||||
;; msc {
|
||||
;; A,B;
|
||||
;; A -> B [ label = "send message" ];
|
||||
;; A <- B [ label = "get answer" ];
|
||||
;; }
|
||||
;; #+end_src
|
||||
;;
|
||||
;; Header for alternative file type:
|
||||
;;
|
||||
;; #+begin_src mscgen :file ex2.svg :filetype svg
|
||||
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in mscgen
|
||||
;; 2) we are generally only going to return results of type "file"
|
||||
;; 3) we are adding the "file" and "filetype" header arguments
|
||||
;; 4) there are no variables
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:mscgen
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a mscgen source block.")
|
||||
|
||||
(defun org-babel-execute:mscgen (body params)
|
||||
"Execute a block of Mscgen code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'.
|
||||
Default filetype is png. Modify by setting :filetype parameter to
|
||||
mscgen supported formats."
|
||||
(let* ((out-file (or (cdr (assoc :file params)) "output.png" ))
|
||||
(filetype (or (cdr (assoc :filetype params)) "png" )))
|
||||
(unless (cdr (assoc :file params))
|
||||
(error "
|
||||
ERROR: no output file specified. Add \":file name.png\" to the src header"))
|
||||
(org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body)
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:mscgen (session params)
|
||||
"Raise an error because Mscgen doesn't support sessions."
|
||||
(error "Mscgen does not support sessions"))
|
||||
|
||||
(provide 'ob-mscgen)
|
||||
|
||||
|
||||
|
||||
;;; ob-msc.el ends here
|
173
elpa/org-20160919/ob-ocaml.el
Normal file
173
elpa/org-20160919/ob-ocaml.el
Normal file
@ -0,0 +1,173 @@
|
||||
;;; ob-ocaml.el --- org-babel functions for ocaml evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating ocaml source code. This one will
|
||||
;; be sort of tricky because ocaml programs must be compiled before
|
||||
;; they can be run, but ocaml code can also be run through an
|
||||
;; interactive interpreter.
|
||||
;;
|
||||
;; For now lets only allow evaluation using the ocaml interpreter.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - tuareg-mode :: http://www-rocq.inria.fr/~acohen/tuareg/
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function tuareg-run-caml "ext:tuareg" ())
|
||||
(declare-function tuareg-run-ocaml "ext:tuareg" ())
|
||||
(declare-function tuareg-interactive-send-input "ext:tuareg" ())
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("ocaml" . "ml"))
|
||||
|
||||
(defvar org-babel-default-header-args:ocaml '())
|
||||
|
||||
(defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;")
|
||||
(defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe")
|
||||
|
||||
(defcustom org-babel-ocaml-command "ocaml"
|
||||
"Name of the command for executing Ocaml code."
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:ocaml (body params)
|
||||
"Execute a block of Ocaml code with Babel."
|
||||
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params
|
||||
(org-babel-variable-assignments:ocaml params)))
|
||||
(session (org-babel-prep-session:ocaml
|
||||
(cdr (assoc :session params)) params))
|
||||
(raw (org-babel-comint-with-output
|
||||
(session org-babel-ocaml-eoe-output t full-body)
|
||||
(insert
|
||||
(concat
|
||||
(org-babel-chomp full-body) ";;\n"
|
||||
org-babel-ocaml-eoe-indicator))
|
||||
(tuareg-interactive-send-input)))
|
||||
(clean
|
||||
(car (let ((re (regexp-quote org-babel-ocaml-eoe-output)) out)
|
||||
(delq nil (mapcar (lambda (line)
|
||||
(if out
|
||||
(progn (setq out nil) line)
|
||||
(when (string-match re line)
|
||||
(progn (setq out t) nil))))
|
||||
(mapcar #'org-babel-trim (reverse raw)))))))
|
||||
(raw (org-babel-trim clean))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(parsed
|
||||
(string-match
|
||||
"\\(\\(.*\n\\)*\\)[^:\n]+ : \\([^=\n]+\\) =\\(\n\\| \\)\\(.+\\)$"
|
||||
raw))
|
||||
(output (match-string 1 raw))
|
||||
(type (match-string 3 raw))
|
||||
(value (match-string 5 raw)))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-result-cond result-params
|
||||
(cond
|
||||
((member "verbatim" result-params) raw)
|
||||
((member "output" result-params) output)
|
||||
(t raw))
|
||||
(if (and value type)
|
||||
(org-babel-ocaml-parse-output value type)
|
||||
raw))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defvar tuareg-interactive-buffer-name)
|
||||
(defun org-babel-prep-session:ocaml (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS."
|
||||
(require 'tuareg)
|
||||
(let ((tuareg-interactive-buffer-name (if (and (not (string= session "none"))
|
||||
(not (string= session "default"))
|
||||
(stringp session))
|
||||
session
|
||||
tuareg-interactive-buffer-name)))
|
||||
(save-window-excursion (if (fboundp 'tuareg-run-process-if-needed)
|
||||
(tuareg-run-process-if-needed org-babel-ocaml-command)
|
||||
(tuareg-run-caml)))
|
||||
(get-buffer tuareg-interactive-buffer-name)))
|
||||
|
||||
(defun org-babel-variable-assignments:ocaml (params)
|
||||
"Return list of ocaml statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair) (format "let %s = %s;;" (car pair)
|
||||
(org-babel-ocaml-elisp-to-ocaml (cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-ocaml-elisp-to-ocaml (val)
|
||||
"Return a string of ocaml code which evaluates to VAL."
|
||||
(if (listp val)
|
||||
(concat "[|" (mapconcat #'org-babel-ocaml-elisp-to-ocaml val "; ") "|]")
|
||||
(format "%S" val)))
|
||||
|
||||
(defun org-babel-ocaml-parse-output (value type)
|
||||
"Parse VALUE of type TYPE.
|
||||
VALUE and TYPE are string output from an ocaml process."
|
||||
(cond
|
||||
((string= "string" type)
|
||||
(org-babel-read value))
|
||||
((or (string= "int" type)
|
||||
(string= "float" type))
|
||||
(string-to-number value))
|
||||
((string-match "list" type)
|
||||
(org-babel-ocaml-read-list value))
|
||||
((string-match "array" type)
|
||||
(org-babel-ocaml-read-array value))
|
||||
(t (message "don't recognize type %s" type) value)))
|
||||
|
||||
(defun org-babel-ocaml-read-list (results)
|
||||
"Convert RESULTS into an elisp table or string.
|
||||
If the results look like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
;; XXX: This probably does not behave as expected when a semicolon
|
||||
;; is in a string in a list. The same comment applies to
|
||||
;; `org-babel-ocaml-read-array' below (with even more failure
|
||||
;; modes).
|
||||
(org-babel-script-escape (replace-regexp-in-string ";" "," results)))
|
||||
|
||||
(defun org-babel-ocaml-read-array (results)
|
||||
"Convert RESULTS into an elisp table or string.
|
||||
If the results look like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(org-babel-script-escape
|
||||
(replace-regexp-in-string
|
||||
"\\[|" "[" (replace-regexp-in-string
|
||||
"|\\]" "]" (replace-regexp-in-string
|
||||
"; " "," results)))))
|
||||
|
||||
(provide 'ob-ocaml)
|
||||
|
||||
|
||||
|
||||
;;; ob-ocaml.el ends here
|
276
elpa/org-20160919/ob-octave.el
Normal file
276
elpa/org-20160919/ob-octave.el
Normal file
@ -0,0 +1,276 @@
|
||||
;;; ob-octave.el --- org-babel functions for octave and matlab evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; octave
|
||||
;; octave-mode.el and octave-inf.el come with GNU emacs
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function matlab-shell "ext:matlab-mode")
|
||||
(declare-function matlab-shell-run-region "ext:matlab-mode")
|
||||
|
||||
(defvar org-babel-default-header-args:matlab '())
|
||||
(defvar org-babel-default-header-args:octave '())
|
||||
|
||||
(defvar org-babel-matlab-shell-command "matlab -nosplash"
|
||||
"Shell command to run matlab as an external process.")
|
||||
(defvar org-babel-octave-shell-command "octave -q"
|
||||
"Shell command to run octave as an external process.")
|
||||
|
||||
(defvar org-babel-matlab-with-emacs-link nil
|
||||
"If non-nil use matlab-shell-run-region for session evaluation.
|
||||
This will use EmacsLink if (matlab-with-emacs-link) evaluates
|
||||
to a non-nil value.")
|
||||
|
||||
(defvar org-babel-matlab-emacs-link-wrapper-method
|
||||
"%s
|
||||
if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid);
|
||||
else, save -ascii %s ans
|
||||
end
|
||||
delete('%s')
|
||||
")
|
||||
(defvar org-babel-octave-wrapper-method
|
||||
"%s
|
||||
if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid);
|
||||
else, dlmwrite('%s', ans, '\\t')
|
||||
end")
|
||||
|
||||
(defvar org-babel-octave-eoe-indicator "'org_babel_eoe'")
|
||||
|
||||
(defvar org-babel-octave-eoe-output "ans = org_babel_eoe")
|
||||
|
||||
(defun org-babel-execute:matlab (body params)
|
||||
"Execute a block of matlab code with Babel."
|
||||
(org-babel-execute:octave body params 'matlab))
|
||||
|
||||
(defun org-babel-execute:octave (body params &optional matlabp)
|
||||
"Execute a block of octave code with Babel."
|
||||
(let* ((session
|
||||
(funcall (intern (format "org-babel-%s-initiate-session"
|
||||
(if matlabp "matlab" "octave")))
|
||||
(cdr (assoc :session params)) params))
|
||||
(vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(full-body
|
||||
(org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:octave params)))
|
||||
(gfx-file (ignore-errors (org-babel-graphical-output-file params)))
|
||||
(result (org-babel-octave-evaluate
|
||||
session
|
||||
(if gfx-file
|
||||
(mapconcat 'identity
|
||||
(list
|
||||
"set (0, \"defaultfigurevisible\", \"off\");"
|
||||
full-body
|
||||
(format "print -dpng %s" gfx-file))
|
||||
"\n")
|
||||
full-body)
|
||||
result-type matlabp)))
|
||||
(if gfx-file
|
||||
nil
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
|
||||
|
||||
(defun org-babel-prep-session:matlab (session params)
|
||||
"Prepare SESSION according to PARAMS."
|
||||
(org-babel-prep-session:octave session params 'matlab))
|
||||
|
||||
(defun org-babel-variable-assignments:octave (params)
|
||||
"Return list of octave statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(format "%s=%s;"
|
||||
(car pair)
|
||||
(org-babel-octave-var-to-octave (cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defalias 'org-babel-variable-assignments:matlab
|
||||
'org-babel-variable-assignments:octave)
|
||||
|
||||
(defun org-babel-octave-var-to-octave (var)
|
||||
"Convert an emacs-lisp value into an octave variable.
|
||||
Converts an emacs-lisp variable into a string of octave code
|
||||
specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-octave-var-to-octave var
|
||||
(if (listp (car var)) "; " ",")) "]")
|
||||
(cond
|
||||
((stringp var)
|
||||
(format "'%s'" var))
|
||||
(t
|
||||
(format "%s" var)))))
|
||||
|
||||
(defun org-babel-prep-session:octave (session params &optional matlabp)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-octave-initiate-session session params matlabp))
|
||||
(var-lines (org-babel-variable-assignments:octave params)))
|
||||
(org-babel-comint-in-buffer session
|
||||
(mapc (lambda (var)
|
||||
(end-of-line 1) (insert var) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)) var-lines))
|
||||
session))
|
||||
|
||||
(defun org-babel-matlab-initiate-session (&optional session params)
|
||||
"Create a matlab inferior process buffer.
|
||||
If there is not a current inferior-process-buffer in SESSION then
|
||||
create. Return the initialized session."
|
||||
(org-babel-octave-initiate-session session params 'matlab))
|
||||
|
||||
(defun org-babel-octave-initiate-session (&optional session params matlabp)
|
||||
"Create an octave inferior process buffer.
|
||||
If there is not a current inferior-process-buffer in SESSION then
|
||||
create. Return the initialized session."
|
||||
(if matlabp (require 'matlab) (or (require 'octave-inf nil 'noerror)
|
||||
(require 'octave)))
|
||||
(unless (string= session "none")
|
||||
(let ((session (or session
|
||||
(if matlabp "*Inferior Matlab*" "*Inferior Octave*"))))
|
||||
(if (org-babel-comint-buffer-livep session) session
|
||||
(save-window-excursion
|
||||
(if matlabp (unless org-babel-matlab-with-emacs-link (matlab-shell))
|
||||
(run-octave))
|
||||
(rename-buffer (if (bufferp session) (buffer-name session)
|
||||
(if (stringp session) session (buffer-name))))
|
||||
(current-buffer))))))
|
||||
|
||||
(defun org-babel-octave-evaluate
|
||||
(session body result-type &optional matlabp)
|
||||
"Pass BODY to the octave process in SESSION.
|
||||
If RESULT-TYPE equals `output' then return the outputs of the
|
||||
statements in BODY, if RESULT-TYPE equals `value' then return the
|
||||
value of the last statement in BODY, as elisp."
|
||||
(if session
|
||||
(org-babel-octave-evaluate-session session body result-type matlabp)
|
||||
(org-babel-octave-evaluate-external-process body result-type matlabp)))
|
||||
|
||||
(defun org-babel-octave-evaluate-external-process (body result-type matlabp)
|
||||
"Evaluate BODY in an external octave process."
|
||||
(let ((cmd (if matlabp
|
||||
org-babel-matlab-shell-command
|
||||
org-babel-octave-shell-command)))
|
||||
(case result-type
|
||||
(output (org-babel-eval cmd body))
|
||||
(value (let ((tmp-file (org-babel-temp-file "octave-")))
|
||||
(org-babel-eval
|
||||
cmd
|
||||
(format org-babel-octave-wrapper-method body
|
||||
(org-babel-process-file-name tmp-file 'noquote)
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-octave-import-elisp-from-file tmp-file))))))
|
||||
|
||||
(defun org-babel-octave-evaluate-session
|
||||
(session body result-type &optional matlabp)
|
||||
"Evaluate BODY in SESSION."
|
||||
(let* ((tmp-file (org-babel-temp-file (if matlabp "matlab-" "octave-")))
|
||||
(wait-file (org-babel-temp-file "matlab-emacs-link-wait-signal-"))
|
||||
(full-body
|
||||
(case result-type
|
||||
(output
|
||||
(mapconcat
|
||||
#'org-babel-chomp
|
||||
(list body org-babel-octave-eoe-indicator) "\n"))
|
||||
(value
|
||||
(if (and matlabp org-babel-matlab-with-emacs-link)
|
||||
(concat
|
||||
(format org-babel-matlab-emacs-link-wrapper-method
|
||||
body
|
||||
(org-babel-process-file-name tmp-file 'noquote)
|
||||
(org-babel-process-file-name tmp-file 'noquote) wait-file) "\n")
|
||||
(mapconcat
|
||||
#'org-babel-chomp
|
||||
(list (format org-babel-octave-wrapper-method
|
||||
body
|
||||
(org-babel-process-file-name tmp-file 'noquote)
|
||||
(org-babel-process-file-name tmp-file 'noquote))
|
||||
org-babel-octave-eoe-indicator) "\n")))))
|
||||
(raw (if (and matlabp org-babel-matlab-with-emacs-link)
|
||||
(save-window-excursion
|
||||
(with-temp-buffer
|
||||
(insert full-body)
|
||||
(write-region "" 'ignored wait-file nil nil nil 'excl)
|
||||
(matlab-shell-run-region (point-min) (point-max))
|
||||
(message "Waiting for Matlab Emacs Link")
|
||||
(while (file-exists-p wait-file) (sit-for 0.01))
|
||||
"")) ;; matlab-shell-run-region doesn't seem to
|
||||
;; make *matlab* buffer contents easily
|
||||
;; available, so :results output currently
|
||||
;; won't work
|
||||
(org-babel-comint-with-output
|
||||
(session
|
||||
(if matlabp
|
||||
org-babel-octave-eoe-indicator
|
||||
org-babel-octave-eoe-output)
|
||||
t full-body)
|
||||
(insert full-body) (comint-send-input nil t)))) results)
|
||||
(case result-type
|
||||
(value
|
||||
(org-babel-octave-import-elisp-from-file tmp-file))
|
||||
(output
|
||||
(progn
|
||||
(setq results
|
||||
(if matlabp
|
||||
(cdr (reverse (delq "" (mapcar
|
||||
#'org-babel-octave-read-string
|
||||
(mapcar #'org-babel-trim raw)))))
|
||||
(cdr (member org-babel-octave-eoe-output
|
||||
(reverse (mapcar
|
||||
#'org-babel-octave-read-string
|
||||
(mapcar #'org-babel-trim raw)))))))
|
||||
(mapconcat #'identity (reverse results) "\n"))))))
|
||||
|
||||
(defun org-babel-octave-import-elisp-from-file (file-name)
|
||||
"Import data from FILE-NAME.
|
||||
This removes initial blank and comment lines and then calls
|
||||
`org-babel-import-elisp-from-file'."
|
||||
(let ((temp-file (org-babel-temp-file "octave-matlab-")) beg end)
|
||||
(with-temp-file temp-file
|
||||
(insert-file-contents file-name)
|
||||
(re-search-forward "^[ \t]*[^# \t]" nil t)
|
||||
(if (< (setq beg (point-min))
|
||||
(setq end (point-at-bol)))
|
||||
(delete-region beg end)))
|
||||
(org-babel-import-elisp-from-file temp-file '(16))))
|
||||
|
||||
(defun org-babel-octave-read-string (string)
|
||||
"Strip \\\"s from around octave string."
|
||||
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(provide 'ob-octave)
|
||||
|
||||
|
||||
|
||||
;;; ob-octave.el ends here
|
72
elpa/org-20160919/ob-org.el
Normal file
72
elpa/org-20160919/ob-org.el
Normal file
@ -0,0 +1,72 @@
|
||||
;;; ob-org.el --- org-babel functions for org code block evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This is the simplest of code blocks, where upon evaluation the
|
||||
;; contents of the code block are returned in a raw result.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function org-export-string-as "ox"
|
||||
(string backend &optional body-only ext-plist))
|
||||
|
||||
(defvar org-babel-default-header-args:org
|
||||
'((:results . "raw silent") (:exports . "code"))
|
||||
"Default arguments for evaluating a org source block.")
|
||||
|
||||
(defvar org-babel-org-default-header
|
||||
"#+TITLE: default empty header\n"
|
||||
"Default header inserted during export of org blocks.")
|
||||
|
||||
(defun org-babel-expand-body:org (body params)
|
||||
(dolist (var (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(setq body (replace-regexp-in-string
|
||||
(regexp-quote (format "$%s" (car var)))
|
||||
(format "%s" (cdr var))
|
||||
body nil 'literal)))
|
||||
body)
|
||||
|
||||
(defun org-babel-execute:org (body params)
|
||||
"Execute a block of Org code with.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(body (org-babel-expand-body:org
|
||||
(replace-regexp-in-string "^," "" body) params)))
|
||||
(cond
|
||||
((member "latex" result-params)
|
||||
(org-export-string-as (concat "#+Title: \n" body) 'latex t))
|
||||
((member "html" result-params) (org-export-string-as body 'html t))
|
||||
((member "ascii" result-params) (org-export-string-as body 'ascii t))
|
||||
(t body))))
|
||||
|
||||
(defun org-babel-prep-session:org (session params)
|
||||
"Return an error because org does not support sessions."
|
||||
(error "Org does not support sessions"))
|
||||
|
||||
(provide 'ob-org)
|
||||
|
||||
|
||||
|
||||
;;; ob-org.el ends here
|
158
elpa/org-20160919/ob-perl.el
Normal file
158
elpa/org-20160919/ob-perl.el
Normal file
@ -0,0 +1,158 @@
|
||||
;;; ob-perl.el --- org-babel functions for perl evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Dan Davison
|
||||
;; Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating perl source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("perl" . "pl"))
|
||||
|
||||
(defvar org-babel-default-header-args:perl '())
|
||||
|
||||
(defvar org-babel-perl-command "perl"
|
||||
"Name of command to use for executing perl code.")
|
||||
|
||||
(defun org-babel-execute:perl (body params)
|
||||
"Execute a block of Perl code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((session (cdr (assoc :session params)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:perl params)))
|
||||
(session (org-babel-perl-initiate-session session)))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-perl-evaluate session full-body result-type result-params)
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:perl (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS."
|
||||
(error "Sessions are not supported for Perl"))
|
||||
|
||||
(defun org-babel-variable-assignments:perl (params)
|
||||
"Return list of perl statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(org-babel-perl--var-to-perl (cdr pair) (car pair)))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defvar org-babel-perl-var-wrap "q(%s)"
|
||||
"Wrapper for variables inserted into Perl code.")
|
||||
|
||||
(defvar org-babel-perl--lvl)
|
||||
(defun org-babel-perl--var-to-perl (var &optional varn)
|
||||
"Convert an elisp value to a perl variable.
|
||||
The elisp value, VAR, is converted to a string of perl source code
|
||||
specifying a var of the same value."
|
||||
(if varn
|
||||
(let ((org-babel-perl--lvl 0) (lvar (listp var)) prefix)
|
||||
(concat "my $" (symbol-name varn) "=" (when lvar "\n")
|
||||
(org-babel-perl--var-to-perl var)
|
||||
";\n"))
|
||||
(let ((prefix (make-string (* 2 org-babel-perl--lvl) ?\ )))
|
||||
(concat prefix
|
||||
(if (listp var)
|
||||
(let ((org-babel-perl--lvl (1+ org-babel-perl--lvl)))
|
||||
(concat "[\n"
|
||||
(mapconcat #'org-babel-perl--var-to-perl var "")
|
||||
prefix "]"))
|
||||
(format "q(%s)" var))
|
||||
(unless (zerop org-babel-perl--lvl) ",\n")))))
|
||||
|
||||
(defvar org-babel-perl-buffers '(:default . nil))
|
||||
|
||||
(defun org-babel-perl-initiate-session (&optional session params)
|
||||
"Return nil because sessions are not supported by perl."
|
||||
nil)
|
||||
|
||||
(defvar org-babel-perl-wrapper-method "{
|
||||
my $babel_sub = sub {
|
||||
%s
|
||||
};
|
||||
open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/);
|
||||
my $rv = &$babel_sub();
|
||||
my $rt = ref $rv;
|
||||
select $BOH;
|
||||
if (qq(ARRAY) eq $rt) {
|
||||
local $\\=$/;
|
||||
local $,=qq(\t);
|
||||
foreach my $rv ( @$rv ) {
|
||||
my $rt = ref $rv;
|
||||
if (qq(ARRAY) eq $rt) {
|
||||
print @$rv;
|
||||
} else {
|
||||
print $rv;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print $rv;
|
||||
}
|
||||
}")
|
||||
|
||||
(defvar org-babel-perl-preface nil)
|
||||
|
||||
(defvar org-babel-perl-pp-wrapper-method
|
||||
nil)
|
||||
|
||||
(defun org-babel-perl-evaluate (session ibody &optional result-type result-params)
|
||||
"Pass BODY to the Perl process in SESSION.
|
||||
If RESULT-TYPE equals `output' then return a list of the outputs
|
||||
of the statements in BODY, if RESULT-TYPE equals `value' then
|
||||
return the value of the last statement in BODY, as elisp."
|
||||
(when session (error "Sessions are not supported for Perl"))
|
||||
(let* ((body (concat org-babel-perl-preface ibody))
|
||||
(tmp-file (org-babel-temp-file "perl-"))
|
||||
(tmp-babel-file (org-babel-process-file-name
|
||||
tmp-file 'noquote)))
|
||||
(let ((results
|
||||
(case result-type
|
||||
(output
|
||||
(with-temp-file tmp-file
|
||||
(insert
|
||||
(org-babel-eval org-babel-perl-command body))
|
||||
(buffer-string)))
|
||||
(value
|
||||
(org-babel-eval org-babel-perl-command
|
||||
(format org-babel-perl-wrapper-method
|
||||
body tmp-babel-file))))))
|
||||
(when results
|
||||
(org-babel-result-cond result-params
|
||||
(org-babel-eval-read-file tmp-file)
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)))))))
|
||||
|
||||
(provide 'ob-perl)
|
||||
|
||||
|
||||
|
||||
;;; ob-perl.el ends here
|
189
elpa/org-20160919/ob-picolisp.el
Normal file
189
elpa/org-20160919/ob-picolisp.el
Normal file
@ -0,0 +1,189 @@
|
||||
;;; ob-picolisp.el --- org-babel functions for picolisp evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Thorsten Jolitz
|
||||
;; Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This library enables the use of PicoLisp in the multi-language
|
||||
;; programming framework Org-Babel. PicoLisp is a minimal yet
|
||||
;; fascinating lisp dialect and a highly productive application
|
||||
;; framework for web-based client-server applications on top of
|
||||
;; object-oriented databases. A good way to learn PicoLisp is to first
|
||||
;; read Paul Grahams essay "The hundred year language"
|
||||
;; (http://www.paulgraham.com/hundred.html) and then study the various
|
||||
;; documents and essays published in the PicoLisp wiki
|
||||
;; (http://picolisp.com/5000/-2.html). PicoLisp is included in some
|
||||
;; GNU/Linux Distributions, and can be downloaded here:
|
||||
;; http://software-lab.de/down.html. It ships with a picolisp-mode and
|
||||
;; a inferior-picolisp-mode for Emacs (to be found in the /lib/el/
|
||||
;; directory).
|
||||
|
||||
;; Although it might seem more natural to use Emacs Lisp for most
|
||||
;; Lisp-based programming tasks inside Org-Mode, an Emacs library
|
||||
;; written in Emacs Lisp, PicoLisp has at least two outstanding
|
||||
;; features that make it a valuable addition to Org-Babel:
|
||||
|
||||
;; PicoLisp _is_ an object-oriented database with a Prolog-based query
|
||||
;; language implemented in PicoLisp (Pilog). Database objects are
|
||||
;; first-class members of the language.
|
||||
|
||||
;; PicoLisp is an extremely productive framework for the development
|
||||
;; of interactive web-applications (on top of a database).
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'comint)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function run-picolisp "ext:inferior-picolisp" (cmd))
|
||||
(defvar org-babel-tangle-lang-exts) ;; Autoloaded
|
||||
|
||||
;; optionally define a file extension for this language
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("picolisp" . "l"))
|
||||
|
||||
;;; interferes with settings in org-babel buffer?
|
||||
;; optionally declare default header arguments for this language
|
||||
;; (defvar org-babel-default-header-args:picolisp
|
||||
;; '((:colnames . "no"))
|
||||
;; "Default arguments for evaluating a picolisp source block.")
|
||||
|
||||
(defvar org-babel-picolisp-eoe "org-babel-picolisp-eoe"
|
||||
"String to indicate that evaluation has completed.")
|
||||
|
||||
(defcustom org-babel-picolisp-cmd "pil"
|
||||
"Name of command used to evaluate picolisp blocks."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-expand-body:picolisp (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(print-level nil) (print-length nil))
|
||||
(if (> (length vars) 0)
|
||||
(concat "(prog (let ("
|
||||
(mapconcat
|
||||
(lambda (var)
|
||||
(format "%S '%S)"
|
||||
(print (car var))
|
||||
(print (cdr var))))
|
||||
vars "\n ")
|
||||
" \n" body ") )")
|
||||
body)))
|
||||
|
||||
(defun org-babel-execute:picolisp (body params)
|
||||
"Execute a block of Picolisp code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Picolisp source code block")
|
||||
(let* (
|
||||
;; Name of the session or "none".
|
||||
(session-name (cdr (assoc :session params)))
|
||||
;; Set the session if the session variable is non-nil.
|
||||
(session (org-babel-picolisp-initiate-session session-name))
|
||||
;; Either OUTPUT or VALUE which should behave as described above.
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
;; Expand the body with `org-babel-expand-body:picolisp'.
|
||||
(full-body (org-babel-expand-body:picolisp body params))
|
||||
;; Wrap body appropriately for the type of evaluation and results.
|
||||
(wrapped-body
|
||||
(cond
|
||||
((or (member "code" result-params)
|
||||
(member "pp" result-params))
|
||||
(format "(pretty (out \"/dev/null\" %s))" full-body))
|
||||
((and (member "value" result-params) (not session))
|
||||
(format "(print (out \"/dev/null\" %s))" full-body))
|
||||
((member "value" result-params)
|
||||
(format "(out \"/dev/null\" %s)" full-body))
|
||||
(t full-body)))
|
||||
(result
|
||||
(if (not (string= session-name "none"))
|
||||
;; Session based evaluation.
|
||||
(mapconcat ;; <- joins the list back into a single string
|
||||
#'identity
|
||||
(butlast ;; <- remove the org-babel-picolisp-eoe line
|
||||
(delq nil
|
||||
(mapcar
|
||||
(lambda (line)
|
||||
(org-babel-chomp ;; Remove trailing newlines.
|
||||
(when (> (length line) 0) ;; Remove empty lines.
|
||||
(cond
|
||||
;; Remove leading "-> " from return values.
|
||||
((and (>= (length line) 3)
|
||||
(string= "-> " (substring line 0 3)))
|
||||
(substring line 3))
|
||||
;; Remove trailing "-> <<return-value>>" on the
|
||||
;; last line of output.
|
||||
((and (member "output" result-params)
|
||||
(string-match-p "->" line))
|
||||
(substring line 0 (string-match "->" line)))
|
||||
(t line)
|
||||
)
|
||||
;;(if (and (>= (length line) 3);Remove leading "<-"
|
||||
;; (string= "-> " (substring line 0 3)))
|
||||
;; (substring line 3)
|
||||
;; line)
|
||||
)))
|
||||
;; Returns a list of the output of each evaluated exp.
|
||||
(org-babel-comint-with-output
|
||||
(session org-babel-picolisp-eoe)
|
||||
(insert wrapped-body) (comint-send-input)
|
||||
(insert "'" org-babel-picolisp-eoe)
|
||||
(comint-send-input)))))
|
||||
"\n")
|
||||
;; external evaluation
|
||||
(let ((script-file (org-babel-temp-file "picolisp-script-")))
|
||||
(with-temp-file script-file
|
||||
(insert (concat wrapped-body "(bye)")))
|
||||
(org-babel-eval
|
||||
(format "%s %s"
|
||||
org-babel-picolisp-cmd
|
||||
(org-babel-process-file-name script-file))
|
||||
"")))))
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(read result))))
|
||||
|
||||
(defun org-babel-picolisp-initiate-session (&optional session-name)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
(unless (string= session-name "none")
|
||||
(require 'inferior-picolisp)
|
||||
;; provide a reasonable default session name
|
||||
(let ((session (or session-name "*inferior-picolisp*")))
|
||||
;; check if we already have a live session by this name
|
||||
(if (org-babel-comint-buffer-livep session)
|
||||
(get-buffer session)
|
||||
(save-window-excursion
|
||||
(run-picolisp org-babel-picolisp-cmd)
|
||||
(rename-buffer session-name)
|
||||
(current-buffer))))))
|
||||
|
||||
(provide 'ob-picolisp)
|
||||
|
||||
|
||||
|
||||
;;; ob-picolisp.el ends here
|
85
elpa/org-20160919/ob-plantuml.el
Normal file
85
elpa/org-20160919/ob-plantuml.el
Normal file
@ -0,0 +1,85 @@
|
||||
;;; ob-plantuml.el --- org-babel functions for plantuml evaluation
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Zhang Weize
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating plantuml script.
|
||||
;;
|
||||
;; Inspired by Ian Yang's org-export-blocks-format-plantuml
|
||||
;; http://www.emacswiki.org/emacs/org-export-blocks-format-plantuml.el
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; plantuml | http://plantuml.sourceforge.net/
|
||||
;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:plantuml
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments for evaluating a plantuml source block.")
|
||||
|
||||
(defcustom org-plantuml-jar-path ""
|
||||
"Path to the plantuml.jar file."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defun org-babel-execute:plantuml (body params)
|
||||
"Execute a block of plantuml code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(out-file (or (cdr (assoc :file params))
|
||||
(error "PlantUML requires a \":file\" header argument")))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(in-file (org-babel-temp-file "plantuml-"))
|
||||
(java (or (cdr (assoc :java params)) ""))
|
||||
(cmd (if (string= "" org-plantuml-jar-path)
|
||||
(error "`org-plantuml-jar-path' is not set")
|
||||
(concat "java " java " -jar "
|
||||
(shell-quote-argument
|
||||
(expand-file-name org-plantuml-jar-path))
|
||||
(if (string= (file-name-extension out-file) "svg")
|
||||
" -tsvg" "")
|
||||
(if (string= (file-name-extension out-file) "eps")
|
||||
" -teps" "")
|
||||
" -p " cmdline " < "
|
||||
(org-babel-process-file-name in-file)
|
||||
" > "
|
||||
(org-babel-process-file-name out-file)))))
|
||||
(unless (file-exists-p org-plantuml-jar-path)
|
||||
(error "Could not find plantuml.jar at %s" org-plantuml-jar-path))
|
||||
(with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml")))
|
||||
(message "%s" cmd) (org-babel-eval cmd "")
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:plantuml (session params)
|
||||
"Return an error because plantuml does not support sessions."
|
||||
(error "Plantuml does not support sessions"))
|
||||
|
||||
(provide 'ob-plantuml)
|
||||
|
||||
|
||||
|
||||
;;; ob-plantuml.el ends here
|
197
elpa/org-20160919/ob-processing.el
Normal file
197
elpa/org-20160919/ob-processing.el
Normal file
@ -0,0 +1,197 @@
|
||||
;;; ob-processing.el --- Babel functions for evaluation of processing
|
||||
|
||||
;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Jarmo Hurri (adapted from ob-asymptote.el written by Eric Schulte)
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Babel support for evaluating processing source code.
|
||||
;;
|
||||
;; This differs from most standard languages in that
|
||||
;;
|
||||
;; 1) there is no such thing as a "session" in processing
|
||||
;;
|
||||
;; 2) results can only be exported as html; in this case, the
|
||||
;; processing code is embedded via a file into a javascript block
|
||||
;; using the processing.js module; the script then draws the
|
||||
;; resulting output when the web page is viewed in a browser; note
|
||||
;; that the user is responsible for making sure that processing.js
|
||||
;; is available on the website
|
||||
;;
|
||||
;; 3) it is possible to interactively view the sketch of the
|
||||
;; Processing code block via Processing 2.0 Emacs mode, using
|
||||
;; `org-babel-processing-view-sketch'. You can bind this command
|
||||
;; to, e.g., C-c C-v C-k with
|
||||
;;
|
||||
;; (define-key org-babel-map (kbd "C-k") 'org-babel-processing-view-sketch)
|
||||
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - processing2-emacs mode :: https://github.com/ptrv/processing2-emacs
|
||||
;; - Processing.js module :: http://processingjs.org/
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'sha1)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function processing-sketch-run "ext:processing-mode" ())
|
||||
|
||||
(defvar org-babel-temporary-directory)
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("processing" . "pde"))
|
||||
|
||||
;; Default header tags depend on whether exporting html or not; if not
|
||||
;; exporting html, then no results are produced; otherwise results are
|
||||
;; HTML.
|
||||
(defvar org-babel-default-header-args:processing
|
||||
'((:results . "html") (:exports . "results"))
|
||||
"Default arguments when evaluating a Processing source block.")
|
||||
|
||||
(defvar org-babel-processing-processing-js-filename "processing.js"
|
||||
"Filename of the processing.js file.")
|
||||
|
||||
(defun org-babel-processing-view-sketch ()
|
||||
"Show the sketch of the Processing block under point in an external viewer."
|
||||
(interactive)
|
||||
(require 'processing-mode)
|
||||
(let ((info (org-babel-get-src-block-info)))
|
||||
(if (string= (nth 0 info) "processing")
|
||||
(let* ((body (nth 1 info))
|
||||
(params (org-babel-process-params (nth 2 info)))
|
||||
(sketch-code
|
||||
(org-babel-expand-body:generic
|
||||
body
|
||||
params
|
||||
(org-babel-variable-assignments:processing params))))
|
||||
;; Note: sketch filename can not contain a hyphen, since it
|
||||
;; has to be a valid java class name; for this reason
|
||||
;; make-temp-file is repeated until no hyphen is in the
|
||||
;; name; also sketch dir name must be the same as the
|
||||
;; basename of the sketch file.
|
||||
(let* ((temporary-file-directory org-babel-temporary-directory)
|
||||
(sketch-dir
|
||||
(let (sketch-dir-candidate)
|
||||
(while
|
||||
(progn
|
||||
(setq sketch-dir-candidate
|
||||
(make-temp-file "processing" t))
|
||||
(when (org-string-match-p
|
||||
"-"
|
||||
(file-name-nondirectory sketch-dir-candidate))
|
||||
(delete-directory sketch-dir-candidate)
|
||||
t)))
|
||||
sketch-dir-candidate))
|
||||
(sketch-filename
|
||||
(concat sketch-dir
|
||||
"/"
|
||||
(file-name-nondirectory sketch-dir)
|
||||
".pde")))
|
||||
(with-temp-file sketch-filename (insert sketch-code))
|
||||
(find-file sketch-filename)
|
||||
(processing-sketch-run)
|
||||
(kill-buffer)))
|
||||
(message "Not inside a Processing source block."))))
|
||||
|
||||
(defun org-babel-execute:processing (body params)
|
||||
"Execute a block of Processing code.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((sketch-code
|
||||
(org-babel-expand-body:generic
|
||||
body
|
||||
params
|
||||
(org-babel-variable-assignments:processing params))))
|
||||
;; Results are HTML.
|
||||
(let ((sketch-canvas-id (concat "ob-" (sha1 sketch-code))))
|
||||
(concat "<script src=\""
|
||||
org-babel-processing-processing-js-filename
|
||||
"\"></script>\n <script type=\"text/processing\""
|
||||
" data-processing-target=\""
|
||||
sketch-canvas-id
|
||||
"\">\n"
|
||||
sketch-code
|
||||
"\n</script> <canvas id=\""
|
||||
sketch-canvas-id
|
||||
"\"></canvas>"))))
|
||||
|
||||
(defun org-babel-prep-session:processing (session params)
|
||||
"Return an error if the :session header argument is set.
|
||||
Processing does not support sessions"
|
||||
(error "Processing does not support sessions"))
|
||||
|
||||
(defun org-babel-variable-assignments:processing (params)
|
||||
"Return list of processing statements assigning the block's variables."
|
||||
(mapcar #'org-babel-processing-var-to-processing
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-processing-var-to-processing (pair)
|
||||
"Convert an elisp value into a Processing variable.
|
||||
The elisp value PAIR is converted into Processing code specifying
|
||||
a variable of the same value."
|
||||
(let ((var (car pair))
|
||||
(val (let ((v (cdr pair)))
|
||||
(if (symbolp v) (symbol-name v) v))))
|
||||
(cond
|
||||
((integerp val)
|
||||
(format "int %S=%S;" var val))
|
||||
((floatp val)
|
||||
(format "float %S=%S;" var val))
|
||||
((stringp val)
|
||||
(format "String %S=\"%s\";" var val))
|
||||
((and (listp val) (not (listp (car val))))
|
||||
(let* ((type (org-babel-processing-define-type val))
|
||||
(fmt (if (eq 'String type) "\"%s\"" "%s"))
|
||||
(vect (mapconcat (lambda (e) (format fmt e)) val ", ")))
|
||||
(format "%s[] %S={%s};" type var vect)))
|
||||
((listp val)
|
||||
(let* ((type (org-babel-processing-define-type val))
|
||||
(fmt (if (eq 'String type) "\"%s\"" "%s"))
|
||||
(array (mapconcat (lambda (row)
|
||||
(concat "{"
|
||||
(mapconcat (lambda (e) (format fmt e))
|
||||
row ", ")
|
||||
"}"))
|
||||
val ",")))
|
||||
(format "%S[][] %S={%s};" type var array))))))
|
||||
|
||||
(defun org-babel-processing-define-type (data)
|
||||
"Determine type of DATA.
|
||||
|
||||
DATA is a list. Return type as a symbol.
|
||||
|
||||
The type is `String' if any element in DATA is
|
||||
a string. Otherwise, it is either `float', if some elements are
|
||||
floats, or `int'."
|
||||
(let* ((type 'int)
|
||||
find-type ; For byte-compiler.
|
||||
(find-type
|
||||
(lambda (row)
|
||||
(dolist (e row type)
|
||||
(cond ((listp e) (setq type (funcall find-type e)))
|
||||
((stringp e) (throw 'exit 'String))
|
||||
((floatp e) (setq type 'float)))))))
|
||||
(catch 'exit (funcall find-type data))))
|
||||
|
||||
(provide 'ob-processing)
|
||||
|
||||
;;; ob-processing.el ends here
|
346
elpa/org-20160919/ob-python.el
Normal file
346
elpa/org-20160919/ob-python.el
Normal file
@ -0,0 +1,346 @@
|
||||
;;; ob-python.el --- org-babel functions for python evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Eric Schulte
|
||||
;; Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating python source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-remove-indentation "org" )
|
||||
(declare-function py-shell "ext:python-mode" (&optional argprompt))
|
||||
(declare-function py-toggle-shells "ext:python-mode" (arg))
|
||||
(declare-function run-python "ext:python" (&optional cmd dedicated show))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
|
||||
|
||||
(defvar org-babel-default-header-args:python '())
|
||||
|
||||
(defcustom org-babel-python-command "python"
|
||||
"Name of the command for executing Python code."
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-python-mode
|
||||
(if (or (featurep 'xemacs) (featurep 'python-mode)) 'python-mode 'python)
|
||||
"Preferred python mode for use in running python interactively.
|
||||
This will typically be either `python' or `python-mode'."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'symbol)
|
||||
|
||||
(defcustom org-babel-python-hline-to "None"
|
||||
"Replace hlines in incoming tables with this when translating to python."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-python-None-to 'hline
|
||||
"Replace `None' in python tables with this before returning."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'symbol)
|
||||
|
||||
(defun org-babel-execute:python (body params)
|
||||
"Execute a block of Python code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((session (org-babel-python-initiate-session
|
||||
(cdr (assoc :session params))))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(return-val (when (and (eq result-type 'value) (not session))
|
||||
(cdr (assoc :return params))))
|
||||
(preamble (cdr (assoc :preamble params)))
|
||||
(org-babel-python-command
|
||||
(or (cdr (assoc :python params)) org-babel-python-command))
|
||||
(full-body
|
||||
(org-babel-expand-body:generic
|
||||
(concat body (if return-val (format "\nreturn %s" return-val) ""))
|
||||
params (org-babel-variable-assignments:python params)))
|
||||
(result (org-babel-python-evaluate
|
||||
session full-body result-type result-params preamble)))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:python (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS.
|
||||
VARS contains resolved variable references"
|
||||
(let* ((session (org-babel-python-initiate-session session))
|
||||
(var-lines
|
||||
(org-babel-variable-assignments:python params)))
|
||||
(org-babel-comint-in-buffer session
|
||||
(mapc (lambda (var)
|
||||
(end-of-line 1) (insert var) (comint-send-input)
|
||||
(org-babel-comint-wait-for-output session)) var-lines))
|
||||
session))
|
||||
|
||||
(defun org-babel-load-session:python (session body params)
|
||||
"Load BODY into SESSION."
|
||||
(save-window-excursion
|
||||
(let ((buffer (org-babel-prep-session:python session params)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert (org-babel-chomp body)))
|
||||
buffer)))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-variable-assignments:python (params)
|
||||
"Return a list of Python statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-python-var-to-python (cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-python-var-to-python (var)
|
||||
"Convert an elisp value to a python variable.
|
||||
Convert an elisp value, VAR, into a string of python source code
|
||||
specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
|
||||
(if (equal var 'hline)
|
||||
org-babel-python-hline-to
|
||||
(format
|
||||
(if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
|
||||
(if (stringp var) (substring-no-properties var) var)))))
|
||||
|
||||
(defun org-babel-python-table-or-string (results)
|
||||
"Convert RESULTS into an appropriate elisp value.
|
||||
If the results look like a list or tuple, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(let ((res (org-babel-script-escape results)))
|
||||
(if (listp res)
|
||||
(mapcar (lambda (el) (if (equal el 'None)
|
||||
org-babel-python-None-to el))
|
||||
res)
|
||||
res)))
|
||||
|
||||
(defvar org-babel-python-buffers '((:default . "*Python*")))
|
||||
|
||||
(defun org-babel-python-session-buffer (session)
|
||||
"Return the buffer associated with SESSION."
|
||||
(cdr (assoc session org-babel-python-buffers)))
|
||||
|
||||
(defun org-babel-python-with-earmuffs (session)
|
||||
(let ((name (if (stringp session) session (format "%s" session))))
|
||||
(if (and (string= "*" (substring name 0 1))
|
||||
(string= "*" (substring name (- (length name) 1))))
|
||||
name
|
||||
(format "*%s*" name))))
|
||||
|
||||
(defun org-babel-python-without-earmuffs (session)
|
||||
(let ((name (if (stringp session) session (format "%s" session))))
|
||||
(if (and (string= "*" (substring name 0 1))
|
||||
(string= "*" (substring name (- (length name) 1))))
|
||||
(substring name 1 (- (length name) 1))
|
||||
name)))
|
||||
|
||||
(defvar py-default-interpreter)
|
||||
(defvar py-which-bufname)
|
||||
(defvar python-shell-buffer-name)
|
||||
(defun org-babel-python-initiate-session-by-key (&optional session)
|
||||
"Initiate a python session.
|
||||
If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
(require org-babel-python-mode)
|
||||
(save-window-excursion
|
||||
(let* ((session (if session (intern session) :default))
|
||||
(python-buffer (org-babel-python-session-buffer session))
|
||||
(cmd (if (member system-type '(cygwin windows-nt ms-dos))
|
||||
(concat org-babel-python-command " -i")
|
||||
org-babel-python-command)))
|
||||
(cond
|
||||
((and (eq 'python org-babel-python-mode)
|
||||
(fboundp 'run-python)) ; python.el
|
||||
(if (not (version< "24.1" emacs-version))
|
||||
(run-python cmd)
|
||||
(unless python-buffer
|
||||
(setq python-buffer (org-babel-python-with-earmuffs session)))
|
||||
(let ((python-shell-buffer-name
|
||||
(org-babel-python-without-earmuffs python-buffer)))
|
||||
(run-python cmd))))
|
||||
((and (eq 'python-mode org-babel-python-mode)
|
||||
(fboundp 'py-shell)) ; python-mode.el
|
||||
;; Make sure that py-which-bufname is initialized, as otherwise
|
||||
;; it will be overwritten the first time a Python buffer is
|
||||
;; created.
|
||||
(py-toggle-shells py-default-interpreter)
|
||||
;; `py-shell' creates a buffer whose name is the value of
|
||||
;; `py-which-bufname' with '*'s at the beginning and end
|
||||
(let* ((bufname (if (and python-buffer (buffer-live-p python-buffer))
|
||||
(replace-regexp-in-string ;; zap surrounding *
|
||||
"^\\*\\([^*]+\\)\\*$" "\\1" python-buffer)
|
||||
(concat "Python-" (symbol-name session))))
|
||||
(py-which-bufname bufname))
|
||||
(py-shell)
|
||||
(setq python-buffer (org-babel-python-with-earmuffs bufname))))
|
||||
(t
|
||||
(error "No function available for running an inferior Python")))
|
||||
(setq org-babel-python-buffers
|
||||
(cons (cons session python-buffer)
|
||||
(assq-delete-all session org-babel-python-buffers)))
|
||||
session)))
|
||||
|
||||
(defun org-babel-python-initiate-session (&optional session params)
|
||||
"Create a session named SESSION according to PARAMS."
|
||||
(unless (string= session "none")
|
||||
(org-babel-python-session-buffer
|
||||
(org-babel-python-initiate-session-by-key session))))
|
||||
|
||||
(defvar org-babel-python-eoe-indicator "'org_babel_python_eoe'"
|
||||
"A string to indicate that evaluation has completed.")
|
||||
(defconst org-babel-python-wrapper-method
|
||||
"
|
||||
def main():
|
||||
%s
|
||||
|
||||
open('%s', 'w').write( str(main()) )")
|
||||
(defconst org-babel-python-pp-wrapper-method
|
||||
"
|
||||
import pprint
|
||||
def main():
|
||||
%s
|
||||
|
||||
open('%s', 'w').write( pprint.pformat(main()) )")
|
||||
|
||||
(defun org-babel-python-evaluate
|
||||
(session body &optional result-type result-params preamble)
|
||||
"Evaluate BODY as Python code."
|
||||
(if session
|
||||
(org-babel-python-evaluate-session
|
||||
session body result-type result-params)
|
||||
(org-babel-python-evaluate-external-process
|
||||
body result-type result-params preamble)))
|
||||
|
||||
(defun org-babel-python-evaluate-external-process
|
||||
(body &optional result-type result-params preamble)
|
||||
"Evaluate BODY in external python process.
|
||||
If RESULT-TYPE equals `output' then return standard output as a
|
||||
string. If RESULT-TYPE equals `value' then return the value of the
|
||||
last statement in BODY, as elisp."
|
||||
(let ((raw
|
||||
(case result-type
|
||||
(output (org-babel-eval org-babel-python-command
|
||||
(concat (if preamble (concat preamble "\n"))
|
||||
body)))
|
||||
(value (let ((tmp-file (org-babel-temp-file "python-")))
|
||||
(org-babel-eval
|
||||
org-babel-python-command
|
||||
(concat
|
||||
(if preamble (concat preamble "\n") "")
|
||||
(format
|
||||
(if (member "pp" result-params)
|
||||
org-babel-python-pp-wrapper-method
|
||||
org-babel-python-wrapper-method)
|
||||
(mapconcat
|
||||
(lambda (line) (format "\t%s" line))
|
||||
(split-string
|
||||
(org-remove-indentation
|
||||
(org-babel-trim body))
|
||||
"[\r\n]") "\n")
|
||||
(org-babel-process-file-name tmp-file 'noquote))))
|
||||
(org-babel-eval-read-file tmp-file))))))
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-python-table-or-string (org-babel-trim raw)))))
|
||||
|
||||
(defun org-babel-python-evaluate-session
|
||||
(session body &optional result-type result-params)
|
||||
"Pass BODY to the Python process in SESSION.
|
||||
If RESULT-TYPE equals `output' then return standard output as a
|
||||
string. If RESULT-TYPE equals `value' then return the value of the
|
||||
last statement in BODY, as elisp."
|
||||
(let* ((send-wait (lambda () (comint-send-input nil t) (sleep-for 0 5)))
|
||||
(dump-last-value
|
||||
(lambda
|
||||
(tmp-file pp)
|
||||
(mapc
|
||||
(lambda (statement) (insert statement) (funcall send-wait))
|
||||
(if pp
|
||||
(list
|
||||
"import pprint"
|
||||
(format "open('%s', 'w').write(pprint.pformat(_))"
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(list (format "open('%s', 'w').write(str(_))"
|
||||
(org-babel-process-file-name tmp-file
|
||||
'noquote)))))))
|
||||
(input-body (lambda (body)
|
||||
(mapc (lambda (line) (insert line) (funcall send-wait))
|
||||
(split-string body "[\r\n]"))
|
||||
(funcall send-wait)))
|
||||
(results
|
||||
(case result-type
|
||||
(output
|
||||
(mapconcat
|
||||
#'org-babel-trim
|
||||
(butlast
|
||||
(org-babel-comint-with-output
|
||||
(session org-babel-python-eoe-indicator t body)
|
||||
(funcall input-body body)
|
||||
(funcall send-wait) (funcall send-wait)
|
||||
(insert org-babel-python-eoe-indicator)
|
||||
(funcall send-wait))
|
||||
2) "\n"))
|
||||
(value
|
||||
(let ((tmp-file (org-babel-temp-file "python-")))
|
||||
(org-babel-comint-with-output
|
||||
(session org-babel-python-eoe-indicator nil body)
|
||||
(let ((comint-process-echoes nil))
|
||||
(funcall input-body body)
|
||||
(funcall dump-last-value tmp-file
|
||||
(member "pp" result-params))
|
||||
(funcall send-wait) (funcall send-wait)
|
||||
(insert org-babel-python-eoe-indicator)
|
||||
(funcall send-wait)))
|
||||
(org-babel-eval-read-file tmp-file))))))
|
||||
(unless (string= (substring org-babel-python-eoe-indicator 1 -1) results)
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(org-babel-python-table-or-string results)))))
|
||||
|
||||
(defun org-babel-python-read-string (string)
|
||||
"Strip \\='s from around Python string."
|
||||
(if (string-match "^'\\([^\000]+\\)'$" string)
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(provide 'ob-python)
|
||||
|
||||
|
||||
|
||||
;;; ob-python.el ends here
|
281
elpa/org-20160919/ob-ref.el
Normal file
281
elpa/org-20160919/ob-ref.el
Normal file
@ -0,0 +1,281 @@
|
||||
;;; ob-ref.el --- org-babel functions for referencing external data
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Eric Schulte
|
||||
;; Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Functions for referencing data from the header arguments of a
|
||||
;; org-babel block. The syntax of such a reference should be
|
||||
|
||||
;; #+VAR: variable-name=file:resource-id
|
||||
|
||||
;; - variable-name :: the name of the variable to which the value
|
||||
;; will be assigned
|
||||
|
||||
;; - file :: path to the file containing the resource, or omitted if
|
||||
;; resource is in the current file
|
||||
|
||||
;; - resource-id :: the id or name of the resource
|
||||
|
||||
;; So an example of a simple src block referencing table data in the
|
||||
;; same file would be
|
||||
|
||||
;; #+NAME: sandbox
|
||||
;; | 1 | 2 | 3 |
|
||||
;; | 4 | org-babel | 6 |
|
||||
;;
|
||||
;; #+begin_src emacs-lisp :var table=sandbox
|
||||
;; (message table)
|
||||
;; #+end_src
|
||||
|
||||
;;; Code:
|
||||
(require 'ob-core)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(declare-function org-end-of-meta-data "org" (&optional full))
|
||||
(declare-function org-find-property "org" (property &optional value))
|
||||
(declare-function org-remove-if-not "org" (predicate seq))
|
||||
(declare-function org-at-table-p "org" (&optional table-type))
|
||||
(declare-function org-count "org" (CL-ITEM CL-SEQ))
|
||||
(declare-function org-at-item-p "org-list" ())
|
||||
(declare-function org-narrow-to-subtree "org" ())
|
||||
(declare-function org-id-find-id-in-file "org-id" (id file &optional markerp))
|
||||
(declare-function org-id-find-id-file "org-id" (id))
|
||||
(declare-function org-show-context "org" (&optional key))
|
||||
(declare-function org-pop-to-buffer-same-window
|
||||
"org-compat" (&optional buffer-or-name norecord label))
|
||||
(declare-function org-babel-lob-execute "ob-lob" (info))
|
||||
(declare-function org-babel-lob-get-info "ob-lob" nil)
|
||||
|
||||
(defvar org-babel-ref-split-regexp
|
||||
"[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")
|
||||
|
||||
(defvar org-babel-update-intermediate nil
|
||||
"Update the in-buffer results of code blocks executed to resolve references.")
|
||||
|
||||
(defun org-babel-ref-parse (assignment)
|
||||
"Parse a variable ASSIGNMENT in a header argument.
|
||||
If the right hand side of the assignment has a literal value
|
||||
return that value, otherwise interpret as a reference to an
|
||||
external resource and find its value using
|
||||
`org-babel-ref-resolve'. Return a list with two elements. The
|
||||
first element of the list will be the name of the variable, and
|
||||
the second will be an emacs-lisp representation of the value of
|
||||
the variable."
|
||||
(when (string-match org-babel-ref-split-regexp assignment)
|
||||
(let ((var (match-string 1 assignment))
|
||||
(ref (match-string 2 assignment)))
|
||||
(cons (intern var)
|
||||
(let ((out (save-excursion
|
||||
(when org-babel-current-src-block-location
|
||||
(goto-char (if (markerp org-babel-current-src-block-location)
|
||||
(marker-position org-babel-current-src-block-location)
|
||||
org-babel-current-src-block-location)))
|
||||
(org-babel-read ref))))
|
||||
(if (equal out ref)
|
||||
(if (string-match "^\".*\"$" ref)
|
||||
(read ref)
|
||||
(org-babel-ref-resolve ref))
|
||||
out))))))
|
||||
|
||||
(defun org-babel-ref-goto-headline-id (id)
|
||||
(or (let ((h (org-find-property "CUSTOM_ID" id)))
|
||||
(when h (goto-char h)))
|
||||
(let* ((file (org-id-find-id-file id))
|
||||
(m (when file (org-id-find-id-in-file id file 'marker))))
|
||||
(when (and file m)
|
||||
(message "file:%S" file)
|
||||
(org-pop-to-buffer-same-window (marker-buffer m))
|
||||
(goto-char m)
|
||||
(move-marker m nil)
|
||||
(org-show-context)
|
||||
t))))
|
||||
|
||||
(defun org-babel-ref-headline-body ()
|
||||
(save-restriction
|
||||
(org-narrow-to-subtree)
|
||||
(buffer-substring
|
||||
(save-excursion (goto-char (point-min))
|
||||
(org-end-of-meta-data)
|
||||
(point))
|
||||
(point-max))))
|
||||
|
||||
(defvar org-babel-lob-one-liner-regexp)
|
||||
(defvar org-babel-library-of-babel)
|
||||
(defun org-babel-ref-resolve (ref)
|
||||
"Resolve the reference REF and return its value."
|
||||
(save-window-excursion
|
||||
(with-current-buffer (or org-babel-exp-reference-buffer (current-buffer))
|
||||
(save-excursion
|
||||
(let ((case-fold-search t)
|
||||
type args new-refere new-header-args new-referent result
|
||||
lob-info split-file split-ref index index-row index-col id)
|
||||
;; if ref is indexed grab the indices -- beware nested indices
|
||||
(when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref)
|
||||
(let ((str (substring ref 0 (match-beginning 0))))
|
||||
(= (org-count ?( str) (org-count ?) str))))
|
||||
(setq index (match-string 1 ref))
|
||||
(setq ref (substring ref 0 (match-beginning 0))))
|
||||
;; assign any arguments to pass to source block
|
||||
(when (string-match
|
||||
"^\\(.+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)(\\(.*\\))$" ref)
|
||||
(setq new-refere (match-string 1 ref))
|
||||
(setq new-header-args (match-string 3 ref))
|
||||
(setq new-referent (match-string 5 ref))
|
||||
(when (> (length new-refere) 0)
|
||||
(when (> (length new-referent) 0)
|
||||
(setq args (mapcar (lambda (ref) (cons :var ref))
|
||||
(org-babel-ref-split-args new-referent))))
|
||||
(when (> (length new-header-args) 0)
|
||||
(setq args (append (org-babel-parse-header-arguments
|
||||
new-header-args) args)))
|
||||
(setq ref new-refere)))
|
||||
(when (string-match "^\\(.+\\):\\(.+\\)$" ref)
|
||||
(setq split-file (match-string 1 ref))
|
||||
(setq split-ref (match-string 2 ref))
|
||||
(find-file split-file) (setq ref split-ref))
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(if (let ((src-rx (org-babel-named-src-block-regexp-for-name ref))
|
||||
(res-rx (org-babel-named-data-regexp-for-name ref)))
|
||||
;; goto ref in the current buffer
|
||||
(or
|
||||
;; check for code blocks
|
||||
(re-search-forward src-rx nil t)
|
||||
;; check for named data
|
||||
(re-search-forward res-rx nil t)
|
||||
;; check for local or global headlines by id
|
||||
(setq id (org-babel-ref-goto-headline-id ref))
|
||||
;; check the Library of Babel
|
||||
(setq lob-info (cdr (assoc (intern ref)
|
||||
org-babel-library-of-babel)))))
|
||||
(unless (or lob-info id) (goto-char (match-beginning 0)))
|
||||
;; ;; TODO: allow searching for names in other buffers
|
||||
;; (setq id-loc (org-id-find ref 'marker)
|
||||
;; buffer (marker-buffer id-loc)
|
||||
;; loc (marker-position id-loc))
|
||||
;; (move-marker id-loc nil)
|
||||
(error "Reference `%s' not found in this buffer" ref))
|
||||
(cond
|
||||
(lob-info (setq type 'lob))
|
||||
(id (setq type 'id))
|
||||
((and (looking-at org-babel-src-name-regexp)
|
||||
(save-excursion
|
||||
(forward-line 1)
|
||||
(or (looking-at org-babel-src-block-regexp)
|
||||
(looking-at org-babel-multi-line-header-regexp))))
|
||||
(setq type 'source-block))
|
||||
((and (looking-at org-babel-src-name-regexp)
|
||||
(save-excursion
|
||||
(forward-line 1)
|
||||
(looking-at org-babel-lob-one-liner-regexp)))
|
||||
(setq type 'call-line))
|
||||
(t (while (not (setq type (org-babel-ref-at-ref-p)))
|
||||
(forward-line 1)
|
||||
(beginning-of-line)
|
||||
(if (or (= (point) (point-min)) (= (point) (point-max)))
|
||||
(error "Reference not found")))))
|
||||
(let ((params (append args '((:results . "silent")))))
|
||||
(setq result
|
||||
(case type
|
||||
(results-line (org-babel-read-result))
|
||||
(table (org-babel-read-table))
|
||||
(list (org-babel-read-list))
|
||||
(file (org-babel-read-link))
|
||||
(source-block (org-babel-execute-src-block
|
||||
nil nil (if org-babel-update-intermediate
|
||||
nil params)))
|
||||
(call-line (save-excursion
|
||||
(forward-line 1)
|
||||
(org-babel-lob-execute
|
||||
(org-babel-lob-get-info))))
|
||||
(lob (org-babel-execute-src-block
|
||||
nil lob-info params))
|
||||
(id (org-babel-ref-headline-body)))))
|
||||
(if (symbolp result)
|
||||
(format "%S" result)
|
||||
(if (and index (listp result))
|
||||
(org-babel-ref-index-list index result)
|
||||
result))))))))
|
||||
|
||||
(defun org-babel-ref-index-list (index lis)
|
||||
"Return the subset of LIS indexed by INDEX.
|
||||
|
||||
Indices are 0 based and negative indices count from the end of
|
||||
LIS, so 0 references the first element of LIS and -1 references
|
||||
the last. If INDEX is separated by \",\"s then each \"portion\"
|
||||
is assumed to index into the next deepest nesting or dimension.
|
||||
|
||||
A valid \"portion\" can consist of either an integer index, two
|
||||
integers separated by a \":\" in which case the entire range is
|
||||
returned, or an empty string or \"*\" both of which are
|
||||
interpreted to mean the entire range and as such are equivalent
|
||||
to \"0:-1\"."
|
||||
(if (and (> (length index) 0) (string-match "^\\([^,]*\\),?" index))
|
||||
(let* ((ind-re "\\(\\([-[:digit:]]+\\):\\([-[:digit:]]+\\)\\|\\*\\)")
|
||||
(lgth (length lis))
|
||||
(portion (match-string 1 index))
|
||||
(remainder (substring index (match-end 0)))
|
||||
(wrap (lambda (num) (if (< num 0) (+ lgth num) num)))
|
||||
(open (lambda (ls) (if (and (listp ls) (= (length ls) 1)) (car ls) ls))))
|
||||
(funcall
|
||||
open
|
||||
(mapcar
|
||||
(lambda (sub-lis)
|
||||
(if (listp sub-lis)
|
||||
(org-babel-ref-index-list remainder sub-lis)
|
||||
sub-lis))
|
||||
(if (or (= 0 (length portion)) (string-match ind-re portion))
|
||||
(mapcar
|
||||
(lambda (n) (nth n lis))
|
||||
(apply 'org-number-sequence
|
||||
(if (and (> (length portion) 0) (match-string 2 portion))
|
||||
(list
|
||||
(funcall wrap (string-to-number (match-string 2 portion)))
|
||||
(funcall wrap (string-to-number (match-string 3 portion))))
|
||||
(list (funcall wrap 0) (funcall wrap -1)))))
|
||||
(list (nth (funcall wrap (string-to-number portion)) lis))))))
|
||||
lis))
|
||||
|
||||
(defun org-babel-ref-split-args (arg-string)
|
||||
"Split ARG-STRING into top-level arguments of balanced parenthesis."
|
||||
(mapcar #'org-babel-trim (org-babel-balanced-split arg-string 44)))
|
||||
|
||||
(defvar org-bracket-link-regexp)
|
||||
(defun org-babel-ref-at-ref-p ()
|
||||
"Return the type of reference located at point.
|
||||
Return nil if none of the supported reference types are found.
|
||||
Supported reference types are tables and source blocks."
|
||||
(cond ((org-at-table-p) 'table)
|
||||
((org-at-item-p) 'list)
|
||||
((looking-at "^[ \t]*#\\+BEGIN_SRC") 'source-block)
|
||||
((looking-at org-bracket-link-regexp) 'file)
|
||||
((looking-at org-babel-result-regexp) 'results-line)))
|
||||
|
||||
(provide 'ob-ref)
|
||||
|
||||
|
||||
|
||||
;;; ob-ref.el ends here
|
267
elpa/org-20160919/ob-ruby.el
Normal file
267
elpa/org-20160919/ob-ruby.el
Normal file
@ -0,0 +1,267 @@
|
||||
;;; ob-ruby.el --- org-babel functions for ruby evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating ruby source code.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - ruby and irb executables :: http://www.ruby-lang.org/
|
||||
;;
|
||||
;; - ruby-mode :: Can be installed through ELPA, or from
|
||||
;; http://github.com/eschulte/rinari/raw/master/util/ruby-mode.el
|
||||
;;
|
||||
;; - inf-ruby mode :: Can be installed through ELPA, or from
|
||||
;; http://github.com/eschulte/rinari/raw/master/util/inf-ruby.el
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function run-ruby "ext:inf-ruby" (&optional command name))
|
||||
(declare-function xmp "ext:rcodetools" (&optional option))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("ruby" . "rb"))
|
||||
|
||||
(defvar org-babel-default-header-args:ruby '())
|
||||
|
||||
(defvar org-babel-ruby-command "ruby"
|
||||
"Name of command to use for executing ruby code.")
|
||||
|
||||
(defcustom org-babel-ruby-hline-to "nil"
|
||||
"Replace hlines in incoming tables with this when translating to ruby."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-ruby-nil-to 'hline
|
||||
"Replace nil in ruby tables with this before returning."
|
||||
:group 'org-babel
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'symbol)
|
||||
|
||||
(defun org-babel-execute:ruby (body params)
|
||||
"Execute a block of Ruby code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((session (org-babel-ruby-initiate-session
|
||||
(cdr (assoc :session params))))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:ruby params)))
|
||||
(result (if (member "xmp" result-params)
|
||||
(with-temp-buffer
|
||||
(require 'rcodetools)
|
||||
(insert full-body)
|
||||
(xmp (cdr (assoc :xmp-option params)))
|
||||
(buffer-string))
|
||||
(org-babel-ruby-evaluate
|
||||
session full-body result-type result-params))))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-result-cond result-params
|
||||
result
|
||||
(org-babel-ruby-table-or-string result))
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:ruby (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
;; (message "params=%S" params) ;; debugging
|
||||
(let* ((session (org-babel-ruby-initiate-session session))
|
||||
(var-lines (org-babel-variable-assignments:ruby params)))
|
||||
(org-babel-comint-in-buffer session
|
||||
(sit-for .5) (goto-char (point-max))
|
||||
(mapc (lambda (var)
|
||||
(insert var) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)
|
||||
(sit-for .1) (goto-char (point-max))) var-lines))
|
||||
session))
|
||||
|
||||
(defun org-babel-load-session:ruby (session body params)
|
||||
"Load BODY into SESSION."
|
||||
(save-window-excursion
|
||||
(let ((buffer (org-babel-prep-session:ruby session params)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert (org-babel-chomp body)))
|
||||
buffer)))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-variable-assignments:ruby (params)
|
||||
"Return list of ruby statements assigning the block's variables."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-ruby-var-to-ruby (cdr pair))))
|
||||
(mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-ruby-var-to-ruby (var)
|
||||
"Convert VAR into a ruby variable.
|
||||
Convert an elisp value into a string of ruby source code
|
||||
specifying a variable of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
|
||||
(if (equal var 'hline)
|
||||
org-babel-ruby-hline-to
|
||||
(format "%S" var))))
|
||||
|
||||
(defun org-babel-ruby-table-or-string (results)
|
||||
"Convert RESULTS into an appropriate elisp value.
|
||||
If RESULTS look like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(let ((res (org-babel-script-escape results)))
|
||||
(if (listp res)
|
||||
(mapcar (lambda (el) (if (equal el 'nil)
|
||||
org-babel-ruby-nil-to el))
|
||||
res)
|
||||
res)))
|
||||
|
||||
(defun org-babel-ruby-initiate-session (&optional session params)
|
||||
"Initiate a ruby session.
|
||||
If there is not a current inferior-process-buffer in SESSION
|
||||
then create one. Return the initialized session."
|
||||
(unless (string= session "none")
|
||||
(require 'inf-ruby)
|
||||
(let ((session-buffer (save-window-excursion
|
||||
(run-ruby nil session) (current-buffer))))
|
||||
(if (org-babel-comint-buffer-livep session-buffer)
|
||||
(progn (sit-for .25) session-buffer)
|
||||
(sit-for .5)
|
||||
(org-babel-ruby-initiate-session session)))))
|
||||
|
||||
(defvar org-babel-ruby-eoe-indicator ":org_babel_ruby_eoe"
|
||||
"String to indicate that evaluation has completed.")
|
||||
(defvar org-babel-ruby-f-write
|
||||
"File.open('%s','w'){|f| f.write((_.class == String) ? _ : _.inspect)}")
|
||||
(defvar org-babel-ruby-pp-f-write
|
||||
"File.open('%s','w'){|f| $stdout = f; pp(results); $stdout = orig_out}")
|
||||
(defvar org-babel-ruby-wrapper-method
|
||||
"
|
||||
def main()
|
||||
%s
|
||||
end
|
||||
results = main()
|
||||
File.open('%s', 'w'){ |f| f.write((results.class == String) ? results : results.inspect) }
|
||||
")
|
||||
(defvar org-babel-ruby-pp-wrapper-method
|
||||
"
|
||||
require 'pp'
|
||||
def main()
|
||||
%s
|
||||
end
|
||||
results = main()
|
||||
File.open('%s', 'w') do |f|
|
||||
$stdout = f
|
||||
pp results
|
||||
end
|
||||
")
|
||||
|
||||
(defun org-babel-ruby-evaluate
|
||||
(buffer body &optional result-type result-params)
|
||||
"Pass BODY to the Ruby process in BUFFER.
|
||||
If RESULT-TYPE equals `output' then return a list of the outputs
|
||||
of the statements in BODY, if RESULT-TYPE equals `value' then
|
||||
return the value of the last statement in BODY, as elisp."
|
||||
(if (not buffer)
|
||||
;; external process evaluation
|
||||
(case result-type
|
||||
(output (org-babel-eval org-babel-ruby-command body))
|
||||
(value (let ((tmp-file (org-babel-temp-file "ruby-")))
|
||||
(org-babel-eval
|
||||
org-babel-ruby-command
|
||||
(format (if (member "pp" result-params)
|
||||
org-babel-ruby-pp-wrapper-method
|
||||
org-babel-ruby-wrapper-method)
|
||||
body (org-babel-process-file-name tmp-file 'noquote)))
|
||||
(org-babel-eval-read-file tmp-file))))
|
||||
;; comint session evaluation
|
||||
(case result-type
|
||||
(output
|
||||
(let ((eoe-string (format "puts \"%s\"" org-babel-ruby-eoe-indicator)))
|
||||
;; Force the session to be ready before the actual session
|
||||
;; code is run. There is some problem in comint that will
|
||||
;; sometimes show the prompt after the the input has already
|
||||
;; been inserted and that throws off the extraction of the
|
||||
;; result for Babel.
|
||||
(org-babel-comint-with-output
|
||||
(buffer org-babel-ruby-eoe-indicator t eoe-string)
|
||||
(insert eoe-string) (comint-send-input nil t))
|
||||
;; Now we can start the evaluation.
|
||||
(mapconcat
|
||||
#'identity
|
||||
(butlast
|
||||
(split-string
|
||||
(mapconcat
|
||||
#'org-babel-trim
|
||||
(org-babel-comint-with-output
|
||||
(buffer org-babel-ruby-eoe-indicator t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
(list "conf.echo=false;_org_prompt_mode=conf.prompt_mode;conf.prompt_mode=:NULL"
|
||||
body
|
||||
"conf.prompt_mode=_org_prompt_mode;conf.echo=true"
|
||||
eoe-string)))
|
||||
"\n") "[\r\n]") 4) "\n")))
|
||||
(value
|
||||
(let* ((tmp-file (org-babel-temp-file "ruby-"))
|
||||
(ppp (or (member "code" result-params)
|
||||
(member "pp" result-params))))
|
||||
(org-babel-comint-with-output
|
||||
(buffer org-babel-ruby-eoe-indicator t body)
|
||||
(when ppp (insert "require 'pp';") (comint-send-input nil t))
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
(append
|
||||
(list body)
|
||||
(if (not ppp)
|
||||
(list (format org-babel-ruby-f-write
|
||||
(org-babel-process-file-name tmp-file 'noquote)))
|
||||
(list
|
||||
"results=_" "require 'pp'" "orig_out = $stdout"
|
||||
(format org-babel-ruby-pp-f-write
|
||||
(org-babel-process-file-name tmp-file 'noquote))))
|
||||
(list org-babel-ruby-eoe-indicator)))
|
||||
(comint-send-input nil t))
|
||||
(org-babel-eval-read-file tmp-file))))))
|
||||
|
||||
(defun org-babel-ruby-read-string (string)
|
||||
"Strip \\\"s from around a ruby string."
|
||||
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(provide 'ob-ruby)
|
||||
|
||||
|
||||
|
||||
;;; ob-ruby.el ends here
|
71
elpa/org-20160919/ob-sass.el
Normal file
71
elpa/org-20160919/ob-sass.el
Normal file
@ -0,0 +1,71 @@
|
||||
;;; ob-sass.el --- org-babel functions for the sass css generation language
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; For more information on sass see http://sass-lang.com/
|
||||
;;
|
||||
;; This accepts a 'file' header argument which is the target of the
|
||||
;; compiled sass. The default output type for sass evaluation is
|
||||
;; either file (if a 'file' header argument was given) or scalar if no
|
||||
;; such header argument was supplied.
|
||||
;;
|
||||
;; A 'cmdline' header argument can be supplied to pass arguments to
|
||||
;; the sass command line.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:sass '())
|
||||
|
||||
(defun org-babel-execute:sass (body params)
|
||||
"Execute a block of Sass code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(file (cdr (assoc :file params)))
|
||||
(out-file (or file (org-babel-temp-file "sass-out-")))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(in-file (org-babel-temp-file "sass-in-"))
|
||||
(cmd (concat "sass " (or cmdline "")
|
||||
" " (org-babel-process-file-name in-file)
|
||||
" " (org-babel-process-file-name out-file))))
|
||||
(with-temp-file in-file
|
||||
(insert (org-babel-expand-body:generic body params)))
|
||||
(org-babel-eval cmd "")
|
||||
(if file
|
||||
nil ;; signal that output has already been written to file
|
||||
(with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
|
||||
|
||||
(defun org-babel-prep-session:sass (session params)
|
||||
"Raise an error because sass does not support sessions."
|
||||
(error "Sass does not support sessions"))
|
||||
|
||||
(provide 'ob-sass)
|
||||
|
||||
|
||||
|
||||
;;; ob-sass.el ends here
|
116
elpa/org-20160919/ob-scala.el
Normal file
116
elpa/org-20160919/ob-scala.el
Normal file
@ -0,0 +1,116 @@
|
||||
;;; ob-scala.el --- org-babel functions for Scala evaluation
|
||||
|
||||
;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Andrzej Lichnerowicz
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;; Currently only supports the external execution. No session support yet.
|
||||
|
||||
;;; Requirements:
|
||||
;; - Scala language :: http://www.scala-lang.org/
|
||||
;; - Scala major mode :: Can be installed from Scala sources
|
||||
;; https://github.com/scala/scala-dist/blob/master/tool-support/src/emacs/scala-mode.el
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-lang-exts) ;; Autoloaded
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("scala" . "scala"))
|
||||
(defvar org-babel-default-header-args:scala '())
|
||||
(defvar org-babel-scala-command "scala"
|
||||
"Name of the command to use for executing Scala code.")
|
||||
|
||||
(defun org-babel-execute:scala (body params)
|
||||
"Execute a block of Scala code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'"
|
||||
(message "executing Scala source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-scala-initiate-session (nth 0 processed-params)))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (cdr (assoc :result-type params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params))
|
||||
(result (org-babel-scala-evaluate
|
||||
session full-body result-type result-params)))
|
||||
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defvar org-babel-scala-wrapper-method
|
||||
|
||||
"var str_result :String = null;
|
||||
|
||||
Console.withOut(new java.io.OutputStream() {def write(b: Int){
|
||||
}}) {
|
||||
str_result = {
|
||||
%s
|
||||
}.toString
|
||||
}
|
||||
|
||||
print(str_result)
|
||||
")
|
||||
|
||||
|
||||
(defun org-babel-scala-evaluate
|
||||
(session body &optional result-type result-params)
|
||||
"Evaluate BODY in external Scala process.
|
||||
If RESULT-TYPE equals `output' then return standard output as a string.
|
||||
If RESULT-TYPE equals `value' then return the value of the last statement
|
||||
in BODY as elisp."
|
||||
(when session (error "Sessions are not (yet) supported for Scala"))
|
||||
(case result-type
|
||||
(output
|
||||
(let ((src-file (org-babel-temp-file "scala-")))
|
||||
(progn (with-temp-file src-file (insert body))
|
||||
(org-babel-eval
|
||||
(concat org-babel-scala-command " " src-file) ""))))
|
||||
(value
|
||||
(let* ((src-file (org-babel-temp-file "scala-"))
|
||||
(wrapper (format org-babel-scala-wrapper-method body)))
|
||||
(with-temp-file src-file (insert wrapper))
|
||||
(let ((raw (org-babel-eval
|
||||
(concat org-babel-scala-command " " src-file) "")))
|
||||
(org-babel-result-cond result-params
|
||||
raw
|
||||
(org-babel-script-escape raw)))))))
|
||||
|
||||
|
||||
(defun org-babel-prep-session:scala (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "Sessions are not (yet) supported for Scala"))
|
||||
|
||||
(defun org-babel-scala-initiate-session (&optional session)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session. Sessions are not
|
||||
supported in Scala."
|
||||
nil)
|
||||
|
||||
(provide 'ob-scala)
|
||||
|
||||
|
||||
|
||||
;;; ob-scala.el ends here
|
208
elpa/org-20160919/ob-scheme.el
Normal file
208
elpa/org-20160919/ob-scheme.el
Normal file
@ -0,0 +1,208 @@
|
||||
;;; ob-scheme.el --- org-babel functions for Scheme
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Eric Schulte
|
||||
;; Michael Gauland
|
||||
;; Keywords: literate programming, reproducible research, scheme
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Now working with SBCL for both session and external evaluation.
|
||||
;;
|
||||
;; This certainly isn't optimally robust, but it seems to be working
|
||||
;; for the basic use cases.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - a working scheme implementation
|
||||
;; (e.g. guile http://www.gnu.org/software/guile/guile.html)
|
||||
;;
|
||||
;; - for session based evaluation geiser is required, which is available from
|
||||
;; ELPA.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'geiser nil t)
|
||||
(defvar geiser-repl--repl) ; Defined in geiser-repl.el
|
||||
(defvar geiser-impl--implementation) ; Defined in geiser-impl.el
|
||||
(defvar geiser-default-implementation) ; Defined in geiser-impl.el
|
||||
(defvar geiser-active-implementations) ; Defined in geiser-impl.el
|
||||
|
||||
(declare-function run-geiser "ext:geiser-repl" (impl))
|
||||
(declare-function geiser-mode "ext:geiser-mode" ())
|
||||
(declare-function geiser-eval-region "ext:geiser-mode"
|
||||
(start end &optional and-go raw nomsg))
|
||||
(declare-function geiser-repl-exit "ext:geiser-repl" (&optional arg))
|
||||
|
||||
(defvar org-babel-default-header-args:scheme '()
|
||||
"Default header arguments for scheme code blocks.")
|
||||
|
||||
(defun org-babel-expand-body:scheme (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(if (> (length vars) 0)
|
||||
(concat "(let ("
|
||||
(mapconcat
|
||||
(lambda (var) (format "%S" (print `(,(car var) ',(cdr var)))))
|
||||
vars "\n ")
|
||||
")\n" body ")")
|
||||
body)))
|
||||
|
||||
|
||||
(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal)
|
||||
"Map of scheme sessions to session names.")
|
||||
|
||||
(defun org-babel-scheme-cleanse-repl-map ()
|
||||
"Remove dead buffers from the REPL map."
|
||||
(maphash
|
||||
(lambda (x y)
|
||||
(when (not (buffer-name y))
|
||||
(remhash x org-babel-scheme-repl-map)))
|
||||
org-babel-scheme-repl-map))
|
||||
|
||||
(defun org-babel-scheme-get-session-buffer (session-name)
|
||||
"Look up the scheme buffer for a session; return nil if it doesn't exist."
|
||||
(org-babel-scheme-cleanse-repl-map) ; Prune dead sessions
|
||||
(gethash session-name org-babel-scheme-repl-map))
|
||||
|
||||
(defun org-babel-scheme-set-session-buffer (session-name buffer)
|
||||
"Record the scheme buffer used for a given session."
|
||||
(puthash session-name buffer org-babel-scheme-repl-map))
|
||||
|
||||
(defun org-babel-scheme-get-buffer-impl (buffer)
|
||||
"Returns the scheme implementation geiser associates with the buffer."
|
||||
(with-current-buffer (set-buffer buffer)
|
||||
geiser-impl--implementation))
|
||||
|
||||
(defun org-babel-scheme-get-repl (impl name)
|
||||
"Switch to a scheme REPL, creating it if it doesn't exist:"
|
||||
(let ((buffer (org-babel-scheme-get-session-buffer name)))
|
||||
(or buffer
|
||||
(progn
|
||||
(run-geiser impl)
|
||||
(if name
|
||||
(progn
|
||||
(rename-buffer name t)
|
||||
(org-babel-scheme-set-session-buffer name (current-buffer))))
|
||||
(current-buffer)))))
|
||||
|
||||
(defun org-babel-scheme-make-session-name (buffer name impl)
|
||||
"Generate a name for the session buffer.
|
||||
|
||||
For a named session, the buffer name will be the session name.
|
||||
|
||||
If the session is unnamed (nil), generate a name.
|
||||
|
||||
If the session is `none', use nil for the session name, and
|
||||
org-babel-scheme-execute-with-geiser will use a temporary session."
|
||||
(let ((result
|
||||
(cond ((not name)
|
||||
(concat buffer " " (symbol-name impl) " REPL"))
|
||||
((string= name "none") nil)
|
||||
(name))))
|
||||
result))
|
||||
|
||||
(defmacro org-babel-scheme-capture-current-message (&rest body)
|
||||
"Capture current message in both interactive and noninteractive mode"
|
||||
`(if noninteractive
|
||||
(let ((original-message (symbol-function 'message))
|
||||
(current-message nil))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(defun message (&rest args)
|
||||
(setq current-message (apply original-message args)))
|
||||
,@body
|
||||
current-message)
|
||||
(fset 'message original-message)))
|
||||
(progn
|
||||
,@body
|
||||
(current-message))))
|
||||
|
||||
(defun org-babel-scheme-execute-with-geiser (code output impl repl)
|
||||
"Execute code in specified REPL. If the REPL doesn't exist, create it
|
||||
using the given scheme implementation.
|
||||
|
||||
Returns the output of executing the code if the output parameter
|
||||
is true; otherwise returns the last value."
|
||||
(let ((result nil))
|
||||
(with-temp-buffer
|
||||
(insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl))
|
||||
(newline)
|
||||
(insert (if output
|
||||
(format "(with-output-to-string (lambda () %s))" code)
|
||||
code))
|
||||
(geiser-mode)
|
||||
(let ((repl-buffer (save-current-buffer
|
||||
(org-babel-scheme-get-repl impl repl))))
|
||||
(when (not (eq impl (org-babel-scheme-get-buffer-impl
|
||||
(current-buffer))))
|
||||
(message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl)
|
||||
(org-babel-scheme-get-buffer-impl (current-buffer))
|
||||
(symbolp (org-babel-scheme-get-buffer-impl
|
||||
(current-buffer)))))
|
||||
(setq geiser-repl--repl repl-buffer)
|
||||
(setq geiser-impl--implementation nil)
|
||||
(setq result (org-babel-scheme-capture-current-message
|
||||
(geiser-eval-region (point-min) (point-max))))
|
||||
(setq result
|
||||
(if (and (stringp result) (equal (substring result 0 3) "=> "))
|
||||
(replace-regexp-in-string "^=> " "" result)
|
||||
"\"An error occurred.\""))
|
||||
(when (not repl)
|
||||
(save-current-buffer (set-buffer repl-buffer)
|
||||
(geiser-repl-exit))
|
||||
(set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
|
||||
(kill-buffer repl-buffer))
|
||||
(setq result (if (or (string= result "#<void>")
|
||||
(string= result "#<unspecified>"))
|
||||
nil
|
||||
result))))
|
||||
result))
|
||||
|
||||
(defun org-babel-execute:scheme (body params)
|
||||
"Execute a block of Scheme code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'"
|
||||
(let* ((source-buffer (current-buffer))
|
||||
(source-buffer-name (replace-regexp-in-string ;; zap surrounding *
|
||||
"^ ?\\*\\([^*]+\\)\\*" "\\1"
|
||||
(buffer-name source-buffer))))
|
||||
(save-excursion
|
||||
(org-babel-reassemble-table
|
||||
(let* ((result-type (cdr (assoc :result-type params)))
|
||||
(impl (or (when (cdr (assoc :scheme params))
|
||||
(intern (cdr (assoc :scheme params))))
|
||||
geiser-default-implementation
|
||||
(car geiser-active-implementations)))
|
||||
(session (org-babel-scheme-make-session-name
|
||||
source-buffer-name (cdr (assoc :session params)) impl))
|
||||
(full-body (org-babel-expand-body:scheme body params)))
|
||||
(org-babel-scheme-execute-with-geiser
|
||||
full-body ; code
|
||||
(string= result-type "output") ; output?
|
||||
impl ; implementation
|
||||
(and (not (string= session "none")) session))) ; session
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params)))))))
|
||||
|
||||
(provide 'ob-scheme)
|
||||
|
||||
;;; ob-scheme.el ends here
|
145
elpa/org-20160919/ob-screen.el
Normal file
145
elpa/org-20160919/ob-screen.el
Normal file
@ -0,0 +1,145 @@
|
||||
;;; ob-screen.el --- org-babel support for interactive terminal
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Benjamin Andresen
|
||||
;; Keywords: literate programming, interactive shell
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for interactive terminals. Mostly shell scripts.
|
||||
;; Heavily inspired by 'eev' from Eduardo Ochs
|
||||
;;
|
||||
;; Adding :cmd and :terminal as header arguments
|
||||
;; :terminal must support the -T (title) and -e (command) parameter
|
||||
;;
|
||||
;; You can test the default setup. (xterm + sh) with
|
||||
;; M-x org-babel-screen-test RET
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-screen-location "screen"
|
||||
"The command location for screen.
|
||||
In case you want to use a different screen than one selected by your $PATH")
|
||||
|
||||
(defvar org-babel-default-header-args:screen
|
||||
'((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm"))
|
||||
"Default arguments to use when running screen source blocks.")
|
||||
|
||||
(defun org-babel-execute:screen (body params)
|
||||
"Send a block of code via screen to a terminal using Babel.
|
||||
\"default\" session is used when none is specified."
|
||||
(message "Sending source code block to interactive terminal session...")
|
||||
(save-window-excursion
|
||||
(let* ((session (cdr (assoc :session params)))
|
||||
(socket (org-babel-screen-session-socketname session)))
|
||||
(unless socket (org-babel-prep-session:screen session params))
|
||||
(org-babel-screen-session-execute-string
|
||||
session (org-babel-expand-body:generic body params)))))
|
||||
|
||||
(defun org-babel-prep-session:screen (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (cdr (assoc :session params)))
|
||||
(socket (org-babel-screen-session-socketname session))
|
||||
(cmd (cdr (assoc :cmd params)))
|
||||
(terminal (cdr (assoc :terminal params)))
|
||||
(process-name (concat "org-babel: terminal (" session ")")))
|
||||
(apply 'start-process process-name "*Messages*"
|
||||
terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
|
||||
"-c" "/dev/null" "-mS" ,(concat "org-babel-session-" session)
|
||||
,cmd))
|
||||
;; XXX: Is there a better way than the following?
|
||||
(while (not (org-babel-screen-session-socketname session))
|
||||
;; wait until screen session is available before returning
|
||||
)))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-screen-session-execute-string (session body)
|
||||
"If SESSION exists, send BODY to it."
|
||||
(let ((socket (org-babel-screen-session-socketname session)))
|
||||
(when socket
|
||||
(let ((tmpfile (org-babel-screen-session-write-temp-file session body)))
|
||||
(apply 'start-process (concat "org-babel: screen (" session ")") "*Messages*"
|
||||
org-babel-screen-location
|
||||
`("-S" ,socket "-X" "eval" "msgwait 0"
|
||||
,(concat "readreg z " tmpfile)
|
||||
"paste z"))))))
|
||||
|
||||
(defun org-babel-screen-session-socketname (session)
|
||||
"Check if SESSION exists by parsing output of \"screen -ls\"."
|
||||
(let* ((screen-ls (shell-command-to-string "screen -ls"))
|
||||
(sockets (delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (x)
|
||||
(when (string-match (rx (or "(Attached)" "(Detached)")) x)
|
||||
x))
|
||||
(split-string screen-ls "\n"))))
|
||||
(match-socket (car
|
||||
(delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (x)
|
||||
(when (string-match
|
||||
(concat "org-babel-session-" session) x)
|
||||
x))
|
||||
sockets)))))
|
||||
(when match-socket (car (split-string match-socket)))))
|
||||
|
||||
(defun org-babel-screen-session-write-temp-file (session body)
|
||||
"Save BODY in a temp file that is named after SESSION."
|
||||
(let ((tmpfile (org-babel-temp-file "screen-")))
|
||||
(with-temp-file tmpfile
|
||||
(insert body)
|
||||
|
||||
;; org-babel has superfluous spaces
|
||||
(goto-char (point-min))
|
||||
(delete-matching-lines "^ +$"))
|
||||
tmpfile))
|
||||
|
||||
(defun org-babel-screen-test ()
|
||||
"Test if the default setup works.
|
||||
The terminal should shortly flicker."
|
||||
(interactive)
|
||||
(let* ((session "org-babel-testing")
|
||||
(random-string (format "%s" (random 99999)))
|
||||
(tmpfile (org-babel-temp-file "ob-screen-test-"))
|
||||
(body (concat "echo '" random-string "' > " tmpfile "\nexit\n"))
|
||||
process tmp-string)
|
||||
(org-babel-execute:screen body org-babel-default-header-args:screen)
|
||||
;; XXX: need to find a better way to do the following
|
||||
(while (not (file-readable-p tmpfile))
|
||||
;; do something, otherwise this will be optimized away
|
||||
(format "org-babel-screen: File not readable yet."))
|
||||
(setq tmp-string (with-temp-buffer
|
||||
(insert-file-contents-literally tmpfile)
|
||||
(buffer-substring (point-min) (point-max))))
|
||||
(delete-file tmpfile)
|
||||
(message (concat "org-babel-screen: Setup "
|
||||
(if (string-match random-string tmp-string)
|
||||
"WORKS."
|
||||
"DOESN'T work.")))))
|
||||
|
||||
(provide 'ob-screen)
|
||||
|
||||
|
||||
|
||||
;;; ob-screen.el ends here
|
107
elpa/org-20160919/ob-sed.el
Normal file
107
elpa/org-20160919/ob-sed.el
Normal file
@ -0,0 +1,107 @@
|
||||
;;; ob-sed.el --- org-babel functions for sed scripts
|
||||
|
||||
;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Bjarte Johansen
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Version: 0.1.0
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;;; License:
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Provides a way to evaluate sed scripts in Org mode.
|
||||
|
||||
;;; Usage:
|
||||
|
||||
;; Add to your Emacs config:
|
||||
|
||||
;; (org-babel-do-load-languages
|
||||
;; 'org-babel-load-languages
|
||||
;; '((sed . t)))
|
||||
|
||||
;; In addition to the normal header arguments, ob-sed also provides
|
||||
;; :cmd-line and :in-file. :cmd-line allows one to pass other flags to
|
||||
;; the sed command like the "--in-place" flag which makes sed edit the
|
||||
;; file pass to it instead of outputting to standard out or to a
|
||||
;; different file. :in-file is a header arguments that allows one to
|
||||
;; tell Org Babel which file the sed script to act on.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-sed-command "sed"
|
||||
"Name of the sed executable command.")
|
||||
|
||||
(defvar org-babel-tangle-lang-exts)
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("sed" . "sed"))
|
||||
|
||||
(defconst org-babel-header-args:sed
|
||||
'((:cmd-line . :any)
|
||||
(:in-file . :any))
|
||||
"Sed specific header arguments.")
|
||||
|
||||
(defvar org-babel-default-header-args:sed '()
|
||||
"Default arguments for evaluating a sed source block.")
|
||||
|
||||
(defun org-babel-execute:sed (body params)
|
||||
"Execute a block of sed code with Org Babel.
|
||||
BODY is the source inside a sed source block and PARAMS is an
|
||||
association list over the source block configurations. This
|
||||
function is called by `org-babel-execute-src-block'."
|
||||
(message "executing sed source code block")
|
||||
(let* ((result-params (cdr (assq :result-params params)))
|
||||
(cmd-line (cdr (assq :cmd-line params)))
|
||||
(in-file (cdr (assq :in-file params)))
|
||||
(code-file (let ((file (org-babel-temp-file "sed-")))
|
||||
(with-temp-file file
|
||||
(insert body)) file))
|
||||
(stdin (let ((stdin (cdr (assq :stdin params))))
|
||||
(when stdin
|
||||
(let ((tmp (org-babel-temp-file "sed-stdin-"))
|
||||
(res (org-babel-ref-resolve stdin)))
|
||||
(with-temp-file tmp
|
||||
(insert res))
|
||||
tmp))))
|
||||
(cmd (mapconcat #'identity
|
||||
(remq nil
|
||||
(list org-babel-sed-command
|
||||
(format "--file=\"%s\"" code-file)
|
||||
cmd-line
|
||||
in-file))
|
||||
" ")))
|
||||
(org-babel-reassemble-table
|
||||
(let ((results
|
||||
(cond
|
||||
(stdin (with-temp-buffer
|
||||
(call-process-shell-command cmd stdin (current-buffer))
|
||||
(buffer-string)))
|
||||
(t (org-babel-eval cmd "")))))
|
||||
(when results
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(let ((tmp (org-babel-temp-file "sed-results-")))
|
||||
(with-temp-file tmp (insert results))
|
||||
(org-babel-import-elisp-from-file tmp)))))
|
||||
(org-babel-pick-name
|
||||
(cdr (assq :colname-names params)) (cdr (assq :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))
|
||||
|
||||
(provide 'ob-sed)
|
||||
;;; ob-sed.el ends here
|
266
elpa/org-20160919/ob-shell.el
Normal file
266
elpa/org-20160919/ob-shell.el
Normal file
@ -0,0 +1,266 @@
|
||||
;;; ob-shell.el --- org-babel functions for shell evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating shell source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'shell)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body)
|
||||
t)
|
||||
(declare-function org-babel-comint-wait-for-output "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-buffer-livep "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-with-output "ob-comint" (meta &rest body)
|
||||
t)
|
||||
(declare-function orgtbl-to-generic "org-table" (table params))
|
||||
|
||||
(defvar org-babel-default-header-args:shell '())
|
||||
|
||||
(defcustom org-babel-shell-names
|
||||
'("sh" "bash" "csh" "ash" "dash" "ksh" "mksh" "posh")
|
||||
"List of names of shell supported by babel shell code blocks."
|
||||
:group 'org-babel
|
||||
:type 'string
|
||||
:initialize
|
||||
(lambda (symbol value)
|
||||
(set-default symbol (second value))
|
||||
(mapc
|
||||
(lambda (name)
|
||||
(eval `(defun ,(intern (concat "org-babel-execute:" name)) (body params)
|
||||
,(format "Execute a block of %s commands with Babel." name)
|
||||
(let ((shell-file-name ,name))
|
||||
(org-babel-execute:shell body params)))))
|
||||
(second value))))
|
||||
|
||||
(defun org-babel-execute:shell (body params)
|
||||
"Execute a block of Shell commands with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((session (org-babel-sh-initiate-session
|
||||
(cdr (assoc :session params))))
|
||||
(stdin (let ((stdin (cdr (assoc :stdin params))))
|
||||
(when stdin (org-babel-sh-var-to-string
|
||||
(org-babel-ref-resolve stdin)))))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(full-body (org-babel-expand-body:generic
|
||||
body params (org-babel-variable-assignments:shell params))))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-sh-evaluate session full-body params stdin cmdline)
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:shell (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-sh-initiate-session session))
|
||||
(var-lines (org-babel-variable-assignments:shell params)))
|
||||
(org-babel-comint-in-buffer session
|
||||
(mapc (lambda (var)
|
||||
(insert var) (comint-send-input nil t)
|
||||
(org-babel-comint-wait-for-output session)) var-lines))
|
||||
session))
|
||||
|
||||
(defun org-babel-load-session:shell (session body params)
|
||||
"Load BODY into SESSION."
|
||||
(save-window-excursion
|
||||
(let ((buffer (org-babel-prep-session:shell session params)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert (org-babel-chomp body)))
|
||||
buffer)))
|
||||
|
||||
;; helper functions
|
||||
(defun org-babel-variable-assignments:sh-generic
|
||||
(varname values &optional sep hline)
|
||||
"Returns a list of statements declaring the values as a generic variable."
|
||||
(format "%s=%s" varname (org-babel-sh-var-to-sh values sep hline)))
|
||||
|
||||
(defun org-babel-variable-assignments:bash_array
|
||||
(varname values &optional sep hline)
|
||||
"Returns a list of statements declaring the values as a bash array."
|
||||
(format "unset %s\ndeclare -a %s=( %s )"
|
||||
varname varname
|
||||
(mapconcat
|
||||
(lambda (value) (org-babel-sh-var-to-sh value sep hline))
|
||||
values
|
||||
" ")))
|
||||
|
||||
(defun org-babel-variable-assignments:bash_assoc
|
||||
(varname values &optional sep hline)
|
||||
"Returns a list of statements declaring the values as bash associative array."
|
||||
(format "unset %s\ndeclare -A %s\n%s"
|
||||
varname varname
|
||||
(mapconcat
|
||||
(lambda (items)
|
||||
(format "%s[%s]=%s"
|
||||
varname
|
||||
(org-babel-sh-var-to-sh (car items) sep hline)
|
||||
(org-babel-sh-var-to-sh (cdr items) sep hline)))
|
||||
values
|
||||
"\n")))
|
||||
|
||||
(defun org-babel-variable-assignments:bash (varname values &optional sep hline)
|
||||
"Represents the parameters as useful Bash shell variables."
|
||||
(if (listp values)
|
||||
(if (and (listp (car values)) (= 1 (length (car values))))
|
||||
(org-babel-variable-assignments:bash_array varname values sep hline)
|
||||
(org-babel-variable-assignments:bash_assoc varname values sep hline))
|
||||
(org-babel-variable-assignments:sh-generic varname values sep hline)))
|
||||
|
||||
(defun org-babel-variable-assignments:shell (params)
|
||||
"Return list of shell statements assigning the block's variables."
|
||||
(let ((sep (cdr (assoc :separator params)))
|
||||
(hline (when (string= "yes" (cdr (assoc :hlines params)))
|
||||
(or (cdr (assoc :hline-string params))
|
||||
"hline"))))
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(if (string-match "bash$" shell-file-name)
|
||||
(org-babel-variable-assignments:bash
|
||||
(car pair) (cdr pair) sep hline)
|
||||
(org-babel-variable-assignments:sh-generic
|
||||
(car pair) (cdr pair) sep hline)))
|
||||
(mapcar #'cdr (org-babel-get-header params :var)))))
|
||||
|
||||
(defun org-babel-sh-var-to-sh (var &optional sep hline)
|
||||
"Convert an elisp value to a shell variable.
|
||||
Convert an elisp var into a string of shell commands specifying a
|
||||
var of the same value."
|
||||
(concat "'" (replace-regexp-in-string
|
||||
"'" "'\"'\"'"
|
||||
(org-babel-sh-var-to-string var sep hline))
|
||||
"'"))
|
||||
|
||||
(defun org-babel-sh-var-to-string (var &optional sep hline)
|
||||
"Convert an elisp value to a string."
|
||||
(let ((echo-var (lambda (v) (if (stringp v) v (format "%S" v)))))
|
||||
(cond
|
||||
((and (listp var) (or (listp (car var)) (equal (car var) 'hline)))
|
||||
(orgtbl-to-generic var (list :sep (or sep "\t") :fmt echo-var
|
||||
:hline hline)))
|
||||
((listp var)
|
||||
(mapconcat echo-var var "\n"))
|
||||
(t (funcall echo-var var)))))
|
||||
|
||||
(defun org-babel-sh-initiate-session (&optional session params)
|
||||
"Initiate a session named SESSION according to PARAMS."
|
||||
(when (and session (not (string= session "none")))
|
||||
(save-window-excursion
|
||||
(or (org-babel-comint-buffer-livep session)
|
||||
(progn
|
||||
(shell session)
|
||||
;; Needed for Emacs 23 since the marker is initially
|
||||
;; undefined and the filter functions try to use it without
|
||||
;; checking.
|
||||
(set-marker comint-last-output-start (point))
|
||||
(get-buffer (current-buffer)))))))
|
||||
|
||||
(defvar org-babel-sh-eoe-indicator "echo 'org_babel_sh_eoe'"
|
||||
"String to indicate that evaluation has completed.")
|
||||
(defvar org-babel-sh-eoe-output "org_babel_sh_eoe"
|
||||
"String to indicate that evaluation has completed.")
|
||||
|
||||
(defun org-babel-sh-evaluate (session body &optional params stdin cmdline)
|
||||
"Pass BODY to the Shell process in BUFFER.
|
||||
If RESULT-TYPE equals `output' then return a list of the outputs
|
||||
of the statements in BODY, if RESULT-TYPE equals `value' then
|
||||
return the value of the last statement in BODY."
|
||||
(let ((results
|
||||
(cond
|
||||
((or stdin cmdline) ; external shell script w/STDIN
|
||||
(let ((script-file (org-babel-temp-file "sh-script-"))
|
||||
(stdin-file (org-babel-temp-file "sh-stdin-"))
|
||||
(shebang (cdr (assoc :shebang params)))
|
||||
(padline (not (string= "no" (cdr (assoc :padline params))))))
|
||||
(with-temp-file script-file
|
||||
(when shebang (insert (concat shebang "\n")))
|
||||
(when padline (insert "\n"))
|
||||
(insert body))
|
||||
(set-file-modes script-file #o755)
|
||||
(with-temp-file stdin-file (insert (or stdin "")))
|
||||
(with-temp-buffer
|
||||
(call-process-shell-command
|
||||
(concat (if shebang script-file
|
||||
(format "%s %s" shell-file-name script-file))
|
||||
(and cmdline (concat " " cmdline)))
|
||||
stdin-file
|
||||
(current-buffer))
|
||||
(buffer-string))))
|
||||
(session ; session evaluation
|
||||
(mapconcat
|
||||
#'org-babel-sh-strip-weird-long-prompt
|
||||
(mapcar
|
||||
#'org-babel-trim
|
||||
(butlast
|
||||
(org-babel-comint-with-output
|
||||
(session org-babel-sh-eoe-output t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert line)
|
||||
(comint-send-input nil t)
|
||||
(while (save-excursion
|
||||
(goto-char comint-last-input-end)
|
||||
(not (re-search-forward
|
||||
comint-prompt-regexp nil t)))
|
||||
(accept-process-output
|
||||
(get-buffer-process (current-buffer)))))
|
||||
(append
|
||||
(split-string (org-babel-trim body) "\n")
|
||||
(list org-babel-sh-eoe-indicator))))
|
||||
2)) "\n"))
|
||||
('otherwise ; external shell script
|
||||
(if (and (cdr (assoc :shebang params))
|
||||
(> (length (cdr (assoc :shebang params))) 0))
|
||||
(let ((script-file (org-babel-temp-file "sh-script-"))
|
||||
(shebang (cdr (assoc :shebang params)))
|
||||
(padline (not (equal "no" (cdr (assoc :padline params))))))
|
||||
(with-temp-file script-file
|
||||
(when shebang (insert (concat shebang "\n")))
|
||||
(when padline (insert "\n"))
|
||||
(insert body))
|
||||
(set-file-modes script-file #o755)
|
||||
(org-babel-eval script-file ""))
|
||||
(org-babel-eval shell-file-name (org-babel-trim body)))))))
|
||||
(when results
|
||||
(let ((result-params (cdr (assoc :result-params params))))
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(let ((tmp-file (org-babel-temp-file "sh-")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))))))
|
||||
|
||||
(defun org-babel-sh-strip-weird-long-prompt (string)
|
||||
"Remove prompt cruft from a string of shell output."
|
||||
(while (string-match "^% +[\r\n$]+ *" string)
|
||||
(setq string (substring string (match-end 0))))
|
||||
string)
|
||||
|
||||
(provide 'ob-shell)
|
||||
|
||||
|
||||
|
||||
;;; ob-shell.el ends here
|
79
elpa/org-20160919/ob-shen.el
Normal file
79
elpa/org-20160919/ob-shen.el
Normal file
@ -0,0 +1,79 @@
|
||||
;;; ob-shen.el --- org-babel functions for Shen
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, shen
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Currently this only works using session evaluation as there is no
|
||||
;; defined method for executing shen code outside of a session.
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
;; - shen-mode and inf-shen will soon be available through the GNU
|
||||
;; elpa, however in the interim they are available at
|
||||
;; https://github.com/eschulte/shen-mode
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function shen-eval-defun "ext:inf-shen" (&optional and-go))
|
||||
(declare-function org-babel-ruby-var-to-ruby "ob-ruby" (var))
|
||||
|
||||
(defvar org-babel-default-header-args:shen '()
|
||||
"Default header arguments for shen code blocks.")
|
||||
|
||||
(defun org-babel-expand-body:shen (body params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
(if (> (length vars) 0)
|
||||
(concat "(let "
|
||||
(mapconcat (lambda (var)
|
||||
(format "%s %s" (car var)
|
||||
(org-babel-shen-var-to-shen (cdr var))))
|
||||
vars " ")
|
||||
body ")")
|
||||
body)))
|
||||
|
||||
(defun org-babel-shen-var-to-shen (var)
|
||||
"Convert VAR into a shen variable."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var " ") "]")
|
||||
(format "%S" var)))
|
||||
|
||||
(defun org-babel-execute:shen (body params)
|
||||
"Execute a block of Shen code with org-babel.
|
||||
This function is called by `org-babel-execute-src-block'"
|
||||
(require 'inf-shen)
|
||||
(let* ((result-type (cdr (assoc :result-type params)))
|
||||
(result-params (cdr (assoc :result-params params)))
|
||||
(full-body (org-babel-expand-body:shen body params)))
|
||||
(let ((results
|
||||
(with-temp-buffer
|
||||
(insert full-body)
|
||||
(call-interactively #'shen-eval-defun))))
|
||||
(org-babel-result-cond result-params
|
||||
results
|
||||
(condition-case nil (org-babel-script-escape results)
|
||||
(error results))))))
|
||||
|
||||
(provide 'ob-shen)
|
||||
;;; ob-shen.el ends here
|
228
elpa/org-20160919/ob-sql.el
Normal file
228
elpa/org-20160919/ob-sql.el
Normal file
@ -0,0 +1,228 @@
|
||||
;;; ob-sql.el --- org-babel functions for sql evaluation
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating sql source code.
|
||||
;; (see also ob-sqlite.el)
|
||||
;;
|
||||
;; SQL is somewhat unique in that there are many different engines for
|
||||
;; the evaluation of sql (Mysql, PostgreSQL, etc...), so much of this
|
||||
;; file will have to be implemented engine by engine.
|
||||
;;
|
||||
;; Also SQL evaluation generally takes place inside of a database.
|
||||
;;
|
||||
;; Header args used:
|
||||
;; - engine
|
||||
;; - cmdline
|
||||
;; - dbhost
|
||||
;; - dbport
|
||||
;; - dbuser
|
||||
;; - dbpassword
|
||||
;; - database
|
||||
;; - colnames (default, nil, means "yes")
|
||||
;; - result-params
|
||||
;; - out-file
|
||||
;; The following are used but not really implemented for SQL:
|
||||
;; - colname-names
|
||||
;; - rownames
|
||||
;; - rowname-names
|
||||
;;
|
||||
;; TODO:
|
||||
;;
|
||||
;; - support for sessions
|
||||
;; - support for more engines (currently only supports mysql)
|
||||
;; - what's a reasonable way to drop table data into SQL?
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-table-import "org-table" (file arg))
|
||||
(declare-function orgtbl-to-csv "org-table" (table params))
|
||||
(declare-function org-table-to-lisp "org-table" (&optional txt))
|
||||
|
||||
(defvar org-babel-default-header-args:sql '())
|
||||
|
||||
(defconst org-babel-header-args:sql
|
||||
'((engine . :any)
|
||||
(out-file . :any)
|
||||
(dbhost . :any)
|
||||
(dbport . :any)
|
||||
(dbuser . :any)
|
||||
(dbpassword . :any)
|
||||
(database . :any))
|
||||
"SQL-specific header arguments.")
|
||||
|
||||
(defun org-babel-expand-body:sql (body params)
|
||||
"Expand BODY according to the values of PARAMS."
|
||||
(org-babel-sql-expand-vars
|
||||
body (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defun org-babel-sql-dbstring-mysql (host port user password database)
|
||||
"Make MySQL cmd line args for database connection. Pass nil to omit that arg."
|
||||
(combine-and-quote-strings
|
||||
(delq nil
|
||||
(list (when host (concat "-h" host))
|
||||
(when port (format "-P%d" port))
|
||||
(when user (concat "-u" user))
|
||||
(when password (concat "-p" password))
|
||||
(when database (concat "-D" database))))))
|
||||
|
||||
(defun org-babel-sql-dbstring-postgresql (host user database)
|
||||
"Make PostgreSQL command line args for database connection.
|
||||
Pass nil to omit that arg."
|
||||
(combine-and-quote-strings
|
||||
(delq nil
|
||||
(list (when host (concat "-h" host))
|
||||
(when user (concat "-U" user))
|
||||
(when database (concat "-d" database))))))
|
||||
|
||||
(defun org-babel-execute:sql (body params)
|
||||
"Execute a block of Sql code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let* ((result-params (cdr (assoc :result-params params)))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
(dbhost (cdr (assoc :dbhost params)))
|
||||
(dbport (cdr (assq :dbport params)))
|
||||
(dbuser (cdr (assoc :dbuser params)))
|
||||
(dbpassword (cdr (assoc :dbpassword params)))
|
||||
(database (cdr (assoc :database params)))
|
||||
(engine (cdr (assoc :engine params)))
|
||||
(colnames-p (not (equal "no" (cdr (assoc :colnames params)))))
|
||||
(in-file (org-babel-temp-file "sql-in-"))
|
||||
(out-file (or (cdr (assoc :out-file params))
|
||||
(org-babel-temp-file "sql-out-")))
|
||||
(header-delim "")
|
||||
(command (case (intern engine)
|
||||
('dbi (format "dbish --batch %s < %s | sed '%s' > %s"
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
"/^+/d;s/^|//;s/(NULL)/ /g;$d"
|
||||
(org-babel-process-file-name out-file)))
|
||||
('monetdb (format "mclient -f tab %s < %s > %s"
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
(org-babel-process-file-name out-file)))
|
||||
('msosql (format "osql %s -s \"\t\" -i %s -o %s"
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
(org-babel-process-file-name out-file)))
|
||||
('mysql (format "mysql %s %s %s < %s > %s"
|
||||
(org-babel-sql-dbstring-mysql
|
||||
dbhost dbport dbuser dbpassword database)
|
||||
(if colnames-p "" "-N")
|
||||
(or cmdline "")
|
||||
(org-babel-process-file-name in-file)
|
||||
(org-babel-process-file-name out-file)))
|
||||
('postgresql (format
|
||||
"psql --set=\"ON_ERROR_STOP=1\" %s -A -P footer=off -F \"\t\" %s -f %s -o %s %s"
|
||||
(if colnames-p "" "-t")
|
||||
(org-babel-sql-dbstring-postgresql dbhost dbuser database)
|
||||
(org-babel-process-file-name in-file)
|
||||
(org-babel-process-file-name out-file)
|
||||
(or cmdline "")))
|
||||
(t (error "No support for the %s SQL engine" engine)))))
|
||||
(with-temp-file in-file
|
||||
(insert
|
||||
(case (intern engine)
|
||||
('dbi "/format partbox\n")
|
||||
(t ""))
|
||||
(org-babel-expand-body:sql body params)))
|
||||
(message command)
|
||||
(org-babel-eval command "")
|
||||
(org-babel-result-cond result-params
|
||||
(with-temp-buffer
|
||||
(progn (insert-file-contents-literally out-file) (buffer-string)))
|
||||
(with-temp-buffer
|
||||
(cond
|
||||
((or (eq (intern engine) 'mysql)
|
||||
(eq (intern engine) 'dbi)
|
||||
(eq (intern engine) 'postgresql))
|
||||
;; Add header row delimiter after column-names header in first line
|
||||
(cond
|
||||
(colnames-p
|
||||
(with-temp-buffer
|
||||
(insert-file-contents out-file)
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(insert "-\n")
|
||||
(setq header-delim "-")
|
||||
(write-file out-file)))))
|
||||
(t
|
||||
;; Need to figure out the delimiter for the header row
|
||||
(with-temp-buffer
|
||||
(insert-file-contents out-file)
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^\\(-+\\)[^-]" nil t)
|
||||
(setq header-delim (match-string-no-properties 1)))
|
||||
(goto-char (point-max))
|
||||
(forward-char -1)
|
||||
(while (looking-at "\n")
|
||||
(delete-char 1)
|
||||
(goto-char (point-max))
|
||||
(forward-char -1))
|
||||
(write-file out-file))))
|
||||
(org-table-import out-file '(16))
|
||||
(org-babel-reassemble-table
|
||||
(mapcar (lambda (x)
|
||||
(if (string= (car x) header-delim)
|
||||
'hline
|
||||
x))
|
||||
(org-table-to-lisp))
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params))))))))
|
||||
|
||||
(defun org-babel-sql-expand-vars (body vars)
|
||||
"Expand the variables held in VARS in BODY."
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(format "$%s" (car pair))
|
||||
(let ((val (cdr pair)))
|
||||
(if (listp val)
|
||||
(let ((data-file (org-babel-temp-file "sql-data-")))
|
||||
(with-temp-file data-file
|
||||
(insert (orgtbl-to-csv
|
||||
val '(:fmt (lambda (el) (if (stringp el)
|
||||
el
|
||||
(format "%S" el)))))))
|
||||
data-file)
|
||||
(if (stringp val) val (format "%S" val))))
|
||||
body)))
|
||||
vars)
|
||||
body)
|
||||
|
||||
(defun org-babel-prep-session:sql (session params)
|
||||
"Raise an error because Sql sessions aren't implemented."
|
||||
(error "SQL sessions not yet implemented"))
|
||||
|
||||
(provide 'ob-sql)
|
||||
|
||||
|
||||
|
||||
;;; ob-sql.el ends here
|
162
elpa/org-20160919/ob-sqlite.el
Normal file
162
elpa/org-20160919/ob-sqlite.el
Normal file
@ -0,0 +1,162 @@
|
||||
;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating sqlite source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function org-fill-template "org" (template alist))
|
||||
(declare-function org-table-convert-region "org-table"
|
||||
(beg0 end0 &optional separator))
|
||||
(declare-function orgtbl-to-csv "org-table" (table params))
|
||||
(declare-function org-table-to-lisp "org-table" (&optional txt))
|
||||
|
||||
(defvar org-babel-default-header-args:sqlite '())
|
||||
|
||||
(defvar org-babel-header-args:sqlite
|
||||
'((db . :any)
|
||||
(header . :any)
|
||||
(echo . :any)
|
||||
(bail . :any)
|
||||
(csv . :any)
|
||||
(column . :any)
|
||||
(html . :any)
|
||||
(line . :any)
|
||||
(list . :any)
|
||||
(separator . :any)
|
||||
(nullvalue . :any))
|
||||
"Sqlite specific header args.")
|
||||
|
||||
(defun org-babel-expand-body:sqlite (body params)
|
||||
"Expand BODY according to the values of PARAMS."
|
||||
(org-babel-sqlite-expand-vars
|
||||
body (mapcar #'cdr (org-babel-get-header params :var))))
|
||||
|
||||
(defvar org-babel-sqlite3-command "sqlite3")
|
||||
|
||||
(defun org-babel-execute:sqlite (body params)
|
||||
"Execute a block of Sqlite code with Babel.
|
||||
This function is called by `org-babel-execute-src-block'."
|
||||
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(db (cdr (assoc :db params)))
|
||||
(separator (cdr (assoc :separator params)))
|
||||
(nullvalue (cdr (assoc :nullvalue params)))
|
||||
(headers-p (equal "yes" (cdr (assoc :colnames params))))
|
||||
(others (delq nil (mapcar
|
||||
(lambda (arg) (car (assoc arg params)))
|
||||
(list :header :echo :bail :column
|
||||
:csv :html :line :list))))
|
||||
exit-code)
|
||||
(unless db (error "ob-sqlite: can't evaluate without a database"))
|
||||
(with-temp-buffer
|
||||
(insert
|
||||
(org-babel-eval
|
||||
(org-fill-template
|
||||
"%cmd %header %separator %nullvalue %others %csv %db "
|
||||
(list
|
||||
(cons "cmd" org-babel-sqlite3-command)
|
||||
(cons "header" (if headers-p "-header" "-noheader"))
|
||||
(cons "separator"
|
||||
(if separator (format "-separator %s" separator) ""))
|
||||
(cons "nullvalue"
|
||||
(if nullvalue (format "-nullvalue %s" nullvalue) ""))
|
||||
(cons "others"
|
||||
(mapconcat
|
||||
(lambda (arg) (format "-%s" (substring (symbol-name arg) 1)))
|
||||
others " "))
|
||||
;; for easy table parsing, default header type should be -csv
|
||||
(cons "csv" (if (or (member :csv others) (member :column others)
|
||||
(member :line others) (member :list others)
|
||||
(member :html others) separator)
|
||||
""
|
||||
"-csv"))
|
||||
(cons "db " db)))
|
||||
;; body of the code block
|
||||
(org-babel-expand-body:sqlite body params)))
|
||||
(org-babel-result-cond result-params
|
||||
(buffer-string)
|
||||
(if (equal (point-min) (point-max))
|
||||
""
|
||||
(org-table-convert-region (point-min) (point-max)
|
||||
(if (or (member :csv others)
|
||||
(member :column others)
|
||||
(member :line others)
|
||||
(member :list others)
|
||||
(member :html others) separator)
|
||||
nil
|
||||
'(4)))
|
||||
(org-babel-sqlite-table-or-scalar
|
||||
(org-babel-sqlite-offset-colnames
|
||||
(org-table-to-lisp) headers-p)))))))
|
||||
|
||||
(defun org-babel-sqlite-expand-vars (body vars)
|
||||
"Expand the variables held in VARS in BODY."
|
||||
;; FIXME: Redundancy with org-babel-sql-expand-vars!
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(format "$%s" (car pair))
|
||||
(let ((val (cdr pair)))
|
||||
(if (listp val)
|
||||
(let ((data-file (org-babel-temp-file "sqlite-data-")))
|
||||
(with-temp-file data-file
|
||||
(insert (orgtbl-to-csv
|
||||
val '(:fmt (lambda (el) (if (stringp el)
|
||||
el
|
||||
(format "%S" el)))))))
|
||||
data-file)
|
||||
(if (stringp val) val (format "%S" val))))
|
||||
body)))
|
||||
vars)
|
||||
body)
|
||||
|
||||
(defun org-babel-sqlite-table-or-scalar (result)
|
||||
"If RESULT looks like a trivial table, then unwrap it."
|
||||
(if (and (equal 1 (length result))
|
||||
(equal 1 (length (car result))))
|
||||
(org-babel-read (caar result))
|
||||
(mapcar (lambda (row)
|
||||
(if (equal 'hline row)
|
||||
'hline
|
||||
(mapcar #'org-babel-string-read row))) result)))
|
||||
|
||||
(defun org-babel-sqlite-offset-colnames (table headers-p)
|
||||
"If HEADERS-P is non-nil then offset the first row as column names."
|
||||
(if headers-p
|
||||
(cons (car table) (cons 'hline (cdr table)))
|
||||
table))
|
||||
|
||||
(defun org-babel-prep-session:sqlite (session params)
|
||||
"Raise an error because support for SQLite sessions isn't implemented.
|
||||
Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "SQLite sessions not yet implemented"))
|
||||
|
||||
(provide 'ob-sqlite)
|
||||
|
||||
|
||||
|
||||
;;; ob-sqlite.el ends here
|
0
elpa/org-20160919/ob-stan.el
Normal file
0
elpa/org-20160919/ob-stan.el
Normal file
151
elpa/org-20160919/ob-table.el
Normal file
151
elpa/org-20160919/ob-table.el
Normal file
@ -0,0 +1,151 @@
|
||||
;;; ob-table.el --- support for calling org-babel functions from tables
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Should allow calling functions from org-mode tables using the
|
||||
;; function `org-sbe' as so...
|
||||
|
||||
;; #+begin_src emacs-lisp :results silent
|
||||
;; (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
|
||||
;; #+end_src
|
||||
|
||||
;; #+name: fibbd
|
||||
;; #+begin_src emacs-lisp :var n=2 :results silent
|
||||
;; (fibbd n)
|
||||
;; #+end_src
|
||||
|
||||
;; | original | fibbd |
|
||||
;; |----------+--------|
|
||||
;; | 0 | |
|
||||
;; | 1 | |
|
||||
;; | 2 | |
|
||||
;; | 3 | |
|
||||
;; | 4 | |
|
||||
;; | 5 | |
|
||||
;; | 6 | |
|
||||
;; | 7 | |
|
||||
;; | 8 | |
|
||||
;; | 9 | |
|
||||
;; #+TBLFM: $2='(org-sbe "fibbd" (n $1))
|
||||
|
||||
;; NOTE: The quotation marks around the function name, 'fibbd' here,
|
||||
;; are optional.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob-core)
|
||||
|
||||
(defun org-babel-table-truncate-at-newline (string)
|
||||
"Replace newline character with ellipses.
|
||||
If STRING ends in a newline character, then remove the newline
|
||||
character and replace it with ellipses."
|
||||
(if (and (stringp string) (string-match "[\n\r]\\(.\\)?" string))
|
||||
(concat (substring string 0 (match-beginning 0))
|
||||
(if (match-string 1 string) "...")) string))
|
||||
|
||||
(defmacro org-sbe (source-block &rest variables)
|
||||
"Return the results of calling SOURCE-BLOCK with VARIABLES.
|
||||
|
||||
Each element of VARIABLES should be a list of two elements: the
|
||||
first element is the name of the variable and second element is a
|
||||
string of its value.
|
||||
|
||||
So this `org-sbe' construct
|
||||
|
||||
(org-sbe \"source-block\" (n $2) (m 3))
|
||||
|
||||
is the equivalent of the following source code block:
|
||||
|
||||
#+begin_src emacs-lisp :var results=source-block(n=val_at_col_2, m=3) :results silent
|
||||
results
|
||||
#+end_src
|
||||
|
||||
NOTE: The quotation marks around the function name,
|
||||
'source-block', are optional.
|
||||
|
||||
NOTE: By default, string variable names are interpreted as
|
||||
references to source-code blocks, to force interpretation of a
|
||||
cell's value as a string, prefix the identifier a \"$\" (e.g.,
|
||||
\"$$2\" instead of \"$2\" or \"$@2$2\" instead of \"@2$2\").
|
||||
|
||||
NOTE: It is also possible to pass header arguments to the code
|
||||
block. In this case a table cell should hold the string value of
|
||||
the header argument which can then be passed before all variables
|
||||
as shown in the example below.
|
||||
|
||||
| 1 | 2 | :file nothing.png | nothing.png |
|
||||
#+TBLFM: @1$4=\\='(org-sbe test-sbe $3 (x $1) (y $2))"
|
||||
(declare (debug (form form)))
|
||||
(let* ((header-args (if (stringp (car variables)) (car variables) ""))
|
||||
(variables (if (stringp (car variables)) (cdr variables) variables)))
|
||||
(let* (quote
|
||||
(variables
|
||||
(mapcar
|
||||
(lambda (var)
|
||||
;; ensure that all cells prefixed with $'s are strings
|
||||
(cons (car var)
|
||||
(delq nil (mapcar
|
||||
(lambda (el)
|
||||
(if (eq '$ el)
|
||||
(prog1 nil (setq quote t))
|
||||
(prog1
|
||||
(cond
|
||||
(quote (format "\"%s\"" el))
|
||||
((stringp el) (org-no-properties el))
|
||||
(t el))
|
||||
(setq quote nil))))
|
||||
(cdr var)))))
|
||||
variables)))
|
||||
(unless (stringp source-block)
|
||||
(setq source-block (symbol-name source-block)))
|
||||
(let ((result
|
||||
(if (and source-block (> (length source-block) 0))
|
||||
(let ((params
|
||||
;; FIXME: Why `eval'?!?!?
|
||||
(eval `(org-babel-parse-header-arguments
|
||||
(concat
|
||||
":var results="
|
||||
,source-block
|
||||
"[" ,header-args "]"
|
||||
"("
|
||||
(mapconcat
|
||||
(lambda (var-spec)
|
||||
(if (> (length (cdr var-spec)) 1)
|
||||
(format "%S='%S"
|
||||
(car var-spec)
|
||||
(mapcar #'read (cdr var-spec)))
|
||||
(format "%S=%s"
|
||||
(car var-spec) (cadr var-spec))))
|
||||
',variables ", ")
|
||||
")")))))
|
||||
(org-babel-execute-src-block
|
||||
nil (list "emacs-lisp" "results" params)
|
||||
'((:results . "silent"))))
|
||||
"")))
|
||||
(org-babel-trim (if (stringp result) result (format "%S" result)))))))
|
||||
|
||||
(provide 'ob-table)
|
||||
|
||||
|
||||
|
||||
;;; ob-table.el ends here
|
609
elpa/org-20160919/ob-tangle.el
Normal file
609
elpa/org-20160919/ob-tangle.el
Normal file
@ -0,0 +1,609 @@
|
||||
;;; ob-tangle.el --- extract source code from org-mode files
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Extract the code from source blocks out into raw source-code files.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-src)
|
||||
|
||||
(declare-function make-directory "files" (dir &optional parents))
|
||||
(declare-function org-at-heading-p "org" (&optional ignored))
|
||||
(declare-function org-babel-update-block-body "ob-core" (new-body))
|
||||
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
||||
(declare-function org-before-first-heading-p "org" ())
|
||||
(declare-function org-edit-special "org" (&optional arg))
|
||||
(declare-function org-element-at-point "org-element" ())
|
||||
(declare-function org-element-type "org-element" (element))
|
||||
(declare-function org-fill-template "org" (template alist))
|
||||
(declare-function org-heading-components "org" ())
|
||||
(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
|
||||
(declare-function org-link-escape "org" (text &optional table merge))
|
||||
(declare-function org-open-link-from-string "org" (s &optional arg reference-buffer))
|
||||
(declare-function org-store-link "org" (arg))
|
||||
(declare-function org-string-nw-p "org-macs" (s))
|
||||
(declare-function outline-previous-heading "outline" ())
|
||||
|
||||
(defvar org-link-types-re)
|
||||
|
||||
(defcustom org-babel-tangle-lang-exts
|
||||
'(("emacs-lisp" . "el")
|
||||
("elisp" . "el"))
|
||||
"Alist mapping languages to their file extensions.
|
||||
The key is the language name, the value is the string that should
|
||||
be inserted as the extension commonly used to identify files
|
||||
written in this language. If no entry is found in this list,
|
||||
then the name of the language is used."
|
||||
:group 'org-babel-tangle
|
||||
:version "24.1"
|
||||
:type '(repeat
|
||||
(cons
|
||||
(string "Language name")
|
||||
(string "File Extension"))))
|
||||
|
||||
(defcustom org-babel-tangle-use-relative-file-links t
|
||||
"Use relative path names in links from tangled source back the Org-mode file."
|
||||
:group 'org-babel-tangle
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-babel-post-tangle-hook nil
|
||||
"Hook run in code files tangled by `org-babel-tangle'."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-babel-pre-tangle-hook '(save-buffer)
|
||||
"Hook run at the beginning of `org-babel-tangle'."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-babel-tangle-body-hook nil
|
||||
"Hook run over the contents of each code block body."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-babel-tangle-comment-format-beg "[[%link][%source-name]]"
|
||||
"Format of inserted comments in tangled code files.
|
||||
The following format strings can be used to insert special
|
||||
information into the output using `org-fill-template'.
|
||||
%start-line --- the line number at the start of the code block
|
||||
%file --------- the file from which the code block was tangled
|
||||
%link --------- Org-mode style link to the code block
|
||||
%source-name -- name of the code block
|
||||
|
||||
Upon insertion the formatted comment will be commented out, and
|
||||
followed by a newline. To inhibit this post-insertion processing
|
||||
set the `org-babel-tangle-uncomment-comments' variable to a
|
||||
non-nil value.
|
||||
|
||||
Whether or not comments are inserted during tangling is
|
||||
controlled by the :comments header argument."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-tangle-comment-format-end "%source-name ends here"
|
||||
"Format of inserted comments in tangled code files.
|
||||
The following format strings can be used to insert special
|
||||
information into the output using `org-fill-template'.
|
||||
%start-line --- the line number at the start of the code block
|
||||
%file --------- the file from which the code block was tangled
|
||||
%link --------- Org-mode style link to the code block
|
||||
%source-name -- name of the code block
|
||||
|
||||
Upon insertion the formatted comment will be commented out, and
|
||||
followed by a newline. To inhibit this post-insertion processing
|
||||
set the `org-babel-tangle-uncomment-comments' variable to a
|
||||
non-nil value.
|
||||
|
||||
Whether or not comments are inserted during tangling is
|
||||
controlled by the :comments header argument."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-babel-tangle-uncomment-comments nil
|
||||
"Inhibits automatic commenting and addition of trailing newline
|
||||
of tangle comments. Use `org-babel-tangle-comment-format-beg'
|
||||
and `org-babel-tangle-comment-format-end' to customize the format
|
||||
of tangled comments."
|
||||
:group 'org-babel
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-babel-process-comment-text #'org-remove-indentation
|
||||
"Function called to process raw Org-mode text collected to be
|
||||
inserted as comments in tangled source-code files. The function
|
||||
should take a single string argument and return a string
|
||||
result. The default value is `org-remove-indentation'."
|
||||
:group 'org-babel
|
||||
:version "24.1"
|
||||
:type 'function)
|
||||
|
||||
(defun org-babel-find-file-noselect-refresh (file)
|
||||
"Find file ensuring that the latest changes on disk are
|
||||
represented in the file."
|
||||
(find-file-noselect file 'nowarn)
|
||||
(with-current-buffer (get-file-buffer file)
|
||||
(revert-buffer t t t)))
|
||||
|
||||
(defmacro org-babel-with-temp-filebuffer (file &rest body)
|
||||
"Open FILE into a temporary buffer execute BODY there like
|
||||
`progn', then kill the FILE buffer returning the result of
|
||||
evaluating BODY."
|
||||
(declare (indent 1))
|
||||
(let ((temp-path (make-symbol "temp-path"))
|
||||
(temp-result (make-symbol "temp-result"))
|
||||
(temp-file (make-symbol "temp-file"))
|
||||
(visited-p (make-symbol "visited-p")))
|
||||
`(let* ((,temp-path ,file)
|
||||
(,visited-p (get-file-buffer ,temp-path))
|
||||
,temp-result ,temp-file)
|
||||
(org-babel-find-file-noselect-refresh ,temp-path)
|
||||
(setf ,temp-file (get-file-buffer ,temp-path))
|
||||
(with-current-buffer ,temp-file
|
||||
(setf ,temp-result (progn ,@body)))
|
||||
(unless ,visited-p (kill-buffer ,temp-file))
|
||||
,temp-result)))
|
||||
(def-edebug-spec org-babel-with-temp-filebuffer (form body))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-tangle-file (file &optional target-file lang)
|
||||
"Extract the bodies of source code blocks in FILE.
|
||||
Source code blocks are extracted with `org-babel-tangle'.
|
||||
Optional argument TARGET-FILE can be used to specify a default
|
||||
export file for all source blocks. Optional argument LANG can be
|
||||
used to limit the exported source code blocks by language.
|
||||
Return a list whose CAR is the tangled file name."
|
||||
(interactive "fFile to tangle: \nP")
|
||||
(let ((visited-p (get-file-buffer (expand-file-name file)))
|
||||
to-be-removed)
|
||||
(prog1
|
||||
(save-window-excursion
|
||||
(find-file file)
|
||||
(setq to-be-removed (current-buffer))
|
||||
(mapcar #'expand-file-name (org-babel-tangle nil target-file lang)))
|
||||
(unless visited-p
|
||||
(kill-buffer to-be-removed)))))
|
||||
|
||||
(defun org-babel-tangle-publish (_ filename pub-dir)
|
||||
"Tangle FILENAME and place the results in PUB-DIR."
|
||||
(unless (file-exists-p pub-dir)
|
||||
(make-directory pub-dir t))
|
||||
(mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-tangle (&optional arg target-file lang)
|
||||
"Write code blocks to source-specific files.
|
||||
Extract the bodies of all source code blocks from the current
|
||||
file into their own source-specific files.
|
||||
With one universal prefix argument, only tangle the block at point.
|
||||
When two universal prefix arguments, only tangle blocks for the
|
||||
tangle file of the block at point.
|
||||
Optional argument TARGET-FILE can be used to specify a default
|
||||
export file for all source blocks. Optional argument LANG can be
|
||||
used to limit the exported source code blocks by language."
|
||||
(interactive "P")
|
||||
(run-hooks 'org-babel-pre-tangle-hook)
|
||||
;; Possibly Restrict the buffer to the current code block
|
||||
(save-restriction
|
||||
(save-excursion
|
||||
(when (equal arg '(4))
|
||||
(let ((head (org-babel-where-is-src-block-head)))
|
||||
(if head
|
||||
(goto-char head)
|
||||
(user-error "Point is not in a source code block"))))
|
||||
(let ((block-counter 0)
|
||||
(org-babel-default-header-args
|
||||
(if target-file
|
||||
(org-babel-merge-params org-babel-default-header-args
|
||||
(list (cons :tangle target-file)))
|
||||
org-babel-default-header-args))
|
||||
(tangle-file
|
||||
(when (equal arg '(16))
|
||||
(or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info 'light))))
|
||||
(user-error "Point is not in a source code block"))))
|
||||
path-collector)
|
||||
(mapc ;; map over all languages
|
||||
(lambda (by-lang)
|
||||
(let* ((lang (car by-lang))
|
||||
(specs (cdr by-lang))
|
||||
(ext (or (cdr (assoc lang org-babel-tangle-lang-exts)) lang))
|
||||
(lang-f (intern
|
||||
(concat
|
||||
(or (and (cdr (assoc lang org-src-lang-modes))
|
||||
(symbol-name
|
||||
(cdr (assoc lang org-src-lang-modes))))
|
||||
lang)
|
||||
"-mode")))
|
||||
she-banged)
|
||||
(mapc
|
||||
(lambda (spec)
|
||||
(let ((get-spec (lambda (name) (cdr (assoc name (nth 4 spec))))))
|
||||
(let* ((tangle (funcall get-spec :tangle))
|
||||
(she-bang (let ((sheb (funcall get-spec :shebang)))
|
||||
(when (> (length sheb) 0) sheb)))
|
||||
(tangle-mode (funcall get-spec :tangle-mode))
|
||||
(base-name (cond
|
||||
((string= "yes" tangle)
|
||||
(file-name-sans-extension
|
||||
(nth 1 spec)))
|
||||
((string= "no" tangle) nil)
|
||||
((> (length tangle) 0) tangle)))
|
||||
(file-name (when base-name
|
||||
;; decide if we want to add ext to base-name
|
||||
(if (and ext (string= "yes" tangle))
|
||||
(concat base-name "." ext) base-name))))
|
||||
(when file-name
|
||||
;; Possibly create the parent directories for file.
|
||||
(let ((m (funcall get-spec :mkdirp))
|
||||
(fnd (file-name-directory file-name)))
|
||||
(and m fnd (not (string= m "no"))
|
||||
(make-directory fnd 'parents)))
|
||||
;; delete any old versions of file
|
||||
(and (file-exists-p file-name)
|
||||
(not (member file-name (mapcar #'car path-collector)))
|
||||
(delete-file file-name))
|
||||
;; drop source-block to file
|
||||
(with-temp-buffer
|
||||
(when (fboundp lang-f) (ignore-errors (funcall lang-f)))
|
||||
(when (and she-bang (not (member file-name she-banged)))
|
||||
(insert (concat she-bang "\n"))
|
||||
(setq she-banged (cons file-name she-banged)))
|
||||
(org-babel-spec-to-string spec)
|
||||
;; We avoid append-to-file as it does not work with tramp.
|
||||
(let ((content (buffer-string)))
|
||||
(with-temp-buffer
|
||||
(if (file-exists-p file-name)
|
||||
(insert-file-contents file-name))
|
||||
(goto-char (point-max))
|
||||
;; Handle :padlines unless first line in file
|
||||
(unless (or (string= "no" (cdr (assoc :padline (nth 4 spec))))
|
||||
(= (point) (point-min)))
|
||||
(insert "\n"))
|
||||
(insert content)
|
||||
(write-region nil nil file-name))))
|
||||
;; if files contain she-bangs, then make the executable
|
||||
(when she-bang
|
||||
(unless tangle-mode (setq tangle-mode #o755)))
|
||||
;; update counter
|
||||
(setq block-counter (+ 1 block-counter))
|
||||
(add-to-list 'path-collector
|
||||
(cons file-name tangle-mode)
|
||||
nil
|
||||
(lambda (a b) (equal (car a) (car b))))))))
|
||||
specs)))
|
||||
(if (equal arg '(4))
|
||||
(org-babel-tangle-single-block 1 t)
|
||||
(org-babel-tangle-collect-blocks lang tangle-file)))
|
||||
(message "Tangled %d code block%s from %s" block-counter
|
||||
(if (= block-counter 1) "" "s")
|
||||
(file-name-nondirectory
|
||||
(buffer-file-name
|
||||
(or (buffer-base-buffer) (current-buffer)))))
|
||||
;; run `org-babel-post-tangle-hook' in all tangled files
|
||||
(when org-babel-post-tangle-hook
|
||||
(mapc
|
||||
(lambda (file)
|
||||
(org-babel-with-temp-filebuffer file
|
||||
(run-hooks 'org-babel-post-tangle-hook)))
|
||||
(mapcar #'car path-collector)))
|
||||
;; set permissions on tangled files
|
||||
(mapc (lambda (pair)
|
||||
(when (cdr pair) (set-file-modes (car pair) (cdr pair))))
|
||||
path-collector)
|
||||
(mapcar #'car path-collector)))))
|
||||
|
||||
(defun org-babel-tangle-clean ()
|
||||
"Remove comments inserted by `org-babel-tangle'.
|
||||
Call this function inside of a source-code file generated by
|
||||
`org-babel-tangle' to remove all comments inserted automatically
|
||||
by `org-babel-tangle'. Warning, this comment removes any lines
|
||||
containing constructs which resemble org-mode file links or noweb
|
||||
references."
|
||||
(interactive)
|
||||
(goto-char (point-min))
|
||||
(while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t)
|
||||
(re-search-forward (org-babel-noweb-wrap) nil t))
|
||||
(delete-region (save-excursion (beginning-of-line 1) (point))
|
||||
(save-excursion (end-of-line 1) (forward-char 1) (point)))))
|
||||
|
||||
(defvar org-stored-links)
|
||||
(defvar org-bracket-link-regexp)
|
||||
(defun org-babel-spec-to-string (spec)
|
||||
"Insert SPEC into the current file.
|
||||
|
||||
Insert the source-code specified by SPEC into the current source
|
||||
code file. This function uses `comment-region' which assumes
|
||||
that the appropriate major-mode is set. SPEC has the form:
|
||||
|
||||
(start-line file link source-name params body comment)"
|
||||
(let* ((start-line (nth 0 spec))
|
||||
(info (nth 4 spec))
|
||||
(file (if org-babel-tangle-use-relative-file-links
|
||||
(file-relative-name (nth 1 spec))
|
||||
(nth 1 spec)))
|
||||
(link (let ((link (nth 2 spec)))
|
||||
(if org-babel-tangle-use-relative-file-links
|
||||
(when (string-match org-link-types-re link)
|
||||
(let ((type (match-string 0 link))
|
||||
(link (substring link (match-end 0))))
|
||||
(concat
|
||||
type
|
||||
(file-relative-name
|
||||
link
|
||||
(file-name-directory (cdr (assq :tangle info)))))))
|
||||
link)))
|
||||
(source-name (nth 3 spec))
|
||||
(body (nth 5 spec))
|
||||
(comment (nth 6 spec))
|
||||
(comments (cdr (assq :comments info)))
|
||||
(link-p (or (string= comments "both") (string= comments "link")
|
||||
(string= comments "yes") (string= comments "noweb")))
|
||||
(link-data (mapcar (lambda (el)
|
||||
(cons (symbol-name el)
|
||||
(let ((le (eval el)))
|
||||
(if (stringp le) le (format "%S" le)))))
|
||||
'(start-line file link source-name)))
|
||||
(insert-comment (lambda (text)
|
||||
(when (and comments
|
||||
(not (string= comments "no"))
|
||||
(org-string-nw-p text))
|
||||
(if org-babel-tangle-uncomment-comments
|
||||
;; Plain comments: no processing.
|
||||
(insert text)
|
||||
;; Ensure comments are made to be
|
||||
;; comments, and add a trailing
|
||||
;; newline. Also ignore invisible
|
||||
;; characters when commenting.
|
||||
(comment-region
|
||||
(point)
|
||||
(progn (insert (org-no-properties text))
|
||||
(point)))
|
||||
(end-of-line)
|
||||
(insert "\n"))))))
|
||||
(when comment (funcall insert-comment comment))
|
||||
(when link-p
|
||||
(funcall
|
||||
insert-comment
|
||||
(org-fill-template org-babel-tangle-comment-format-beg link-data)))
|
||||
(insert
|
||||
(format
|
||||
"%s\n"
|
||||
(org-unescape-code-in-string
|
||||
(org-babel-trim body (if org-src-preserve-indentation "[\f\n\r\v]")))))
|
||||
(when link-p
|
||||
(funcall
|
||||
insert-comment
|
||||
(org-fill-template org-babel-tangle-comment-format-end link-data)))))
|
||||
|
||||
(defun org-babel-tangle-collect-blocks (&optional language tangle-file)
|
||||
"Collect source blocks in the current Org file.
|
||||
Return an association list of source-code block specifications of
|
||||
the form used by `org-babel-spec-to-string' grouped by language.
|
||||
Optional argument LANGUAGE can be used to limit the collected
|
||||
source code blocks by language. Optional argument TANGLE-FILE
|
||||
can be used to limit the collected code blocks by target file."
|
||||
(let ((counter 0) last-heading-pos blocks)
|
||||
(org-babel-map-src-blocks (buffer-file-name)
|
||||
(let ((current-heading-pos
|
||||
(org-with-wide-buffer
|
||||
(org-with-limited-levels (outline-previous-heading)))))
|
||||
(if (eq last-heading-pos current-heading-pos) (incf counter)
|
||||
(setq counter 1)
|
||||
(setq last-heading-pos current-heading-pos)))
|
||||
(unless (org-in-commented-heading-p)
|
||||
(let* ((info (org-babel-get-src-block-info 'light))
|
||||
(src-lang (nth 0 info))
|
||||
(src-tfile (cdr (assq :tangle (nth 2 info)))))
|
||||
(unless (or (string= src-tfile "no")
|
||||
(and tangle-file (not (equal tangle-file src-tfile)))
|
||||
(and language (not (string= language src-lang))))
|
||||
;; Add the spec for this block to blocks under its
|
||||
;; language.
|
||||
(let ((by-lang (assoc src-lang blocks))
|
||||
(block (org-babel-tangle-single-block counter)))
|
||||
(if by-lang (setcdr by-lang (cons block (cdr by-lang)))
|
||||
(push (cons src-lang (list block)) blocks)))))))
|
||||
;; Ensure blocks are in the correct order.
|
||||
(mapcar (lambda (b) (cons (car b) (nreverse (cdr b)))) blocks)))
|
||||
|
||||
(defun org-babel-tangle-single-block
|
||||
(block-counter &optional only-this-block)
|
||||
"Collect the tangled source for current block.
|
||||
Return the list of block attributes needed by
|
||||
`org-babel-tangle-collect-blocks'.
|
||||
When ONLY-THIS-BLOCK is non-nil, return the full association
|
||||
list to be used by `org-babel-tangle' directly."
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(start-line
|
||||
(save-restriction (widen)
|
||||
(+ 1 (line-number-at-pos (point)))))
|
||||
(file (buffer-file-name (buffer-base-buffer)))
|
||||
(src-lang (nth 0 info))
|
||||
(params (nth 2 info))
|
||||
(extra (nth 3 info))
|
||||
(cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra)
|
||||
(match-string 1 extra))
|
||||
org-coderef-label-format))
|
||||
(link (let ((link (org-no-properties
|
||||
(org-store-link nil))))
|
||||
(and (string-match org-bracket-link-regexp link)
|
||||
(match-string 1 link))))
|
||||
(source-name
|
||||
(intern (or (nth 4 info)
|
||||
(format "%s:%d"
|
||||
(or (ignore-errors (nth 4 (org-heading-components)))
|
||||
"No heading")
|
||||
block-counter))))
|
||||
(expand-cmd
|
||||
(intern (concat "org-babel-expand-body:" src-lang)))
|
||||
(assignments-cmd
|
||||
(intern (concat "org-babel-variable-assignments:" src-lang)))
|
||||
(body
|
||||
;; Run the tangle-body-hook.
|
||||
(let* ((body ;; Expand the body in language specific manner.
|
||||
(if (org-babel-noweb-p params :tangle)
|
||||
(org-babel-expand-noweb-references info)
|
||||
(nth 1 info)))
|
||||
(body
|
||||
(if (assoc :no-expand params)
|
||||
body
|
||||
(if (fboundp expand-cmd)
|
||||
(funcall expand-cmd body params)
|
||||
(org-babel-expand-body:generic
|
||||
body params
|
||||
(and (fboundp assignments-cmd)
|
||||
(funcall assignments-cmd params)))))))
|
||||
(with-temp-buffer
|
||||
(insert body)
|
||||
(when (string-match "-r" extra)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
(replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
|
||||
(replace-match "")))
|
||||
(run-hooks 'org-babel-tangle-body-hook)
|
||||
(buffer-string))))
|
||||
(comment
|
||||
(when (or (string= "both" (cdr (assoc :comments params)))
|
||||
(string= "org" (cdr (assoc :comments params))))
|
||||
;; From the previous heading or code-block end
|
||||
(funcall
|
||||
org-babel-process-comment-text
|
||||
(buffer-substring
|
||||
(max (condition-case nil
|
||||
(save-excursion
|
||||
(org-back-to-heading t) ; Sets match data
|
||||
(match-end 0))
|
||||
(error (point-min)))
|
||||
(save-excursion
|
||||
(if (re-search-backward
|
||||
org-babel-src-block-regexp nil t)
|
||||
(match-end 0)
|
||||
(point-min))))
|
||||
(point)))))
|
||||
(result
|
||||
(list start-line file link source-name params body comment)))
|
||||
(if only-this-block
|
||||
(list (cons src-lang (list result)))
|
||||
result)))
|
||||
|
||||
(defun org-babel-tangle-comment-links ( &optional info)
|
||||
"Return a list of begin and end link comments for the code block at point."
|
||||
(let* ((start-line (org-babel-where-is-src-block-head))
|
||||
(file (buffer-file-name))
|
||||
(link (org-link-escape (progn (call-interactively 'org-store-link)
|
||||
(org-no-properties
|
||||
(car (pop org-stored-links))))))
|
||||
(source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
|
||||
(link-data (mapcar (lambda (el)
|
||||
(cons (symbol-name el)
|
||||
(let ((le (eval el)))
|
||||
(if (stringp le) le (format "%S" le)))))
|
||||
'(start-line file link source-name))))
|
||||
(list (org-fill-template org-babel-tangle-comment-format-beg link-data)
|
||||
(org-fill-template org-babel-tangle-comment-format-end link-data))))
|
||||
|
||||
;; de-tangling functions
|
||||
(defvar org-bracket-link-analytic-regexp)
|
||||
(defun org-babel-detangle (&optional source-code-file)
|
||||
"Propagate changes in source file back original to Org-mode file.
|
||||
This requires that code blocks were tangled with link comments
|
||||
which enable the original code blocks to be found."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(when source-code-file (find-file source-code-file))
|
||||
(goto-char (point-min))
|
||||
(let ((counter 0) new-body end)
|
||||
(while (re-search-forward org-bracket-link-analytic-regexp nil t)
|
||||
(when (re-search-forward
|
||||
(concat " " (regexp-quote (match-string 5)) " ends here"))
|
||||
(setq end (match-end 0))
|
||||
(forward-line -1)
|
||||
(save-excursion
|
||||
(when (setq new-body (org-babel-tangle-jump-to-org))
|
||||
(org-babel-update-block-body new-body)))
|
||||
(setq counter (+ 1 counter)))
|
||||
(goto-char end))
|
||||
(prog1 counter (message "Detangled %d code blocks" counter)))))
|
||||
|
||||
(defun org-babel-tangle-jump-to-org ()
|
||||
"Jump from a tangled code file to the related Org mode file."
|
||||
(interactive)
|
||||
(let ((mid (point))
|
||||
start body-start end done
|
||||
target-buffer target-char link path block-name body)
|
||||
(save-window-excursion
|
||||
(save-excursion
|
||||
(while (and (re-search-backward org-bracket-link-analytic-regexp nil t)
|
||||
(not ; ever wider searches until matching block comments
|
||||
(and (setq start (line-beginning-position))
|
||||
(setq body-start (line-beginning-position 2))
|
||||
(setq link (match-string 0))
|
||||
(setq path (match-string 3))
|
||||
(setq block-name (match-string 5))
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(re-search-forward
|
||||
(concat " " (regexp-quote block-name)
|
||||
" ends here") nil t)
|
||||
(setq end (line-beginning-position))))))))
|
||||
(unless (and start (< start mid) (< mid end))
|
||||
(error "Not in tangled code"))
|
||||
(setq body (buffer-substring body-start end)))
|
||||
(when (string-match "::" path)
|
||||
(setq path (substring path 0 (match-beginning 0))))
|
||||
(find-file path)
|
||||
(setq target-buffer (current-buffer))
|
||||
;; Go to the beginning of the relative block in Org file.
|
||||
(org-open-link-from-string link)
|
||||
(if (string-match "[^ \t\n\r]:\\([[:digit:]]+\\)" block-name)
|
||||
(let ((n (string-to-number (match-string 1 block-name))))
|
||||
(if (org-before-first-heading-p) (goto-char (point-min))
|
||||
(org-back-to-heading t))
|
||||
;; Do not skip the first block if it begins at point min.
|
||||
(cond ((or (org-at-heading-p)
|
||||
(not (eq (org-element-type (org-element-at-point))
|
||||
'src-block)))
|
||||
(org-babel-next-src-block n))
|
||||
((= n 1))
|
||||
(t (org-babel-next-src-block (1- n)))))
|
||||
(org-babel-goto-named-src-block block-name))
|
||||
(goto-char (org-babel-where-is-src-block-head))
|
||||
;; Preserve location of point within the source code in tangled
|
||||
;; code file.
|
||||
(forward-line 1)
|
||||
(forward-char (- mid body-start))
|
||||
(setq target-char (point)))
|
||||
(org-src-switch-to-buffer target-buffer t)
|
||||
(prog1 body (goto-char target-char))))
|
||||
|
||||
(provide 'ob-tangle)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ob-tangle.el ends here
|
43
elpa/org-20160919/ob.el
Normal file
43
elpa/org-20160919/ob.el
Normal file
@ -0,0 +1,43 @@
|
||||
;;; ob.el --- working with code blocks in org-mode
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
(require 'ob-eval)
|
||||
(require 'ob-core)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-exp)
|
||||
(require 'ob-keys)
|
||||
(require 'ob-table)
|
||||
(require 'ob-lob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-tangle)
|
||||
|
||||
(provide 'ob)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; ob.el ends here
|
22223
elpa/org-20160919/org
Normal file
22223
elpa/org-20160919/org
Normal file
File diff suppressed because it is too large
Load Diff
10233
elpa/org-20160919/org-agenda.el
Normal file
10233
elpa/org-20160919/org-agenda.el
Normal file
File diff suppressed because it is too large
Load Diff
607
elpa/org-20160919/org-archive.el
Normal file
607
elpa/org-20160919/org-archive.el
Normal file
@ -0,0 +1,607 @@
|
||||
;;; org-archive.el --- Archiving for Org-mode
|
||||
|
||||
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains the face definitions for Org.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
|
||||
(declare-function org-datetree-find-date-create "org-datetree" (date &optional keep-restriction))
|
||||
|
||||
(defcustom org-archive-default-command 'org-archive-subtree
|
||||
"The default archiving command."
|
||||
:group 'org-archive
|
||||
:type '(choice
|
||||
(const org-archive-subtree)
|
||||
(const org-archive-to-archive-sibling)
|
||||
(const org-archive-set-tag)))
|
||||
|
||||
(defcustom org-archive-reversed-order nil
|
||||
"Non-nil means make the tree first child under the archive heading, not last."
|
||||
:group 'org-archive
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-archive-sibling-heading "Archive"
|
||||
"Name of the local archive sibling that is used to archive entries locally.
|
||||
Locally means: in the tree, under a sibling.
|
||||
See `org-archive-to-archive-sibling' for more information."
|
||||
:group 'org-archive
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-archive-mark-done nil
|
||||
"Non-nil means mark entries as DONE when they are moved to the archive file.
|
||||
This can be a string to set the keyword to use. When t, Org-mode will
|
||||
use the first keyword in its list that means done."
|
||||
:group 'org-archive
|
||||
:type '(choice
|
||||
(const :tag "No" nil)
|
||||
(const :tag "Yes" t)
|
||||
(string :tag "Use this keyword")))
|
||||
|
||||
(defcustom org-archive-stamp-time t
|
||||
"Non-nil means add a time stamp to entries moved to an archive file.
|
||||
This variable is obsolete and has no effect anymore, instead add or remove
|
||||
`time' from the variable `org-archive-save-context-info'."
|
||||
:group 'org-archive
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-archive-file-header-format "\nArchived entries from file %s\n\n"
|
||||
"The header format string for newly created archive files.
|
||||
When nil, no header will be inserted.
|
||||
When a string, a %s formatter will be replaced by the file name."
|
||||
:group 'org-archive
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-archive-subtree-add-inherited-tags 'infile
|
||||
"Non-nil means append inherited tags when archiving a subtree."
|
||||
:group 'org-archive
|
||||
:version "24.1"
|
||||
:type '(choice
|
||||
(const :tag "Never" nil)
|
||||
(const :tag "When archiving a subtree to the same file" infile)
|
||||
(const :tag "Always" t)))
|
||||
|
||||
(defcustom org-archive-save-context-info '(time file olpath category todo itags)
|
||||
"Parts of context info that should be stored as properties when archiving.
|
||||
When a subtree is moved to an archive file, it loses information given by
|
||||
context, like inherited tags, the category, and possibly also the TODO
|
||||
state (depending on the variable `org-archive-mark-done').
|
||||
This variable can be a list of any of the following symbols:
|
||||
|
||||
time The time of archiving.
|
||||
file The file where the entry originates.
|
||||
ltags The local tags, in the headline of the subtree.
|
||||
itags The tags the subtree inherits from further up the hierarchy.
|
||||
todo The pre-archive TODO state.
|
||||
category The category, taken from file name or #+CATEGORY lines.
|
||||
olpath The outline path to the item. These are all headlines above
|
||||
the current item, separated by /, like a file path.
|
||||
|
||||
For each symbol present in the list, a property will be created in
|
||||
the archived entry, with a prefix \"ARCHIVE_\", to remember this
|
||||
information."
|
||||
:group 'org-archive
|
||||
:type '(set :greedy t
|
||||
(const :tag "Time" time)
|
||||
(const :tag "File" file)
|
||||
(const :tag "Category" category)
|
||||
(const :tag "TODO state" todo)
|
||||
(const :tag "Priority" priority)
|
||||
(const :tag "Inherited tags" itags)
|
||||
(const :tag "Outline path" olpath)
|
||||
(const :tag "Local tags" ltags)))
|
||||
|
||||
(defvar org-archive-hook nil
|
||||
"Hook run after successfully archiving a subtree.
|
||||
Hook functions are called with point on the subtree in the
|
||||
original file. At this stage, the subtree has been added to the
|
||||
archive location, but not yet deleted from the original file.")
|
||||
|
||||
(defun org-get-local-archive-location ()
|
||||
"Get the archive location applicable at point."
|
||||
(let ((re "^[ \t]*#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$")
|
||||
prop)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(setq prop (org-entry-get nil "ARCHIVE" 'inherit))
|
||||
(cond
|
||||
((and prop (string-match "\\S-" prop))
|
||||
prop)
|
||||
((or (re-search-backward re nil t)
|
||||
(re-search-forward re nil t))
|
||||
(match-string 1))
|
||||
(t org-archive-location))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-add-archive-files (files)
|
||||
"Splice the archive files into the list of files.
|
||||
This implies visiting all these files and finding out what the
|
||||
archive file is."
|
||||
(org-uniquify
|
||||
(apply
|
||||
'append
|
||||
(mapcar
|
||||
(lambda (f)
|
||||
(if (not (file-exists-p f))
|
||||
nil
|
||||
(with-current-buffer (org-get-agenda-file-buffer f)
|
||||
(cons f (org-all-archive-files)))))
|
||||
files))))
|
||||
|
||||
(defun org-all-archive-files ()
|
||||
"Get a list of all archive files used in the current buffer."
|
||||
(let (file files)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
"^[ \t]*\\(#\\+\\|:\\)ARCHIVE:[ \t]+\\(.*\\)"
|
||||
nil t)
|
||||
(setq file (org-extract-archive-file
|
||||
(org-match-string-no-properties 2)))
|
||||
(and file (> (length file) 0) (file-exists-p file)
|
||||
(add-to-list 'files file)))))
|
||||
(setq files (nreverse files))
|
||||
(setq file (org-extract-archive-file))
|
||||
(and file (> (length file) 0) (file-exists-p file)
|
||||
(add-to-list 'files file))
|
||||
files))
|
||||
|
||||
(defun org-extract-archive-file (&optional location)
|
||||
"Extract and expand the file name from archive LOCATION.
|
||||
if LOCATION is not given, the value of `org-archive-location' is used."
|
||||
(setq location (or location org-archive-location))
|
||||
(if (string-match "\\(.*\\)::\\(.*\\)" location)
|
||||
(if (= (match-beginning 1) (match-end 1))
|
||||
(buffer-file-name (buffer-base-buffer))
|
||||
(expand-file-name
|
||||
(format (match-string 1 location)
|
||||
(file-name-nondirectory
|
||||
(buffer-file-name (buffer-base-buffer))))))))
|
||||
|
||||
(defun org-extract-archive-heading (&optional location)
|
||||
"Extract the heading from archive LOCATION.
|
||||
if LOCATION is not given, the value of `org-archive-location' is used."
|
||||
(setq location (or location org-archive-location))
|
||||
(if (string-match "\\(.*\\)::\\(.*\\)" location)
|
||||
(format (match-string 2 location)
|
||||
(file-name-nondirectory
|
||||
(buffer-file-name (buffer-base-buffer))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-archive-subtree (&optional find-done)
|
||||
"Move the current subtree to the archive.
|
||||
The archive can be a certain top-level heading in the current file, or in
|
||||
a different file. The tree will be moved to that location, the subtree
|
||||
heading be marked DONE, and the current time will be added.
|
||||
|
||||
When called with a single prefix argument FIND-DONE, find whole trees without any
|
||||
open TODO items and archive them (after getting confirmation from the user).
|
||||
When called with a double prefix argument, find whole trees with timestamps before
|
||||
today and archive them (after getting confirmation from the user).
|
||||
If the cursor is not at a headline when these commands are called, try all level
|
||||
1 trees. If the cursor is on a headline, only try the direct children of
|
||||
this heading."
|
||||
(interactive "P")
|
||||
(if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
|
||||
(let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
|
||||
'region-start-level 'region))
|
||||
org-loop-over-headlines-in-active-region)
|
||||
(org-map-entries
|
||||
`(progn (setq org-map-continue-from (progn (org-back-to-heading) (point)))
|
||||
(org-archive-subtree ,find-done))
|
||||
org-loop-over-headlines-in-active-region
|
||||
cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
|
||||
(cond
|
||||
((equal find-done '(4)) (org-archive-all-done))
|
||||
((equal find-done '(16)) (org-archive-all-old))
|
||||
(t
|
||||
;; Save all relevant TODO keyword-relatex variables
|
||||
(let ((tr-org-todo-line-regexp org-todo-line-regexp) ; keep despite compiler
|
||||
(tr-org-todo-keywords-1 org-todo-keywords-1)
|
||||
(tr-org-todo-kwd-alist org-todo-kwd-alist)
|
||||
(tr-org-done-keywords org-done-keywords)
|
||||
(tr-org-todo-regexp org-todo-regexp)
|
||||
(tr-org-todo-line-regexp org-todo-line-regexp)
|
||||
(tr-org-odd-levels-only org-odd-levels-only)
|
||||
(this-buffer (current-buffer))
|
||||
;; start of variables that will be used for saving context
|
||||
;; The compiler complains about them - keep them anyway!
|
||||
(file (abbreviate-file-name
|
||||
(or (buffer-file-name (buffer-base-buffer))
|
||||
(error "No file associated to buffer"))))
|
||||
(olpath (mapconcat 'identity (org-get-outline-path) "/"))
|
||||
(time (format-time-string
|
||||
(substring (cdr org-time-stamp-formats) 1 -1)))
|
||||
category todo priority ltags itags atags
|
||||
;; end of variables that will be used for saving context
|
||||
location afile heading buffer level newfile-p infile-p visiting
|
||||
datetree-date datetree-subheading-p)
|
||||
|
||||
;; Find the local archive location
|
||||
(setq location (org-get-local-archive-location)
|
||||
afile (org-extract-archive-file location)
|
||||
heading (org-extract-archive-heading location)
|
||||
infile-p (equal file (abbreviate-file-name (or afile ""))))
|
||||
(unless afile
|
||||
(error "Invalid `org-archive-location'"))
|
||||
|
||||
(if (> (length afile) 0)
|
||||
(setq newfile-p (not (file-exists-p afile))
|
||||
visiting (find-buffer-visiting afile)
|
||||
buffer (or visiting (find-file-noselect afile)))
|
||||
(setq buffer (current-buffer)))
|
||||
(unless buffer
|
||||
(error "Cannot access file \"%s\"" afile))
|
||||
(when (string-match "\\`datetree/" heading)
|
||||
;; Replace with ***, to represent the 3 levels of headings the
|
||||
;; datetree has.
|
||||
(setq heading (replace-regexp-in-string "\\`datetree/" "***" heading))
|
||||
(setq datetree-subheading-p (> (length heading) 3))
|
||||
(setq datetree-date (org-date-to-gregorian
|
||||
(or (org-entry-get nil "CLOSED" t) time))))
|
||||
(if (and (> (length heading) 0)
|
||||
(string-match "^\\*+" heading))
|
||||
(setq level (match-end 0))
|
||||
(setq heading nil level 0))
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
;; Get context information that will be lost by moving the tree
|
||||
(setq category (org-get-category nil 'force-refresh)
|
||||
todo (and (looking-at org-todo-line-regexp)
|
||||
(match-string 2))
|
||||
priority (org-get-priority
|
||||
(if (match-end 3) (match-string 3) ""))
|
||||
ltags (org-get-tags)
|
||||
itags (org-delete-all ltags (org-get-tags-at))
|
||||
atags (org-get-tags-at))
|
||||
(setq ltags (mapconcat 'identity ltags " ")
|
||||
itags (mapconcat 'identity itags " "))
|
||||
;; We first only copy, in case something goes wrong
|
||||
;; we need to protect `this-command', to avoid kill-region sets it,
|
||||
;; which would lead to duplication of subtrees
|
||||
(let (this-command) (org-copy-subtree 1 nil t))
|
||||
(set-buffer buffer)
|
||||
;; Enforce org-mode for the archive buffer
|
||||
(if (not (derived-mode-p 'org-mode))
|
||||
;; Force the mode for future visits.
|
||||
(let ((org-insert-mode-line-in-empty-file t)
|
||||
(org-inhibit-startup t))
|
||||
(call-interactively 'org-mode)))
|
||||
(when (and newfile-p org-archive-file-header-format)
|
||||
(goto-char (point-max))
|
||||
(insert (format org-archive-file-header-format
|
||||
(buffer-file-name this-buffer))))
|
||||
(when datetree-date
|
||||
(require 'org-datetree)
|
||||
(org-datetree-find-date-create datetree-date)
|
||||
(org-narrow-to-subtree))
|
||||
;; Force the TODO keywords of the original buffer
|
||||
(let ((org-todo-line-regexp tr-org-todo-line-regexp)
|
||||
(org-todo-keywords-1 tr-org-todo-keywords-1)
|
||||
(org-todo-kwd-alist tr-org-todo-kwd-alist)
|
||||
(org-done-keywords tr-org-done-keywords)
|
||||
(org-todo-regexp tr-org-todo-regexp)
|
||||
(org-todo-line-regexp tr-org-todo-line-regexp)
|
||||
(org-odd-levels-only
|
||||
(if (local-variable-p 'org-odd-levels-only (current-buffer))
|
||||
org-odd-levels-only
|
||||
tr-org-odd-levels-only)))
|
||||
(goto-char (point-min))
|
||||
(outline-show-all)
|
||||
(if (and heading (not (and datetree-date (not datetree-subheading-p))))
|
||||
(progn
|
||||
(if (re-search-forward
|
||||
(concat "^" (regexp-quote heading)
|
||||
(org-re "[ \t]*\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\($\\|\r\\)"))
|
||||
nil t)
|
||||
(goto-char (match-end 0))
|
||||
;; Heading not found, just insert it at the end
|
||||
(goto-char (point-max))
|
||||
(or (bolp) (insert "\n"))
|
||||
;; datetrees don't need too much spacing
|
||||
(insert (if datetree-date "" "\n") heading "\n")
|
||||
(end-of-line 0))
|
||||
;; Make the subtree visible
|
||||
(outline-show-subtree)
|
||||
(if org-archive-reversed-order
|
||||
(progn
|
||||
(org-back-to-heading t)
|
||||
(outline-next-heading))
|
||||
(org-end-of-subtree t))
|
||||
(skip-chars-backward " \t\r\n")
|
||||
(and (looking-at "[ \t\r\n]*")
|
||||
;; datetree archives don't need so much spacing.
|
||||
(replace-match (if datetree-date "\n" "\n\n"))))
|
||||
;; No specific heading, just go to end of file.
|
||||
(goto-char (point-max)) (unless datetree-date (insert "\n")))
|
||||
;; Paste
|
||||
(org-paste-subtree (org-get-valid-level level (and heading 1)))
|
||||
;; Shall we append inherited tags?
|
||||
(and itags
|
||||
(or (and (eq org-archive-subtree-add-inherited-tags 'infile)
|
||||
infile-p)
|
||||
(eq org-archive-subtree-add-inherited-tags t))
|
||||
(org-set-tags-to atags))
|
||||
;; Mark the entry as done
|
||||
(when (and org-archive-mark-done
|
||||
(looking-at org-todo-line-regexp)
|
||||
(or (not (match-end 2))
|
||||
(not (member (match-string 2) org-done-keywords))))
|
||||
(let (org-log-done org-todo-log-states)
|
||||
(org-todo
|
||||
(car (or (member org-archive-mark-done org-done-keywords)
|
||||
org-done-keywords)))))
|
||||
|
||||
;; Add the context info
|
||||
(when org-archive-save-context-info
|
||||
(let ((l org-archive-save-context-info) e n v)
|
||||
(while (setq e (pop l))
|
||||
(when (and (setq v (symbol-value e))
|
||||
(stringp v) (string-match "\\S-" v))
|
||||
(setq n (concat "ARCHIVE_" (upcase (symbol-name e))))
|
||||
(org-entry-put (point) n v)))))
|
||||
|
||||
(widen)
|
||||
;; Save and kill the buffer, if it is not the same buffer.
|
||||
(when (not (eq this-buffer buffer))
|
||||
(save-buffer))))
|
||||
;; Here we are back in the original buffer. Everything seems
|
||||
;; to have worked. So now run hooks, cut the tree and finish
|
||||
;; up.
|
||||
(run-hooks 'org-archive-hook)
|
||||
(let (this-command) (org-cut-subtree))
|
||||
(when (featurep 'org-inlinetask)
|
||||
(org-inlinetask-remove-END-maybe))
|
||||
(setq org-markers-to-move nil)
|
||||
(message "Subtree archived %s"
|
||||
(if (eq this-buffer buffer)
|
||||
(concat "under heading: " heading)
|
||||
(concat "in file: " (abbreviate-file-name afile)))))))
|
||||
(org-reveal)
|
||||
(if (looking-at "^[ \t]*$")
|
||||
(outline-next-visible-heading 1))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-archive-to-archive-sibling ()
|
||||
"Archive the current heading by moving it under the archive sibling.
|
||||
The archive sibling is a sibling of the heading with the heading name
|
||||
`org-archive-sibling-heading' and an `org-archive-tag' tag. If this
|
||||
sibling does not exist, it will be created at the end of the subtree."
|
||||
(interactive)
|
||||
(if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
|
||||
(let ((cl (when (eq org-loop-over-headlines-in-active-region 'start-level)
|
||||
'region-start-level 'region))
|
||||
org-loop-over-headlines-in-active-region)
|
||||
(org-map-entries
|
||||
'(progn (setq org-map-continue-from
|
||||
(progn (org-back-to-heading)
|
||||
(if (looking-at (concat "^.*:" org-archive-tag ":.*$"))
|
||||
(org-end-of-subtree t)
|
||||
(point))))
|
||||
(when (org-at-heading-p)
|
||||
(org-archive-to-archive-sibling)))
|
||||
org-loop-over-headlines-in-active-region
|
||||
cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let (b e pos leader level)
|
||||
(org-back-to-heading t)
|
||||
(looking-at org-outline-regexp)
|
||||
(setq leader (match-string 0)
|
||||
level (funcall outline-level))
|
||||
(setq pos (point))
|
||||
(condition-case nil
|
||||
(outline-up-heading 1 t)
|
||||
(error (setq e (point-max)) (goto-char (point-min))))
|
||||
(setq b (point))
|
||||
(unless e
|
||||
(condition-case nil
|
||||
(org-end-of-subtree t t)
|
||||
(error (goto-char (point-max))))
|
||||
(setq e (point)))
|
||||
(goto-char b)
|
||||
(unless (re-search-forward
|
||||
(concat "^" (regexp-quote leader)
|
||||
"[ \t]*"
|
||||
org-archive-sibling-heading
|
||||
"[ \t]*:"
|
||||
org-archive-tag ":") e t)
|
||||
(goto-char e)
|
||||
(or (bolp) (newline))
|
||||
(insert leader org-archive-sibling-heading "\n")
|
||||
(beginning-of-line 0)
|
||||
(org-toggle-tag org-archive-tag 'on))
|
||||
(beginning-of-line 1)
|
||||
(if org-archive-reversed-order
|
||||
(outline-next-heading)
|
||||
(org-end-of-subtree t t))
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(let ((this-command this-command)) (org-cut-subtree)))
|
||||
(org-paste-subtree (org-get-valid-level level 1))
|
||||
(org-set-property
|
||||
"ARCHIVE_TIME"
|
||||
(format-time-string
|
||||
(substring (cdr org-time-stamp-formats) 1 -1)))
|
||||
(outline-up-heading 1 t)
|
||||
(outline-hide-subtree)
|
||||
(org-cycle-show-empty-lines 'folded)
|
||||
(goto-char pos)))
|
||||
(org-reveal)
|
||||
(if (looking-at "^[ \t]*$")
|
||||
(outline-next-visible-heading 1))))
|
||||
|
||||
(defun org-archive-all-done (&optional tag)
|
||||
"Archive sublevels of the current tree without open TODO items.
|
||||
If the cursor is not on a headline, try all level 1 trees. If
|
||||
it is on a headline, try all direct children.
|
||||
When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
|
||||
(org-archive-all-matches
|
||||
(lambda (beg end)
|
||||
(unless (re-search-forward org-not-done-heading-regexp end t)
|
||||
"no open TODO items"))
|
||||
tag))
|
||||
|
||||
(defun org-archive-all-old (&optional tag)
|
||||
"Archive sublevels of the current tree with timestamps prior to today.
|
||||
If the cursor is not on a headline, try all level 1 trees. If
|
||||
it is on a headline, try all direct children.
|
||||
When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
|
||||
(org-archive-all-matches
|
||||
(lambda (beg end)
|
||||
(let (ts)
|
||||
(and (re-search-forward org-ts-regexp end t)
|
||||
(setq ts (match-string 0))
|
||||
(< (org-time-stamp-to-now ts) 0)
|
||||
(if (not (looking-at
|
||||
(concat "--\\(" org-ts-regexp "\\)")))
|
||||
(concat "old timestamp " ts)
|
||||
(setq ts (concat "old timestamp " ts (match-string 0)))
|
||||
(and (< (org-time-stamp-to-now (match-string 1)) 0)
|
||||
ts)))))
|
||||
tag))
|
||||
|
||||
(defun org-archive-all-matches (predicate &optional tag)
|
||||
"Archive sublevels of the current tree that match PREDICATE.
|
||||
|
||||
PREDICATE is a function of two arguments, BEG and END, which
|
||||
specify the beginning and end of the headline being considered.
|
||||
It is called with point positioned at BEG. The headline will be
|
||||
archived if PREDICATE returns non-nil. If the return value of
|
||||
PREDICATE is a string, it should describe the reason for
|
||||
archiving the heading.
|
||||
|
||||
If the cursor is not on a headline, try all level 1 trees. If it
|
||||
is on a headline, try all direct children. When TAG is non-nil,
|
||||
don't move trees, but mark them with the ARCHIVE tag."
|
||||
(let ((rea (concat ".*:" org-archive-tag ":")) re1
|
||||
(begm (make-marker))
|
||||
(endm (make-marker))
|
||||
(question (if tag "Set ARCHIVE tag? "
|
||||
"Move subtree to archive? "))
|
||||
reason beg end (cntarch 0))
|
||||
(if (org-at-heading-p)
|
||||
(progn
|
||||
(setq re1 (concat "^" (regexp-quote
|
||||
(make-string
|
||||
(+ (- (match-end 0) (match-beginning 0) 1)
|
||||
(if org-odd-levels-only 2 1))
|
||||
?*))
|
||||
" "))
|
||||
(move-marker begm (point))
|
||||
(move-marker endm (org-end-of-subtree t)))
|
||||
(setq re1 "^* ")
|
||||
(move-marker begm (point-min))
|
||||
(move-marker endm (point-max)))
|
||||
(save-excursion
|
||||
(goto-char begm)
|
||||
(while (re-search-forward re1 endm t)
|
||||
(setq beg (match-beginning 0)
|
||||
end (save-excursion (org-end-of-subtree t) (point)))
|
||||
(goto-char beg)
|
||||
(if (not (setq reason (funcall predicate beg end)))
|
||||
(goto-char end)
|
||||
(goto-char beg)
|
||||
(if (and (or (not tag) (not (looking-at rea)))
|
||||
(y-or-n-p
|
||||
(if (stringp reason)
|
||||
(concat question "(" reason ")")
|
||||
question)))
|
||||
(progn
|
||||
(if tag
|
||||
(org-toggle-tag org-archive-tag 'on)
|
||||
(org-archive-subtree))
|
||||
(setq cntarch (1+ cntarch)))
|
||||
(goto-char end)))))
|
||||
(message "%d trees archived" cntarch)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-toggle-archive-tag (&optional find-done)
|
||||
"Toggle the archive tag for the current headline.
|
||||
With prefix ARG, check all children of current headline and offer tagging
|
||||
the children that do not contain any open TODO items."
|
||||
(interactive "P")
|
||||
(if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
|
||||
(let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
|
||||
'region-start-level 'region))
|
||||
org-loop-over-headlines-in-active-region)
|
||||
(org-map-entries
|
||||
`(org-toggle-archive-tag ,find-done)
|
||||
org-loop-over-headlines-in-active-region
|
||||
cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
|
||||
(if find-done
|
||||
(org-archive-all-done 'tag)
|
||||
(let (set)
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(setq set (org-toggle-tag org-archive-tag))
|
||||
(when set (org-flag-subtree t)))
|
||||
(and set (beginning-of-line 1))
|
||||
(message "Subtree %s" (if set "archived" "unarchived"))))))
|
||||
|
||||
(defun org-archive-set-tag ()
|
||||
"Set the ARCHIVE tag."
|
||||
(interactive)
|
||||
(if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
|
||||
(let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
|
||||
'region-start-level 'region))
|
||||
org-loop-over-headlines-in-active-region)
|
||||
(org-map-entries
|
||||
'org-archive-set-tag
|
||||
org-loop-over-headlines-in-active-region
|
||||
cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
|
||||
(org-toggle-tag org-archive-tag 'on)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-archive-subtree-default ()
|
||||
"Archive the current subtree with the default command.
|
||||
This command is set with the variable `org-archive-default-command'."
|
||||
(interactive)
|
||||
(call-interactively org-archive-default-command))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-archive-subtree-default-with-confirmation ()
|
||||
"Archive the current subtree with the default command.
|
||||
This command is set with the variable `org-archive-default-command'."
|
||||
(interactive)
|
||||
(if (y-or-n-p "Archive this subtree or entry? ")
|
||||
(call-interactively org-archive-default-command)
|
||||
(error "Abort")))
|
||||
|
||||
(provide 'org-archive)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-archive.el ends here
|
507
elpa/org-20160919/org-attach.el
Normal file
507
elpa/org-20160919/org-attach.el
Normal file
@ -0,0 +1,507 @@
|
||||
;;; org-attach.el --- Manage file attachments to org-mode tasks
|
||||
|
||||
;; Copyright (C) 2008-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <johnw@newartisans.com>
|
||||
;; Keywords: org data task
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; See the Org-mode manual for information on how to use it.
|
||||
;;
|
||||
;; Attachments are managed in a special directory called "data", which
|
||||
;; lives in the same directory as the org file itself. If this data
|
||||
;; directory is initialized as a Git repository, then org-attach will
|
||||
;; automatically commit changes when it sees them.
|
||||
;;
|
||||
;; Attachment directories are identified using a UUID generated for the
|
||||
;; task which has the attachments. These are added as property to the
|
||||
;; task when necessary, and should not be deleted or changed by the
|
||||
;; user, ever. UUIDs are generated by a mechanism defined in the variable
|
||||
;; `org-id-method'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'org-id)
|
||||
(require 'org)
|
||||
(require 'vc-git)
|
||||
|
||||
(defgroup org-attach nil
|
||||
"Options concerning entry attachments in Org-mode."
|
||||
:tag "Org Attach"
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-attach-directory "data/"
|
||||
"The directory where attachments are stored.
|
||||
If this is a relative path, it will be interpreted relative to the directory
|
||||
where the Org file lives."
|
||||
:group 'org-attach
|
||||
:type 'directory)
|
||||
|
||||
(defcustom org-attach-git-annex-cutoff (* 32 1024)
|
||||
"If non-nil, files larger than this will be annexed instead of stored."
|
||||
:group 'org-attach
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type '(choice
|
||||
(const :tag "None" nil)
|
||||
(integer :tag "Bytes")))
|
||||
|
||||
(defcustom org-attach-auto-tag "ATTACH"
|
||||
"Tag that will be triggered automatically when an entry has an attachment."
|
||||
:group 'org-attach
|
||||
:type '(choice
|
||||
(const :tag "None" nil)
|
||||
(string :tag "Tag")))
|
||||
|
||||
(defcustom org-attach-file-list-property "Attachments"
|
||||
"The property used to keep a list of attachment belonging to this entry.
|
||||
This is not really needed, so you may set this to nil if you don't want it.
|
||||
Also, for entries where children inherit the directory, the list of
|
||||
attachments is not kept in this property."
|
||||
:group 'org-attach
|
||||
:type '(choice
|
||||
(const :tag "None" nil)
|
||||
(string :tag "Tag")))
|
||||
|
||||
(defcustom org-attach-method 'cp
|
||||
"The preferred method to attach a file.
|
||||
Allowed values are:
|
||||
|
||||
mv rename the file to move it into the attachment directory
|
||||
cp copy the file
|
||||
ln create a hard link. Note that this is not supported
|
||||
on all systems, and then the result is not defined.
|
||||
lns create a symbol link. Note that this is not supported
|
||||
on all systems, and then the result is not defined."
|
||||
:group 'org-attach
|
||||
:type '(choice
|
||||
(const :tag "Copy" cp)
|
||||
(const :tag "Move/Rename" mv)
|
||||
(const :tag "Hard Link" ln)
|
||||
(const :tag "Symbol Link" lns)))
|
||||
|
||||
(defcustom org-attach-expert nil
|
||||
"Non-nil means do not show the splash buffer with the attach dispatcher."
|
||||
:group 'org-attach
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-attach-allow-inheritance t
|
||||
"Non-nil means allow attachment directories be inherited."
|
||||
:group 'org-attach
|
||||
:type 'boolean)
|
||||
|
||||
(defvar org-attach-inherited nil
|
||||
"Indicates if the last access to the attachment directory was inherited.")
|
||||
|
||||
(defcustom org-attach-store-link-p nil
|
||||
"Non-nil means store a link to a file when attaching it."
|
||||
:group 'org-attach
|
||||
:version "24.1"
|
||||
:type '(choice
|
||||
(const :tag "Don't store link" nil)
|
||||
(const :tag "Link to origin location" t)
|
||||
(const :tag "Link to the attach-dir location" attached)))
|
||||
|
||||
(defcustom org-attach-archive-delete nil
|
||||
"Non-nil means attachments are deleted upon archiving a subtree.
|
||||
When set to `query', ask the user instead."
|
||||
:group 'org-attach
|
||||
:version "25.1"
|
||||
:package-version '(Org . "8.3")
|
||||
:type '(choice
|
||||
(const :tag "Never delete attachments" nil)
|
||||
(const :tag "Always delete attachments" t)
|
||||
(const :tag "Query the user" query)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-attach ()
|
||||
"The dispatcher for attachment commands.
|
||||
Shows a list of commands and prompts for another key to execute a command."
|
||||
(interactive)
|
||||
(let (c marker)
|
||||
(when (eq major-mode 'org-agenda-mode)
|
||||
(setq marker (or (get-text-property (point) 'org-hd-marker)
|
||||
(get-text-property (point) 'org-marker)))
|
||||
(unless marker
|
||||
(error "No task in current line")))
|
||||
(save-excursion
|
||||
(when marker
|
||||
(set-buffer (marker-buffer marker))
|
||||
(goto-char marker))
|
||||
(org-back-to-heading t)
|
||||
(save-excursion
|
||||
(save-window-excursion
|
||||
(unless org-attach-expert
|
||||
(with-output-to-temp-buffer "*Org Attach*"
|
||||
(princ "Select an Attachment Command:
|
||||
|
||||
a Select a file and attach it to the task, using `org-attach-method'.
|
||||
c/m/l/y Attach a file using copy/move/link/symbolic-link method.
|
||||
n Create a new attachment, as an Emacs buffer.
|
||||
z Synchronize the current task with its attachment
|
||||
directory, in case you added attachments yourself.
|
||||
|
||||
o Open current task's attachments.
|
||||
O Like \"o\", but force opening in Emacs.
|
||||
f Open current task's attachment directory.
|
||||
F Like \"f\", but force using dired in Emacs.
|
||||
|
||||
d Delete one attachment, you will be prompted for a file name.
|
||||
D Delete all of a task's attachments. A safer way is
|
||||
to open the directory in dired and delete from there.
|
||||
|
||||
s Set a specific attachment directory for this entry.
|
||||
i Make children of the current entry inherit its attachment directory.")))
|
||||
(org-fit-window-to-buffer (get-buffer-window "*Org Attach*"))
|
||||
(message "Select command: [acmlzoOfFdD]")
|
||||
(setq c (read-char-exclusive))
|
||||
(and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*"))))
|
||||
(cond
|
||||
((memq c '(?a ?\C-a)) (call-interactively 'org-attach-attach))
|
||||
((memq c '(?c ?\C-c))
|
||||
(let ((org-attach-method 'cp)) (call-interactively 'org-attach-attach)))
|
||||
((memq c '(?m ?\C-m))
|
||||
(let ((org-attach-method 'mv)) (call-interactively 'org-attach-attach)))
|
||||
((memq c '(?l ?\C-l))
|
||||
(let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach)))
|
||||
((memq c '(?y ?\C-y))
|
||||
(let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach)))
|
||||
((memq c '(?n ?\C-n)) (call-interactively 'org-attach-new))
|
||||
((memq c '(?z ?\C-z)) (call-interactively 'org-attach-sync))
|
||||
((memq c '(?o ?\C-o)) (call-interactively 'org-attach-open))
|
||||
((eq c ?O) (call-interactively 'org-attach-open-in-emacs))
|
||||
((memq c '(?f ?\C-f)) (call-interactively 'org-attach-reveal))
|
||||
((memq c '(?F)) (call-interactively 'org-attach-reveal-in-emacs))
|
||||
((memq c '(?d ?\C-d)) (call-interactively
|
||||
'org-attach-delete-one))
|
||||
((eq c ?D) (call-interactively 'org-attach-delete-all))
|
||||
((eq c ?q) (message "Abort"))
|
||||
((memq c '(?s ?\C-s)) (call-interactively
|
||||
'org-attach-set-directory))
|
||||
((memq c '(?i ?\C-i)) (call-interactively
|
||||
'org-attach-set-inherit))
|
||||
(t (error "No such attachment command %c" c))))))
|
||||
|
||||
(defun org-attach-dir (&optional create-if-not-exists-p)
|
||||
"Return the directory associated with the current entry.
|
||||
This first checks for a local property ATTACH_DIR, and then for an inherited
|
||||
property ATTACH_DIR_INHERIT. If neither exists, the default mechanism
|
||||
using the entry ID will be invoked to access the unique directory for the
|
||||
current entry.
|
||||
If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil,
|
||||
the directory and (if necessary) the corresponding ID will be created."
|
||||
(let (attach-dir uuid inherit)
|
||||
(setq org-attach-inherited (org-entry-get nil "ATTACH_DIR_INHERIT"))
|
||||
(cond
|
||||
((setq attach-dir (org-entry-get nil "ATTACH_DIR"))
|
||||
(org-attach-check-absolute-path attach-dir))
|
||||
((and org-attach-allow-inheritance
|
||||
(setq inherit (org-entry-get nil "ATTACH_DIR_INHERIT" t)))
|
||||
(setq attach-dir
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(if (marker-position org-entry-property-inherited-from)
|
||||
(goto-char org-entry-property-inherited-from)
|
||||
(org-back-to-heading t))
|
||||
(let (org-attach-allow-inheritance)
|
||||
(org-attach-dir create-if-not-exists-p)))))
|
||||
(org-attach-check-absolute-path attach-dir)
|
||||
(setq org-attach-inherited t))
|
||||
(t ; use the ID
|
||||
(org-attach-check-absolute-path nil)
|
||||
(setq uuid (org-id-get (point) create-if-not-exists-p))
|
||||
(when (or uuid create-if-not-exists-p)
|
||||
(unless uuid (error "ID retrieval/creation failed"))
|
||||
(setq attach-dir (expand-file-name
|
||||
(format "%s/%s"
|
||||
(substring uuid 0 2)
|
||||
(substring uuid 2))
|
||||
(expand-file-name org-attach-directory))))))
|
||||
(when attach-dir
|
||||
(if (and create-if-not-exists-p
|
||||
(not (file-directory-p attach-dir)))
|
||||
(make-directory attach-dir t))
|
||||
(and (file-exists-p attach-dir)
|
||||
attach-dir))))
|
||||
|
||||
(defun org-attach-check-absolute-path (dir)
|
||||
"Check if we have enough information to root the attachment directory.
|
||||
When DIR is given, check also if it is already absolute. Otherwise,
|
||||
assume that it will be relative, and check if `org-attach-directory' is
|
||||
absolute, or if at least the current buffer has a file name.
|
||||
Throw an error if we cannot root the directory."
|
||||
(or (and dir (file-name-absolute-p dir))
|
||||
(file-name-absolute-p org-attach-directory)
|
||||
(buffer-file-name (buffer-base-buffer))
|
||||
(error "Need absolute `org-attach-directory' to attach in buffers without filename")))
|
||||
|
||||
(defun org-attach-set-directory ()
|
||||
"Set the ATTACH_DIR property of the current entry.
|
||||
The property defines the directory that is used for attachments
|
||||
of the entry."
|
||||
(interactive)
|
||||
(let ((dir (org-entry-get nil "ATTACH_DIR")))
|
||||
(setq dir (read-directory-name "Attachment directory: " dir))
|
||||
(org-entry-put nil "ATTACH_DIR" dir)))
|
||||
|
||||
(defun org-attach-set-inherit ()
|
||||
"Set the ATTACH_DIR_INHERIT property of the current entry.
|
||||
The property defines the directory that is used for attachments
|
||||
of the entry and any children that do not explicitly define (by setting
|
||||
the ATTACH_DIR property) their own attachment directory."
|
||||
(interactive)
|
||||
(org-entry-put nil "ATTACH_DIR_INHERIT" "t")
|
||||
(message "Children will inherit attachment directory"))
|
||||
|
||||
(defun org-attach-commit ()
|
||||
"Commit changes to git if `org-attach-directory' is properly initialized.
|
||||
This checks for the existence of a \".git\" directory in that directory."
|
||||
(let* ((dir (expand-file-name org-attach-directory))
|
||||
(git-dir (vc-git-root dir))
|
||||
(changes 0))
|
||||
(when (and git-dir (executable-find "git"))
|
||||
(with-temp-buffer
|
||||
(cd dir)
|
||||
(let ((have-annex
|
||||
(and org-attach-git-annex-cutoff
|
||||
(or (file-exists-p (expand-file-name "annex" git-dir))
|
||||
(file-exists-p (expand-file-name ".git/annex" git-dir))))))
|
||||
(dolist (new-or-modified
|
||||
(split-string
|
||||
(shell-command-to-string
|
||||
"git ls-files -zmo --exclude-standard") "\0" t))
|
||||
(if (and have-annex
|
||||
(>= (nth 7 (file-attributes new-or-modified))
|
||||
org-attach-git-annex-cutoff))
|
||||
(call-process "git" nil nil nil "annex" "add" new-or-modified)
|
||||
(call-process "git" nil nil nil "add" new-or-modified))
|
||||
(incf changes)))
|
||||
(dolist (deleted
|
||||
(split-string
|
||||
(shell-command-to-string "git ls-files -z --deleted") "\0" t))
|
||||
(call-process "git" nil nil nil "rm" deleted)
|
||||
(incf changes))
|
||||
(when (> changes 0)
|
||||
(shell-command "git commit -m 'Synchronized attachments'"))))))
|
||||
|
||||
(defun org-attach-tag (&optional off)
|
||||
"Turn the autotag on or (if OFF is set) off."
|
||||
(when org-attach-auto-tag
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(org-toggle-tag org-attach-auto-tag (if off 'off 'on)))))
|
||||
|
||||
(defun org-attach-untag ()
|
||||
"Turn the autotag off."
|
||||
(org-attach-tag 'off))
|
||||
|
||||
(defun org-attach-store-link (file)
|
||||
"Add a link to `org-stored-link' when attaching a file.
|
||||
Only do this when `org-attach-store-link-p' is non-nil."
|
||||
(setq org-stored-links
|
||||
(cons (list (org-attach-expand-link file)
|
||||
(file-name-nondirectory file))
|
||||
org-stored-links)))
|
||||
|
||||
(defun org-attach-attach (file &optional visit-dir method)
|
||||
"Move/copy/link FILE into the attachment directory of the current task.
|
||||
If VISIT-DIR is non-nil, visit the directory with dired.
|
||||
METHOD may be `cp', `mv', `ln', or `lns' default taken from
|
||||
`org-attach-method'."
|
||||
(interactive "fFile to keep as an attachment: \nP")
|
||||
(setq method (or method org-attach-method))
|
||||
(let ((basename (file-name-nondirectory file)))
|
||||
(when (and org-attach-file-list-property (not org-attach-inherited))
|
||||
(org-entry-add-to-multivalued-property
|
||||
(point) org-attach-file-list-property basename))
|
||||
(let* ((attach-dir (org-attach-dir t))
|
||||
(fname (expand-file-name basename attach-dir)))
|
||||
(cond
|
||||
((eq method 'mv) (rename-file file fname))
|
||||
((eq method 'cp) (copy-file file fname))
|
||||
((eq method 'ln) (add-name-to-file file fname))
|
||||
((eq method 'lns) (make-symbolic-link file fname)))
|
||||
(org-attach-commit)
|
||||
(org-attach-tag)
|
||||
(cond ((eq org-attach-store-link-p 'attached)
|
||||
(org-attach-store-link fname))
|
||||
((eq org-attach-store-link-p t)
|
||||
(org-attach-store-link file)))
|
||||
(if visit-dir
|
||||
(dired attach-dir)
|
||||
(message "File \"%s\" is now a task attachment." basename)))))
|
||||
|
||||
(defun org-attach-attach-cp ()
|
||||
"Attach a file by copying it."
|
||||
(interactive)
|
||||
(let ((org-attach-method 'cp)) (call-interactively 'org-attach-attach)))
|
||||
(defun org-attach-attach-mv ()
|
||||
"Attach a file by moving (renaming) it."
|
||||
(interactive)
|
||||
(let ((org-attach-method 'mv)) (call-interactively 'org-attach-attach)))
|
||||
(defun org-attach-attach-ln ()
|
||||
"Attach a file by creating a hard link to it.
|
||||
Beware that this does not work on systems that do not support hard links.
|
||||
On some systems, this apparently does copy the file instead."
|
||||
(interactive)
|
||||
(let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach)))
|
||||
(defun org-attach-attach-lns ()
|
||||
"Attach a file by creating a symbolic link to it.
|
||||
|
||||
Beware that this does not work on systems that do not support symbolic links.
|
||||
On some systems, this apparently does copy the file instead."
|
||||
(interactive)
|
||||
(let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach)))
|
||||
|
||||
(defun org-attach-new (file)
|
||||
"Create a new attachment FILE for the current task.
|
||||
The attachment is created as an Emacs buffer."
|
||||
(interactive "sCreate attachment named: ")
|
||||
(when (and org-attach-file-list-property (not org-attach-inherited))
|
||||
(org-entry-add-to-multivalued-property
|
||||
(point) org-attach-file-list-property file))
|
||||
(let ((attach-dir (org-attach-dir t)))
|
||||
(org-attach-tag)
|
||||
(find-file (expand-file-name file attach-dir))
|
||||
(message "New attachment %s" file)))
|
||||
|
||||
(defun org-attach-delete-one (&optional file)
|
||||
"Delete a single attachment."
|
||||
(interactive)
|
||||
(let* ((attach-dir (org-attach-dir t))
|
||||
(files (org-attach-file-list attach-dir))
|
||||
(file (or file
|
||||
(org-icompleting-read
|
||||
"Delete attachment: "
|
||||
(mapcar (lambda (f)
|
||||
(list (file-name-nondirectory f)))
|
||||
files)))))
|
||||
(setq file (expand-file-name file attach-dir))
|
||||
(unless (file-exists-p file)
|
||||
(error "No such attachment: %s" file))
|
||||
(delete-file file)
|
||||
(org-attach-commit)))
|
||||
|
||||
(defun org-attach-delete-all (&optional force)
|
||||
"Delete all attachments from the current task.
|
||||
This actually deletes the entire attachment directory.
|
||||
A safer way is to open the directory in dired and delete from there."
|
||||
(interactive "P")
|
||||
(when (and org-attach-file-list-property (not org-attach-inherited))
|
||||
(org-entry-delete (point) org-attach-file-list-property))
|
||||
(let ((attach-dir (org-attach-dir)))
|
||||
(when
|
||||
(and attach-dir
|
||||
(or force
|
||||
(y-or-n-p "Are you sure you want to remove all attachments of this entry? ")))
|
||||
(shell-command (format "rm -fr %s" attach-dir))
|
||||
(message "Attachment directory removed")
|
||||
(org-attach-commit)
|
||||
(org-attach-untag))))
|
||||
|
||||
(defun org-attach-sync ()
|
||||
"Synchronize the current tasks with its attachments.
|
||||
This can be used after files have been added externally."
|
||||
(interactive)
|
||||
(org-attach-commit)
|
||||
(when (and org-attach-file-list-property (not org-attach-inherited))
|
||||
(org-entry-delete (point) org-attach-file-list-property))
|
||||
(let ((attach-dir (org-attach-dir)))
|
||||
(when attach-dir
|
||||
(let ((files (org-attach-file-list attach-dir)))
|
||||
(and files (org-attach-tag))
|
||||
(when org-attach-file-list-property
|
||||
(dolist (file files)
|
||||
(unless (string-match "^\\.\\.?\\'" file)
|
||||
(org-entry-add-to-multivalued-property
|
||||
(point) org-attach-file-list-property file))))))))
|
||||
|
||||
(defun org-attach-file-list (dir)
|
||||
"Return a list of files in the attachment directory.
|
||||
This ignores files ending in \"~\"."
|
||||
(delq nil
|
||||
(mapcar (lambda (x) (if (string-match "^\\.\\.?\\'" x) nil x))
|
||||
(directory-files dir nil "[^~]\\'"))))
|
||||
|
||||
(defun org-attach-reveal (&optional if-exists)
|
||||
"Show the attachment directory of the current task.
|
||||
This will attempt to use an external program to show the directory."
|
||||
(interactive "P")
|
||||
(let ((attach-dir (org-attach-dir (not if-exists))))
|
||||
(and attach-dir (org-open-file attach-dir))))
|
||||
|
||||
(defun org-attach-reveal-in-emacs ()
|
||||
"Show the attachment directory of the current task in dired."
|
||||
(interactive)
|
||||
(let ((attach-dir (org-attach-dir t)))
|
||||
(dired attach-dir)))
|
||||
|
||||
(defun org-attach-open (&optional in-emacs)
|
||||
"Open an attachment of the current task.
|
||||
If there are more than one attachment, you will be prompted for the file name.
|
||||
This command will open the file using the settings in `org-file-apps'
|
||||
and in the system-specific variants of this variable.
|
||||
If IN-EMACS is non-nil, force opening in Emacs."
|
||||
(interactive "P")
|
||||
(let* ((attach-dir (org-attach-dir t))
|
||||
(files (org-attach-file-list attach-dir))
|
||||
(file (if (= (length files) 1)
|
||||
(car files)
|
||||
(org-icompleting-read "Open attachment: "
|
||||
(mapcar 'list files) nil t))))
|
||||
(org-open-file (expand-file-name file attach-dir) in-emacs)))
|
||||
|
||||
(defun org-attach-open-in-emacs ()
|
||||
"Open attachment, force opening in Emacs.
|
||||
See `org-attach-open'."
|
||||
(interactive)
|
||||
(org-attach-open 'in-emacs))
|
||||
|
||||
(defun org-attach-expand (file)
|
||||
"Return the full path to the current entry's attachment file FILE.
|
||||
Basically, this adds the path to the attachment directory."
|
||||
(expand-file-name file (org-attach-dir)))
|
||||
|
||||
(defun org-attach-expand-link (file)
|
||||
"Return a file link pointing to the current entry's attachment file FILE.
|
||||
Basically, this adds the path to the attachment directory, and a \"file:\"
|
||||
prefix."
|
||||
(concat "file:" (org-attach-expand file)))
|
||||
|
||||
(defun org-attach-archive-delete-maybe ()
|
||||
"Maybe delete subtree attachments when archiving.
|
||||
This function is called by `org-archive-hook'. The option
|
||||
`org-attach-archive-delete' controls its behavior."
|
||||
(when (if (eq org-attach-archive-delete 'query)
|
||||
(yes-or-no-p "Delete all attachments? ")
|
||||
org-attach-archive-delete)
|
||||
(org-attach-delete-all t)))
|
||||
|
||||
(add-hook 'org-archive-hook 'org-attach-archive-delete-maybe)
|
||||
|
||||
(provide 'org-attach)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-attach.el ends here
|
703
elpa/org-20160919/org-autoloads.el
Normal file
703
elpa/org-20160919/org-autoloads.el
Normal file
@ -0,0 +1,703 @@
|
||||
;;; org-autoloads.el --- automatically extracted autoloads
|
||||
;;
|
||||
;;; Code:
|
||||
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
|
||||
|
||||
;;;### (autoloads nil "org" "org.el" (22499 31110 515000 0))
|
||||
;;; Generated autoloads from org.el
|
||||
|
||||
(autoload 'org-babel-do-load-languages "org" "\
|
||||
Load the languages defined in `org-babel-load-languages'.
|
||||
|
||||
\(fn SYM VALUE)" nil nil)
|
||||
|
||||
(autoload 'org-babel-load-file "org" "\
|
||||
Load Emacs Lisp source code blocks in the Org-mode FILE.
|
||||
This function exports the source code using `org-babel-tangle'
|
||||
and then loads the resulting file using `load-file'. With prefix
|
||||
arg (noninteractively: 2nd arg) COMPILE the tangled Emacs Lisp
|
||||
file to byte-code before it is loaded.
|
||||
|
||||
\(fn FILE &optional COMPILE)" t nil)
|
||||
|
||||
(autoload 'org-version "org" "\
|
||||
Show the org-mode version.
|
||||
Interactively, or when MESSAGE is non-nil, show it in echo area.
|
||||
With prefix argument, or when HERE is non-nil, insert it at point.
|
||||
In non-interactive uses, a reduced version string is output unless
|
||||
FULL is given.
|
||||
|
||||
\(fn &optional HERE FULL MESSAGE)" t nil)
|
||||
|
||||
(autoload 'turn-on-orgtbl "org" "\
|
||||
Unconditionally turn on `orgtbl-mode'.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'org-clock-persistence-insinuate "org" "\
|
||||
Set up hooks for clock persistence.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'org-mode "org" "\
|
||||
Outline-based notes management and organizer, alias
|
||||
\"Carsten's outline-mode for keeping track of everything.\"
|
||||
|
||||
Org-mode develops organizational tasks around a NOTES file which
|
||||
contains information about projects as plain text. Org-mode is
|
||||
implemented on top of outline-mode, which is ideal to keep the content
|
||||
of large files well structured. It supports ToDo items, deadlines and
|
||||
time stamps, which magically appear in the diary listing of the Emacs
|
||||
calendar. Tables are easily created with a built-in table editor.
|
||||
Plain text URL-like links connect to websites, emails (VM), Usenet
|
||||
messages (Gnus), BBDB entries, and any files related to the project.
|
||||
For printing and sharing of notes, an Org-mode file (or a part of it)
|
||||
can be exported as a structured ASCII or HTML file.
|
||||
|
||||
The following commands are available:
|
||||
|
||||
\\{org-mode-map}
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-cycle "org" "\
|
||||
TAB-action and visibility cycling for Org-mode.
|
||||
|
||||
This is the command invoked in Org-mode by the TAB key. Its main purpose
|
||||
is outline visibility cycling, but it also invokes other actions
|
||||
in special contexts.
|
||||
|
||||
- When this function is called with a prefix argument, rotate the entire
|
||||
buffer through 3 states (global cycling)
|
||||
1. OVERVIEW: Show only top-level headlines.
|
||||
2. CONTENTS: Show all headlines of all levels, but no body text.
|
||||
3. SHOW ALL: Show everything.
|
||||
With a double \\[universal-argument] prefix argument, switch to the startup visibility,
|
||||
determined by the variable `org-startup-folded', and by any VISIBILITY
|
||||
properties in the buffer.
|
||||
With a triple \\[universal-argument] prefix argument, show the entire buffer, including any drawers.
|
||||
|
||||
- When inside a table, re-align the table and move to the next field.
|
||||
|
||||
- When point is at the beginning of a headline, rotate the subtree started
|
||||
by this line through 3 different states (local cycling)
|
||||
1. FOLDED: Only the main headline is shown.
|
||||
2. CHILDREN: The main headline and the direct children are shown.
|
||||
From this state, you can move to one of the children
|
||||
and zoom in further.
|
||||
3. SUBTREE: Show the entire subtree, including body text.
|
||||
If there is no subtree, switch directly from CHILDREN to FOLDED.
|
||||
|
||||
- When point is at the beginning of an empty headline and the variable
|
||||
`org-cycle-level-after-item/entry-creation' is set, cycle the level
|
||||
of the headline by demoting and promoting it to likely levels. This
|
||||
speeds up creation document structure by pressing TAB once or several
|
||||
times right after creating a new headline.
|
||||
|
||||
- When there is a numeric prefix, go up to a heading with level ARG, do
|
||||
a `show-subtree' and return to the previous cursor position. If ARG
|
||||
is negative, go up that many levels.
|
||||
|
||||
- When point is not at the beginning of a headline, execute the global
|
||||
binding for TAB, which is re-indenting the line. See the option
|
||||
`org-cycle-emulate-tab' for details.
|
||||
|
||||
- Special case: if point is at the beginning of the buffer and there is
|
||||
no headline in line 1, this function will act as if called with prefix arg
|
||||
(\\[universal-argument] TAB, same as S-TAB) also when called without prefix arg.
|
||||
But only if also the variable `org-cycle-global-at-bob' is t.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'org-global-cycle "org" "\
|
||||
Cycle the global visibility. For details see `org-cycle'.
|
||||
With \\[universal-argument] prefix arg, switch to startup visibility.
|
||||
With a numeric prefix, show all headlines up to that level.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
(put 'orgstruct-heading-prefix-regexp 'safe-local-variable 'stringp)
|
||||
|
||||
(autoload 'orgstruct-mode "org" "\
|
||||
Toggle the minor mode `orgstruct-mode'.
|
||||
This mode is for using Org-mode structure commands in other
|
||||
modes. The following keys behave as if Org-mode were active, if
|
||||
the cursor is on a headline, or on a plain list item (both as
|
||||
defined by Org-mode).
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'turn-on-orgstruct "org" "\
|
||||
Unconditionally turn on `orgstruct-mode'.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'turn-on-orgstruct++ "org" "\
|
||||
Unconditionally turn on `orgstruct++-mode'.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'org-run-like-in-org-mode "org" "\
|
||||
Run a command, pretending that the current buffer is in Org-mode.
|
||||
This will temporarily bind local variables that are typically bound in
|
||||
Org-mode to the values they have in Org-mode, and then interactively
|
||||
call CMD.
|
||||
|
||||
\(fn CMD)" nil nil)
|
||||
|
||||
(autoload 'org-store-link "org" "\
|
||||
\\<org-mode-map>Store an org-link to the current location.
|
||||
This link is added to `org-stored-links' and can later be inserted
|
||||
into an Org buffer with \\[org-insert-link].
|
||||
|
||||
For some link types, a prefix ARG is interpreted.
|
||||
For links to Usenet articles, ARG negates `org-gnus-prefer-web-links'.
|
||||
For file links, ARG negates `org-context-in-file-links'.
|
||||
|
||||
A double prefix ARG force skipping storing functions that are not
|
||||
part of Org's core.
|
||||
|
||||
A triple prefix ARG force storing a link for each line in the
|
||||
active region.
|
||||
|
||||
\(fn ARG)" t nil)
|
||||
|
||||
(autoload 'org-insert-link-global "org" "\
|
||||
Insert a link like Org-mode does.
|
||||
This command can be called in any mode to insert a link in Org-mode syntax.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-open-at-point-global "org" "\
|
||||
Follow a link like Org-mode does.
|
||||
This command can be called in any mode to follow a link that has
|
||||
Org-mode syntax.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-open-link-from-string "org" "\
|
||||
Open a link in the string S, as if it was in Org-mode.
|
||||
|
||||
\(fn S &optional ARG REFERENCE-BUFFER)" t nil)
|
||||
|
||||
(autoload 'org-switchb "org" "\
|
||||
Switch between Org buffers.
|
||||
With one prefix argument, restrict available buffers to files.
|
||||
With two prefix arguments, restrict available buffers to agenda files.
|
||||
|
||||
Defaults to `iswitchb' for buffer name completion.
|
||||
Set `org-completion-use-ido' to make it use ido instead.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(defalias 'org-ido-switchb 'org-switchb)
|
||||
|
||||
(defalias 'org-iswitchb 'org-switchb)
|
||||
|
||||
(autoload 'org-cycle-agenda-files "org" "\
|
||||
Cycle through the files in `org-agenda-files'.
|
||||
If the current buffer visits an agenda file, find the next one in the list.
|
||||
If the current buffer does not, find the first agenda file.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-submit-bug-report "org" "\
|
||||
Submit a bug report on Org-mode via mail.
|
||||
|
||||
Don't hesitate to report any problems or inaccurate documentation.
|
||||
|
||||
If you don't have setup sending mail from (X)Emacs, please copy the
|
||||
output buffer into your mail program, as it gives us important
|
||||
information about your Org-mode version and configuration.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-reload "org" "\
|
||||
Reload all org lisp files.
|
||||
With prefix arg UNCOMPILED, load the uncompiled versions.
|
||||
|
||||
\(fn &optional UNCOMPILED)" t nil)
|
||||
|
||||
(autoload 'org-customize "org" "\
|
||||
Call the customize function with org as argument.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-agenda" "org-agenda.el" (22499 31110 405000
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from org-agenda.el
|
||||
|
||||
(autoload 'org-toggle-sticky-agenda "org-agenda" "\
|
||||
Toggle `org-agenda-sticky'.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'org-agenda "org-agenda" "\
|
||||
Dispatch agenda commands to collect entries to the agenda buffer.
|
||||
Prompts for a command to execute. Any prefix arg will be passed
|
||||
on to the selected command. The default selections are:
|
||||
|
||||
a Call `org-agenda-list' to display the agenda for current day or week.
|
||||
t Call `org-todo-list' to display the global todo list.
|
||||
T Call `org-todo-list' to display the global todo list, select only
|
||||
entries with a specific TODO keyword (the user gets a prompt).
|
||||
m Call `org-tags-view' to display headlines with tags matching
|
||||
a condition (the user is prompted for the condition).
|
||||
M Like `m', but select only TODO entries, no ordinary headlines.
|
||||
L Create a timeline for the current buffer.
|
||||
e Export views to associated files.
|
||||
s Search entries for keywords.
|
||||
S Search entries for keywords, only with TODO keywords.
|
||||
/ Multi occur across all agenda files and also files listed
|
||||
in `org-agenda-text-search-extra-files'.
|
||||
< Restrict agenda commands to buffer, subtree, or region.
|
||||
Press several times to get the desired effect.
|
||||
> Remove a previous restriction.
|
||||
# List \"stuck\" projects.
|
||||
! Configure what \"stuck\" means.
|
||||
C Configure custom agenda commands.
|
||||
|
||||
More commands can be added by configuring the variable
|
||||
`org-agenda-custom-commands'. In particular, specific tags and TODO keyword
|
||||
searches can be pre-defined in this way.
|
||||
|
||||
If the current buffer is in Org-mode and visiting a file, you can also
|
||||
first press `<' once to indicate that the agenda should be temporarily
|
||||
\(until the next use of \\[org-agenda]) restricted to the current file.
|
||||
Pressing `<' twice means to restrict to the current subtree or region
|
||||
\(if active).
|
||||
|
||||
\(fn &optional ARG ORG-KEYS RESTRICTION)" t nil)
|
||||
|
||||
(autoload 'org-batch-agenda "org-agenda" "\
|
||||
Run an agenda command in batch mode and send the result to STDOUT.
|
||||
If CMD-KEY is a string of length 1, it is used as a key in
|
||||
`org-agenda-custom-commands' and triggers this command. If it is a
|
||||
longer string it is used as a tags/todo match string.
|
||||
Parameters are alternating variable names and values that will be bound
|
||||
before running the agenda command.
|
||||
|
||||
\(fn CMD-KEY &rest PARAMETERS)" nil t)
|
||||
|
||||
(autoload 'org-batch-agenda-csv "org-agenda" "\
|
||||
Run an agenda command in batch mode and send the result to STDOUT.
|
||||
If CMD-KEY is a string of length 1, it is used as a key in
|
||||
`org-agenda-custom-commands' and triggers this command. If it is a
|
||||
longer string it is used as a tags/todo match string.
|
||||
Parameters are alternating variable names and values that will be bound
|
||||
before running the agenda command.
|
||||
|
||||
The output gives a line for each selected agenda item. Each
|
||||
item is a list of comma-separated values, like this:
|
||||
|
||||
category,head,type,todo,tags,date,time,extra,priority-l,priority-n
|
||||
|
||||
category The category of the item
|
||||
head The headline, without TODO kwd, TAGS and PRIORITY
|
||||
type The type of the agenda entry, can be
|
||||
todo selected in TODO match
|
||||
tagsmatch selected in tags match
|
||||
diary imported from diary
|
||||
deadline a deadline on given date
|
||||
scheduled scheduled on given date
|
||||
timestamp entry has timestamp on given date
|
||||
closed entry was closed on given date
|
||||
upcoming-deadline warning about deadline
|
||||
past-scheduled forwarded scheduled item
|
||||
block entry has date block including g. date
|
||||
todo The todo keyword, if any
|
||||
tags All tags including inherited ones, separated by colons
|
||||
date The relevant date, like 2007-2-14
|
||||
time The time, like 15:00-16:50
|
||||
extra Sting with extra planning info
|
||||
priority-l The priority letter if any was given
|
||||
priority-n The computed numerical priority
|
||||
agenda-day The day in the agenda where this is listed
|
||||
|
||||
\(fn CMD-KEY &rest PARAMETERS)" nil t)
|
||||
|
||||
(autoload 'org-store-agenda-views "org-agenda" "\
|
||||
Store agenda views.
|
||||
|
||||
\(fn &rest PARAMETERS)" t nil)
|
||||
|
||||
(autoload 'org-batch-store-agenda-views "org-agenda" "\
|
||||
Run all custom agenda commands that have a file argument.
|
||||
|
||||
\(fn &rest PARAMETERS)" nil t)
|
||||
|
||||
(autoload 'org-agenda-list "org-agenda" "\
|
||||
Produce a daily/weekly view from all files in variable `org-agenda-files'.
|
||||
The view will be for the current day or week, but from the overview buffer
|
||||
you will be able to go to other days/weeks.
|
||||
|
||||
With a numeric prefix argument in an interactive call, the agenda will
|
||||
span ARG days. Lisp programs should instead specify SPAN to change
|
||||
the number of days. SPAN defaults to `org-agenda-span'.
|
||||
|
||||
START-DAY defaults to TODAY, or to the most recent match for the weekday
|
||||
given in `org-agenda-start-on-weekday'.
|
||||
|
||||
When WITH-HOUR is non-nil, only include scheduled and deadline
|
||||
items if they have an hour specification like [h]h:mm.
|
||||
|
||||
\(fn &optional ARG START-DAY SPAN WITH-HOUR)" t nil)
|
||||
|
||||
(autoload 'org-search-view "org-agenda" "\
|
||||
Show all entries that contain a phrase or words or regular expressions.
|
||||
|
||||
With optional prefix argument TODO-ONLY, only consider entries that are
|
||||
TODO entries. The argument STRING can be used to pass a default search
|
||||
string into this function. If EDIT-AT is non-nil, it means that the
|
||||
user should get a chance to edit this string, with cursor at position
|
||||
EDIT-AT.
|
||||
|
||||
The search string can be viewed either as a phrase that should be found as
|
||||
is, or it can be broken into a number of snippets, each of which must match
|
||||
in a Boolean way to select an entry. The default depends on the variable
|
||||
`org-agenda-search-view-always-boolean'.
|
||||
Even if this is turned off (the default) you can always switch to
|
||||
Boolean search dynamically by preceding the first word with \"+\" or \"-\".
|
||||
|
||||
The default is a direct search of the whole phrase, where each space in
|
||||
the search string can expand to an arbitrary amount of whitespace,
|
||||
including newlines.
|
||||
|
||||
If using a Boolean search, the search string is split on whitespace and
|
||||
each snippet is searched separately, with logical AND to select an entry.
|
||||
Words prefixed with a minus must *not* occur in the entry. Words without
|
||||
a prefix or prefixed with a plus must occur in the entry. Matching is
|
||||
case-insensitive. Words are enclosed by word delimiters (i.e. they must
|
||||
match whole words, not parts of a word) if
|
||||
`org-agenda-search-view-force-full-words' is set (default is nil).
|
||||
|
||||
Boolean search snippets enclosed by curly braces are interpreted as
|
||||
regular expressions that must or (when preceded with \"-\") must not
|
||||
match in the entry. Snippets enclosed into double quotes will be taken
|
||||
as a whole, to include whitespace.
|
||||
|
||||
- If the search string starts with an asterisk, search only in headlines.
|
||||
- If (possibly after the leading star) the search string starts with an
|
||||
exclamation mark, this also means to look at TODO entries only, an effect
|
||||
that can also be achieved with a prefix argument.
|
||||
- If (possibly after star and exclamation mark) the search string starts
|
||||
with a colon, this will mean that the (non-regexp) snippets of the
|
||||
Boolean search must match as full words.
|
||||
|
||||
This command searches the agenda files, and in addition the files listed
|
||||
in `org-agenda-text-search-extra-files'.
|
||||
|
||||
\(fn &optional TODO-ONLY STRING EDIT-AT)" t nil)
|
||||
|
||||
(autoload 'org-todo-list "org-agenda" "\
|
||||
Show all (not done) TODO entries from all agenda file in a single list.
|
||||
The prefix arg can be used to select a specific TODO keyword and limit
|
||||
the list to these. When using \\[universal-argument], you will be prompted
|
||||
for a keyword. A numeric prefix directly selects the Nth keyword in
|
||||
`org-todo-keywords-1'.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
(autoload 'org-tags-view "org-agenda" "\
|
||||
Show all headlines for all `org-agenda-files' matching a TAGS criterion.
|
||||
The prefix arg TODO-ONLY limits the search to TODO entries.
|
||||
|
||||
\(fn &optional TODO-ONLY MATCH)" t nil)
|
||||
|
||||
(autoload 'org-agenda-list-stuck-projects "org-agenda" "\
|
||||
Create agenda view for projects that are stuck.
|
||||
Stuck projects are project that have no next actions. For the definitions
|
||||
of what a project is and how to check if it stuck, customize the variable
|
||||
`org-stuck-projects'.
|
||||
|
||||
\(fn &rest IGNORE)" t nil)
|
||||
|
||||
(autoload 'org-diary "org-agenda" "\
|
||||
Return diary information from org files.
|
||||
This function can be used in a \"sexp\" diary entry in the Emacs calendar.
|
||||
It accesses org files and extracts information from those files to be
|
||||
listed in the diary. The function accepts arguments specifying what
|
||||
items should be listed. For a list of arguments allowed here, see the
|
||||
variable `org-agenda-entry-types'.
|
||||
|
||||
The call in the diary file should look like this:
|
||||
|
||||
&%%(org-diary) ~/path/to/some/orgfile.org
|
||||
|
||||
Use a separate line for each org file to check. Or, if you omit the file name,
|
||||
all files listed in `org-agenda-files' will be checked automatically:
|
||||
|
||||
&%%(org-diary)
|
||||
|
||||
If you don't give any arguments (as in the example above), the default value
|
||||
of `org-agenda-entry-types' is used: (:deadline :scheduled :timestamp :sexp).
|
||||
So the example above may also be written as
|
||||
|
||||
&%%(org-diary :deadline :timestamp :sexp :scheduled)
|
||||
|
||||
The function expects the lisp variables `entry' and `date' to be provided
|
||||
by the caller, because this is how the calendar works. Don't use this
|
||||
function from a program - use `org-agenda-get-day-entries' instead.
|
||||
|
||||
\(fn &rest ARGS)" nil nil)
|
||||
|
||||
(autoload 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item "org-agenda" "\
|
||||
Do we have a reason to ignore this TODO entry because it has a time stamp?
|
||||
|
||||
\(fn &optional END)" nil nil)
|
||||
|
||||
(autoload 'org-agenda-set-restriction-lock "org-agenda" "\
|
||||
Set restriction lock for agenda, to current subtree or file.
|
||||
Restriction will be the file if TYPE is `file', or if type is the
|
||||
universal prefix \\='(4), or if the cursor is before the first headline
|
||||
in the file. Otherwise, restriction will be to the current subtree.
|
||||
|
||||
\(fn &optional TYPE)" t nil)
|
||||
|
||||
(autoload 'org-calendar-goto-agenda "org-agenda" "\
|
||||
Compute the Org-mode agenda for the calendar date displayed at the cursor.
|
||||
This is a command that has to be installed in `calendar-mode-map'.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-agenda-to-appt "org-agenda" "\
|
||||
Activate appointments found in `org-agenda-files'.
|
||||
With a \\[universal-argument] prefix, refresh the list of
|
||||
appointments.
|
||||
|
||||
If FILTER is t, interactively prompt the user for a regular
|
||||
expression, and filter out entries that don't match it.
|
||||
|
||||
If FILTER is a string, use this string as a regular expression
|
||||
for filtering entries out.
|
||||
|
||||
If FILTER is a function, filter out entries against which
|
||||
calling the function returns nil. This function takes one
|
||||
argument: an entry from `org-agenda-get-day-entries'.
|
||||
|
||||
FILTER can also be an alist with the car of each cell being
|
||||
either `headline' or `category'. For example:
|
||||
|
||||
\\='((headline \"IMPORTANT\")
|
||||
(category \"Work\"))
|
||||
|
||||
will only add headlines containing IMPORTANT or headlines
|
||||
belonging to the \"Work\" category.
|
||||
|
||||
ARGS are symbols indicating what kind of entries to consider.
|
||||
By default `org-agenda-to-appt' will use :deadline*, :scheduled*
|
||||
\(i.e., deadlines and scheduled items with a hh:mm specification)
|
||||
and :timestamp entries. See the docstring of `org-diary' for
|
||||
details and examples.
|
||||
|
||||
If an entry has a APPT_WARNTIME property, its value will be used
|
||||
to override `appt-message-warning-time'.
|
||||
|
||||
\(fn &optional REFRESH FILTER &rest ARGS)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-capture" "org-capture.el" (22499 31110
|
||||
;;;;;; 462000 0))
|
||||
;;; Generated autoloads from org-capture.el
|
||||
|
||||
(autoload 'org-capture-string "org-capture" "\
|
||||
Capture STRING with the template selected by KEYS.
|
||||
|
||||
\(fn STRING &optional KEYS)" t nil)
|
||||
|
||||
(autoload 'org-capture "org-capture" "\
|
||||
Capture something.
|
||||
\\<org-capture-mode-map>
|
||||
This will let you select a template from `org-capture-templates', and then
|
||||
file the newly captured information. The text is immediately inserted
|
||||
at the target location, and an indirect buffer is shown where you can
|
||||
edit it. Pressing \\[org-capture-finalize] brings you back to the previous state
|
||||
of Emacs, so that you can continue your work.
|
||||
|
||||
When called interactively with a \\[universal-argument] prefix argument GOTO, don't capture
|
||||
anything, just go to the file/headline where the selected template
|
||||
stores its notes. With a double prefix argument \\[universal-argument] \\[universal-argument], go to the last note
|
||||
stored.
|
||||
|
||||
When called with a `C-0' (zero) prefix, insert a template at point.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template
|
||||
in `org-capture-templates'. In this case, interactive selection
|
||||
will be bypassed.
|
||||
|
||||
If `org-capture-use-agenda-date' is non-nil, capturing from the
|
||||
agenda will use the date at point as the default date. Then, a
|
||||
`C-1' prefix will tell the capture process to use the HH:MM time
|
||||
of the day at point (if any) or the current HH:MM time.
|
||||
|
||||
\(fn &optional GOTO KEYS)" t nil)
|
||||
|
||||
(autoload 'org-capture-import-remember-templates "org-capture" "\
|
||||
Set `org-capture-templates' to be similar to `org-remember-templates'.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-colview" "org-colview.el" (22499 31110
|
||||
;;;;;; 380000 0))
|
||||
;;; Generated autoloads from org-colview.el
|
||||
|
||||
(autoload 'org-columns-remove-overlays "org-colview" "\
|
||||
Remove all currently active column overlays.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-columns-get-format-and-top-level "org-colview" "\
|
||||
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'org-columns "org-colview" "\
|
||||
Turn on column view on an org-mode file.
|
||||
When COLUMNS-FMT-STRING is non-nil, use it as the column format.
|
||||
|
||||
\(fn &optional COLUMNS-FMT-STRING)" t nil)
|
||||
|
||||
(autoload 'org-columns-compute "org-colview" "\
|
||||
Sum the values of property PROPERTY hierarchically, for the entire buffer.
|
||||
|
||||
\(fn PROPERTY)" t nil)
|
||||
|
||||
(autoload 'org-columns-number-to-string "org-colview" "\
|
||||
Convert a computed column number to a string value, according to FMT.
|
||||
|
||||
\(fn N FMT &optional PRINTF)" nil nil)
|
||||
|
||||
(autoload 'org-dblock-write:columnview "org-colview" "\
|
||||
Write the column view table.
|
||||
PARAMS is a property list of parameters:
|
||||
|
||||
:width enforce same column widths with <N> specifiers.
|
||||
:id the :ID: property of the entry where the columns view
|
||||
should be built. When the symbol `local', call locally.
|
||||
When `global' call column view with the cursor at the beginning
|
||||
of the buffer (usually this means that the whole buffer switches
|
||||
to column view). When \"file:path/to/file.org\", invoke column
|
||||
view at the start of that file. Otherwise, the ID is located
|
||||
using `org-id-find'.
|
||||
:hlines When t, insert a hline before each item. When a number, insert
|
||||
a hline before each level <= that number.
|
||||
:vlines When t, make each column a colgroup to enforce vertical lines.
|
||||
:maxlevel When set to a number, don't capture headlines below this level.
|
||||
:skip-empty-rows
|
||||
When t, skip rows where all specifiers other than ITEM are empty.
|
||||
:format When non-nil, specify the column view format to use.
|
||||
|
||||
\(fn PARAMS)" nil nil)
|
||||
|
||||
(autoload 'org-insert-columns-dblock "org-colview" "\
|
||||
Create a dynamic block capturing a column view table.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
(autoload 'org-agenda-columns "org-colview" "\
|
||||
Turn on or update column view in the agenda.
|
||||
|
||||
\(fn)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-compat" "org-compat.el" (22499 31110 330000
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from org-compat.el
|
||||
|
||||
(autoload 'org-check-version "org-compat" "\
|
||||
Try very hard to provide sensible version strings.
|
||||
|
||||
\(fn)" nil t)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-lint" "org-lint.el" (22499 31110 408000
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from org-lint.el
|
||||
|
||||
(autoload 'org-lint "org-lint" "\
|
||||
Check current Org buffer for syntax mistakes.
|
||||
|
||||
By default, run all checkers. With a single prefix ARG \\[universal-argument],
|
||||
select one category of checkers only. With a double prefix
|
||||
\\[universal-argument] \\[universal-argument], select one precise checker by its name.
|
||||
|
||||
ARG can also be a list of checker names, as symbols, to run.
|
||||
|
||||
\(fn &optional ARG)" t nil)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-macs" "org-macs.el" (22499 31110 420000
|
||||
;;;;;; 0))
|
||||
;;; Generated autoloads from org-macs.el
|
||||
|
||||
(autoload 'org-load-noerror-mustsuffix "org-macs" "\
|
||||
Load FILE with optional arguments NOERROR and MUSTSUFFIX. Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it.
|
||||
|
||||
\(fn FILE)" nil t)
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "org-version" "org-version.el" (22499 31110
|
||||
;;;;;; 476000 0))
|
||||
;;; Generated autoloads from org-version.el
|
||||
|
||||
(autoload 'org-release "org-version" "\
|
||||
The release version of org-mode.
|
||||
Inserted by installing org-mode or when a release is made.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(autoload 'org-git-version "org-version" "\
|
||||
The Git version of org-mode.
|
||||
Inserted by installing org-mode or when a release is made.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(defvar org-odt-data-dir "/usr/share/emacs/etc/org" "\
|
||||
The location of ODT styles.")
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil nil ("ob-C.el" "ob-J.el" "ob-R.el" "ob-abc.el"
|
||||
;;;;;; "ob-asymptote.el" "ob-awk.el" "ob-calc.el" "ob-clojure.el"
|
||||
;;;;;; "ob-comint.el" "ob-coq.el" "ob-core.el" "ob-css.el" "ob-ditaa.el"
|
||||
;;;;;; "ob-dot.el" "ob-ebnf.el" "ob-emacs-lisp.el" "ob-eval.el"
|
||||
;;;;;; "ob-exp.el" "ob-forth.el" "ob-fortran.el" "ob-gnuplot.el"
|
||||
;;;;;; "ob-groovy.el" "ob-haskell.el" "ob-io.el" "ob-java.el" "ob-js.el"
|
||||
;;;;;; "ob-keys.el" "ob-latex.el" "ob-ledger.el" "ob-lilypond.el"
|
||||
;;;;;; "ob-lisp.el" "ob-lob.el" "ob-makefile.el" "ob-matlab.el"
|
||||
;;;;;; "ob-maxima.el" "ob-mscgen.el" "ob-ocaml.el" "ob-octave.el"
|
||||
;;;;;; "ob-org.el" "ob-perl.el" "ob-picolisp.el" "ob-plantuml.el"
|
||||
;;;;;; "ob-processing.el" "ob-python.el" "ob-ref.el" "ob-ruby.el"
|
||||
;;;;;; "ob-sass.el" "ob-scala.el" "ob-scheme.el" "ob-screen.el"
|
||||
;;;;;; "ob-sed.el" "ob-shell.el" "ob-shen.el" "ob-sql.el" "ob-sqlite.el"
|
||||
;;;;;; "ob-stan.el" "ob-table.el" "ob-tangle.el" "ob.el" "org-archive.el"
|
||||
;;;;;; "org-attach.el" "org-bbdb.el" "org-bibtex.el" "org-clock.el"
|
||||
;;;;;; "org-crypt.el" "org-ctags.el" "org-datetree.el" "org-docview.el"
|
||||
;;;;;; "org-element.el" "org-entities.el" "org-eshell.el" "org-faces.el"
|
||||
;;;;;; "org-feed.el" "org-footnote.el" "org-gnus.el" "org-habit.el"
|
||||
;;;;;; "org-id.el" "org-indent.el" "org-info.el" "org-inlinetask.el"
|
||||
;;;;;; "org-install.el" "org-irc.el" "org-list.el" "org-loaddefs.el"
|
||||
;;;;;; "org-macro.el" "org-mhe.el" "org-mobile.el" "org-mouse.el"
|
||||
;;;;;; "org-pcomplete.el" "org-pkg.el" "org-plot.el" "org-protocol.el"
|
||||
;;;;;; "org-rmail.el" "org-src.el" "org-table.el" "org-timer.el"
|
||||
;;;;;; "org-w3m.el" "ox-ascii.el" "ox-beamer.el" "ox-html.el" "ox-icalendar.el"
|
||||
;;;;;; "ox-latex.el" "ox-man.el" "ox-md.el" "ox-odt.el" "ox-org.el"
|
||||
;;;;;; "ox-publish.el" "ox-texinfo.el" "ox.el") (22499 31110 921000
|
||||
;;;;;; 582000))
|
||||
|
||||
;;;***
|
||||
|
||||
;; Local Variables:
|
||||
;; version-control: never
|
||||
;; no-byte-compile: t
|
||||
;; no-update-autoloads: t
|
||||
;; End:
|
||||
;;; org-autoloads.el ends here
|
448
elpa/org-20160919/org-bbdb.el
Normal file
448
elpa/org-20160919/org-bbdb.el
Normal file
@ -0,0 +1,448 @@
|
||||
;;; org-bbdb.el --- Support for links to BBDB entries from within Org-mode
|
||||
|
||||
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file implements links to BBDB database entries from within Org-mode.
|
||||
;; Org-mode loads this module by default - if this is not what you want,
|
||||
;; configure the variable `org-modules'.
|
||||
|
||||
;; It also implements an interface (based on Ivar Rummelhoff's
|
||||
;; bbdb-anniv.el) for those org-mode users, who do not use the diary
|
||||
;; but who do want to include the anniversaries stored in the BBDB
|
||||
;; into the org-agenda. If you already include the `diary' into the
|
||||
;; agenda, you might want to prefer to include the anniversaries in
|
||||
;; the diary using bbdb-anniv.el.
|
||||
;;
|
||||
;; Put the following in /somewhere/at/home/diary.org and make sure
|
||||
;; that this file is in `org-agenda-files'.
|
||||
;;
|
||||
;; %%(org-bbdb-anniversaries)
|
||||
;;
|
||||
;; For example my diary.org looks like:
|
||||
;; * Anniversaries
|
||||
;; #+CATEGORY: Anniv
|
||||
;; %%(org-bbdb-anniversaries)
|
||||
;;
|
||||
;;
|
||||
;; To add an anniversary to a BBDB record, press `C-o' in the record.
|
||||
;; You will be prompted for the field name, in this case it must be
|
||||
;; "anniversary". If this is the first time you are using this field,
|
||||
;; you need to confirm that it should be created.
|
||||
;;
|
||||
;; The format of an anniversary field stored in BBDB is the following
|
||||
;; (items in {} are optional):
|
||||
;;
|
||||
;; YYYY-MM-DD{ CLASS-OR-FORMAT-STRING}
|
||||
;; {\nYYYY-MM-DD CLASS-OR-FORMAT-STRING}...
|
||||
;;
|
||||
;; CLASS-OR-FORMAT-STRING is one of two things:
|
||||
;;
|
||||
;; - an identifier for a class of anniversaries (eg. birthday or
|
||||
;; wedding) from `org-bbdb-anniversary-format-alist' which then
|
||||
;; defines the format string for this class
|
||||
;; - the (format) string displayed in the diary.
|
||||
;;
|
||||
;; You can enter multiple anniversaries for a single BBDB record by
|
||||
;; separating them with a newline character. At the BBDB prompt for
|
||||
;; the field value, type `C-q C-j' to enter a newline between two
|
||||
;; anniversaries.
|
||||
;;
|
||||
;; If you omit the CLASS-OR-FORMAT-STRING entirely, it defaults to the
|
||||
;; value of `org-bbdb-default-anniversary-format' ("birthday" by
|
||||
;; default).
|
||||
;;
|
||||
;; The substitutions in the format string are (in order):
|
||||
;; - the name of the record containing this anniversary
|
||||
;; - the number of years
|
||||
;; - an ordinal suffix (st, nd, rd, th) for the year
|
||||
;;
|
||||
;; See the documentation of `org-bbdb-anniversary-format-alist' for
|
||||
;; further options.
|
||||
;;
|
||||
;; Example
|
||||
;;
|
||||
;; 1973-06-22
|
||||
;; 20??-??-?? wedding
|
||||
;; 1998-03-12 %s created bbdb-anniv.el %d years ago
|
||||
;;
|
||||
;; From Org's agenda, you can use `C-c C-o' to jump to the BBDB
|
||||
;; link from which the entry at point originates.
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
;; Declare external functions and variables
|
||||
|
||||
(declare-function bbdb "ext:bbdb-com" (string elidep))
|
||||
(declare-function bbdb-company "ext:bbdb-com" (string elidep))
|
||||
(declare-function bbdb-current-record "ext:bbdb-com"
|
||||
(&optional planning-on-modifying))
|
||||
(declare-function bbdb-name "ext:bbdb-com" (string elidep))
|
||||
(declare-function bbdb-completing-read-record "ext:bbdb-com"
|
||||
(prompt &optional omit-records))
|
||||
(declare-function bbdb-record-getprop "ext:bbdb" (record property))
|
||||
(declare-function bbdb-record-name "ext:bbdb" (record))
|
||||
(declare-function bbdb-records "ext:bbdb"
|
||||
(&optional dont-check-disk already-in-db-buffer))
|
||||
(declare-function bbdb-split "ext:bbdb" (string separators))
|
||||
(declare-function bbdb-string-trim "ext:bbdb" (string))
|
||||
(declare-function bbdb-record-get-field "ext:bbdb" (record field))
|
||||
(declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
|
||||
(declare-function bbdb-search-organization "ext:bbdb-com" (regexp &optional layout))
|
||||
|
||||
;; `bbdb-record-note' was part of BBDB v3.x
|
||||
(declare-function bbdb-record-note "ext:bbdb" (record label))
|
||||
;; `bbdb-record-xfield' replaces it in recent BBDB v3.x+
|
||||
(declare-function bbdb-record-xfield "ext:bbdb" (record label))
|
||||
|
||||
(declare-function calendar-leap-year-p "calendar" (year))
|
||||
(declare-function diary-ordinal-suffix "diary-lib" (n))
|
||||
|
||||
(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el
|
||||
|
||||
;; Customization
|
||||
|
||||
(defgroup org-bbdb-anniversaries nil
|
||||
"Customizations for including anniversaries from BBDB into Agenda."
|
||||
:group 'org-bbdb)
|
||||
|
||||
(defcustom org-bbdb-default-anniversary-format "birthday"
|
||||
"Default anniversary class."
|
||||
:type 'string
|
||||
:group 'org-bbdb-anniversaries
|
||||
:require 'bbdb)
|
||||
|
||||
(defcustom org-bbdb-anniversary-format-alist
|
||||
'(("birthday" .
|
||||
(lambda (name years suffix)
|
||||
(concat "Birthday: [[bbdb:" name "][" name " ("
|
||||
(format "%s" years) ; handles numbers as well as strings
|
||||
suffix ")]]")))
|
||||
("wedding" .
|
||||
(lambda (name years suffix)
|
||||
(concat "[[bbdb:" name "][" name "'s "
|
||||
(format "%s" years)
|
||||
suffix " wedding anniversary]]"))))
|
||||
"How different types of anniversaries should be formatted.
|
||||
An alist of elements (STRING . FORMAT) where STRING is the name of an
|
||||
anniversary class and format is either:
|
||||
1) A format string with the following substitutions (in order):
|
||||
- the name of the record containing this anniversary
|
||||
- the number of years
|
||||
- an ordinal suffix (st, nd, rd, th) for the year
|
||||
|
||||
2) A function to be called with three arguments: NAME YEARS SUFFIX
|
||||
(string int string) returning a string for the diary or nil.
|
||||
|
||||
3) An Emacs Lisp form that should evaluate to a string (or nil) in the
|
||||
scope of variables NAME, YEARS and SUFFIX (among others)."
|
||||
:type '(alist :key-type (string :tag "Class")
|
||||
:value-type (function :tag "Function"))
|
||||
:group 'org-bbdb-anniversaries
|
||||
:require 'bbdb)
|
||||
|
||||
(defcustom org-bbdb-anniversary-field 'anniversary
|
||||
"The BBDB field which contains anniversaries.
|
||||
The anniversaries are stored in the following format
|
||||
|
||||
YYYY-MM-DD Class-or-Format-String
|
||||
|
||||
where class is one of the customized classes for anniversaries;
|
||||
birthday and wedding are predefined. Format-String can take three
|
||||
substitutions 1) the name of the record containing this
|
||||
anniversary, 2) the number of years, and 3) an ordinal suffix for
|
||||
the year.
|
||||
|
||||
Multiple anniversaries can be separated by \\n."
|
||||
:type 'symbol
|
||||
:group 'org-bbdb-anniversaries
|
||||
:require 'bbdb)
|
||||
|
||||
(defcustom org-bbdb-extract-date-fun 'org-bbdb-anniv-extract-date
|
||||
"How to retrieve `month date year' from the anniversary field.
|
||||
|
||||
Customize if you have already filled your BBDB with dates
|
||||
different from YYYY-MM-DD. The function must return a list (month
|
||||
date year)."
|
||||
:type 'function
|
||||
:group 'org-bbdb-anniversaries
|
||||
:require 'bbdb)
|
||||
|
||||
|
||||
;; Install the link type
|
||||
(org-add-link-type "bbdb" 'org-bbdb-open 'org-bbdb-export)
|
||||
(add-hook 'org-store-link-functions 'org-bbdb-store-link)
|
||||
|
||||
;; Implementation
|
||||
(defun org-bbdb-store-link ()
|
||||
"Store a link to a BBDB database entry."
|
||||
(when (eq major-mode 'bbdb-mode)
|
||||
;; This is BBDB, we make this link!
|
||||
(let* ((rec (bbdb-current-record))
|
||||
(name (bbdb-record-name rec))
|
||||
(company (if (fboundp 'bbdb-record-getprop)
|
||||
(bbdb-record-getprop rec 'company)
|
||||
(car (bbdb-record-get-field rec 'organization))))
|
||||
(link (concat "bbdb:" name)))
|
||||
(org-store-link-props :type "bbdb" :name name :company company
|
||||
:link link :description name)
|
||||
link)))
|
||||
|
||||
(defun org-bbdb-export (path desc format)
|
||||
"Create the export version of a BBDB link specified by PATH or DESC.
|
||||
If exporting to either HTML or LaTeX FORMAT the link will be
|
||||
italicized, in all other cases it is left unchanged."
|
||||
(when (string= desc (format "bbdb:%s" path))
|
||||
(setq desc path))
|
||||
(cond
|
||||
((eq format 'html) (format "<i>%s</i>" desc))
|
||||
((eq format 'latex) (format "\\textit{%s}" desc))
|
||||
((eq format 'odt)
|
||||
(format "<text:span text:style-name=\"Emphasis\">%s</text:span>" desc))
|
||||
(t desc)))
|
||||
|
||||
(defun org-bbdb-open (name)
|
||||
"Follow a BBDB link to NAME."
|
||||
(require 'bbdb-com)
|
||||
(let ((inhibit-redisplay (not debug-on-error))
|
||||
(bbdb-electric-p nil))
|
||||
(if (fboundp 'bbdb-name)
|
||||
(org-bbdb-open-old name)
|
||||
(org-bbdb-open-new name))))
|
||||
|
||||
(defun org-bbdb-open-old (name)
|
||||
(catch 'exit
|
||||
;; Exact match on name
|
||||
(bbdb-name (concat "\\`" name "\\'") nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; Exact match on name
|
||||
(bbdb-company (concat "\\`" name "\\'") nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; Partial match on name
|
||||
(bbdb-name name nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; Partial match on company
|
||||
(bbdb-company name nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; General match including network address and notes
|
||||
(bbdb name nil)
|
||||
(when (= 0 (buffer-size (get-buffer "*BBDB*")))
|
||||
(delete-window (get-buffer-window "*BBDB*"))
|
||||
(error "No matching BBDB record"))))
|
||||
|
||||
(defun org-bbdb-open-new (name)
|
||||
(catch 'exit
|
||||
;; Exact match on name
|
||||
(bbdb-search-name (concat "\\`" name "\\'") nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; Exact match on name
|
||||
(bbdb-search-organization (concat "\\`" name "\\'") nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; Partial match on name
|
||||
(bbdb-search-name name nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; Partial match on company
|
||||
(bbdb-search-organization name nil)
|
||||
(if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
|
||||
;; General match including network address and notes
|
||||
(bbdb name nil)
|
||||
(when (= 0 (buffer-size (get-buffer "*BBDB*")))
|
||||
(delete-window (get-buffer-window "*BBDB*"))
|
||||
(error "No matching BBDB record"))))
|
||||
|
||||
(defun org-bbdb-anniv-extract-date (time-str)
|
||||
"Convert YYYY-MM-DD to (month date year).
|
||||
Argument TIME-STR is the value retrieved from BBDB. If YYYY- is omitted
|
||||
it will be considered unknown."
|
||||
(multiple-value-bind (a b c) (values-list (org-split-string time-str "-"))
|
||||
(if (eq c nil)
|
||||
(list (string-to-number a)
|
||||
(string-to-number b)
|
||||
nil)
|
||||
(list (string-to-number b)
|
||||
(string-to-number c)
|
||||
(string-to-number a)))))
|
||||
|
||||
(defun org-bbdb-anniv-split (str)
|
||||
"Split multiple entries in the BBDB anniversary field.
|
||||
Argument STR is the anniversary field in BBDB."
|
||||
(let ((pos (string-match "[ \t]" str)))
|
||||
(if pos (list (substring str 0 pos)
|
||||
(bbdb-string-trim (substring str pos)))
|
||||
(list str nil))))
|
||||
|
||||
(defvar org-bbdb-anniv-hash nil
|
||||
"A hash holding anniversaries extracted from BBDB.
|
||||
The hash table is created on first use.")
|
||||
|
||||
(defvar org-bbdb-updated-p t
|
||||
"This is non-nil if BBDB has been updated since we last built the hash.")
|
||||
|
||||
(defun org-bbdb-make-anniv-hash ()
|
||||
"Create a hash with anniversaries extracted from BBDB, for fast access.
|
||||
The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
|
||||
(let ((old-bbdb (fboundp 'bbdb-record-getprop))
|
||||
(record-func (if (fboundp 'bbdb-record-xfield)
|
||||
'bbdb-record-xfield
|
||||
'bbdb-record-note))
|
||||
split tmp annivs)
|
||||
(clrhash org-bbdb-anniv-hash)
|
||||
(dolist (rec (bbdb-records))
|
||||
(when (setq annivs (if old-bbdb
|
||||
(bbdb-record-getprop
|
||||
rec org-bbdb-anniversary-field)
|
||||
(funcall record-func
|
||||
rec org-bbdb-anniversary-field)))
|
||||
(setq annivs (if old-bbdb
|
||||
(bbdb-split annivs "\n")
|
||||
;; parameter order is reversed in new bbdb
|
||||
(bbdb-split "\n" annivs)))
|
||||
(while annivs
|
||||
(setq split (org-bbdb-anniv-split (pop annivs)))
|
||||
(multiple-value-bind (m d y)
|
||||
(values-list (funcall org-bbdb-extract-date-fun (car split)))
|
||||
(setq tmp (gethash (list m d) org-bbdb-anniv-hash))
|
||||
(puthash (list m d) (cons (list y
|
||||
(bbdb-record-name rec)
|
||||
(cadr split))
|
||||
tmp)
|
||||
org-bbdb-anniv-hash))))))
|
||||
(setq org-bbdb-updated-p nil))
|
||||
|
||||
(defun org-bbdb-updated (rec)
|
||||
"Record the fact that BBDB has been updated.
|
||||
This is used by Org to re-create the anniversary hash table."
|
||||
(setq org-bbdb-updated-p t))
|
||||
|
||||
(add-hook 'bbdb-after-change-hook 'org-bbdb-updated)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-bbdb-anniversaries ()
|
||||
"Extract anniversaries from BBDB for display in the agenda."
|
||||
(require 'bbdb)
|
||||
(require 'diary-lib)
|
||||
(unless (hash-table-p org-bbdb-anniv-hash)
|
||||
(setq org-bbdb-anniv-hash
|
||||
(make-hash-table :test 'equal :size 366)))
|
||||
|
||||
(when (or org-bbdb-updated-p
|
||||
(= 0 (hash-table-count org-bbdb-anniv-hash)))
|
||||
(org-bbdb-make-anniv-hash))
|
||||
|
||||
(let* ((m (car date)) ; month
|
||||
(d (nth 1 date)) ; day
|
||||
(y (nth 2 date)) ; year
|
||||
(annivs (gethash (list m d) org-bbdb-anniv-hash))
|
||||
(text ())
|
||||
rec recs)
|
||||
|
||||
;; we don't want to miss people born on Feb. 29th
|
||||
(when (and (= m 3) (= d 1)
|
||||
(not (null (gethash (list 2 29) org-bbdb-anniv-hash)))
|
||||
(not (calendar-leap-year-p y)))
|
||||
(setq recs (gethash (list 2 29) org-bbdb-anniv-hash))
|
||||
(while (setq rec (pop recs))
|
||||
(push rec annivs)))
|
||||
|
||||
(when annivs
|
||||
(while (setq rec (pop annivs))
|
||||
(when rec
|
||||
(let* ((class (or (nth 2 rec)
|
||||
org-bbdb-default-anniversary-format))
|
||||
(form (or (cdr (assoc-string
|
||||
class org-bbdb-anniversary-format-alist t))
|
||||
class)) ; (as format string)
|
||||
(name (nth 1 rec))
|
||||
(years (if (eq (car rec) nil)
|
||||
"unknown"
|
||||
(- y (car rec))))
|
||||
(suffix (if (eq (car rec) nil)
|
||||
""
|
||||
(diary-ordinal-suffix years)))
|
||||
(tmp (cond
|
||||
((functionp form)
|
||||
(funcall form name years suffix))
|
||||
((listp form) (eval form))
|
||||
(t (format form name years suffix)))))
|
||||
(org-add-props tmp nil 'org-bbdb-name name)
|
||||
(if text
|
||||
(setq text (append text (list tmp)))
|
||||
(setq text (list tmp)))))
|
||||
))
|
||||
text))
|
||||
|
||||
(defun org-bbdb-complete-link ()
|
||||
"Read a bbdb link with name completion."
|
||||
(require 'bbdb-com)
|
||||
(let ((rec (bbdb-completing-read-record "Name: ")))
|
||||
(concat "bbdb:"
|
||||
(bbdb-record-name (if (listp rec)
|
||||
(car rec)
|
||||
rec)))))
|
||||
|
||||
(defun org-bbdb-anniv-export-ical ()
|
||||
"Extract anniversaries from BBDB and convert them to icalendar format."
|
||||
(require 'bbdb)
|
||||
(require 'diary-lib)
|
||||
(unless (hash-table-p org-bbdb-anniv-hash)
|
||||
(setq org-bbdb-anniv-hash
|
||||
(make-hash-table :test 'equal :size 366)))
|
||||
(when (or org-bbdb-updated-p
|
||||
(= 0 (hash-table-count org-bbdb-anniv-hash)))
|
||||
(org-bbdb-make-anniv-hash))
|
||||
(maphash 'org-bbdb-format-vevent org-bbdb-anniv-hash))
|
||||
|
||||
(defun org-bbdb-format-vevent (key recs)
|
||||
(let (rec categ)
|
||||
(while (setq rec (pop recs))
|
||||
(setq categ (or (nth 2 rec) org-bbdb-default-anniversary-format))
|
||||
(princ (format "BEGIN:VEVENT
|
||||
UID: ANNIV-%4i%02i%02i-%s
|
||||
DTSTART:%4i%02i%02i
|
||||
SUMMARY:%s
|
||||
DESCRIPTION:%s
|
||||
CATEGORIES:%s
|
||||
RRULE:FREQ=YEARLY
|
||||
END:VEVENT\n"
|
||||
(nth 0 rec) (nth 0 key) (nth 1 key)
|
||||
(mapconcat 'identity
|
||||
(org-split-string (nth 1 rec) "[^a-zA-Z0-90]+")
|
||||
"-")
|
||||
(nth 0 rec) (nth 0 key) (nth 1 key)
|
||||
(nth 1 rec)
|
||||
(concat (capitalize categ) " " (nth 1 rec))
|
||||
categ)))))
|
||||
|
||||
(provide 'org-bbdb)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-bbdb.el ends here
|
739
elpa/org-20160919/org-bibtex.el
Normal file
739
elpa/org-20160919/org-bibtex.el
Normal file
@ -0,0 +1,739 @@
|
||||
;;; org-bibtex.el --- Org links to BibTeX entries
|
||||
;;
|
||||
;; Copyright (C) 2007-2016 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Authors: Bastien Guerry <bzg@gnu.org>
|
||||
;; Carsten Dominik <carsten dot dominik at gmail dot com>
|
||||
;; Eric Schulte <schulte dot eric at gmail dot com>
|
||||
;; Keywords: org, wp, capture
|
||||
;;
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This file implements links to database entries in BibTeX files.
|
||||
;; Instead of defining a special link prefix, it uses the normal file
|
||||
;; links combined with a custom search mechanism to find entries
|
||||
;; by reference key. And it constructs a nice description tag for
|
||||
;; the link that contains the author name, the year and a short title.
|
||||
;;
|
||||
;; It also stores detailed information about the entry so that
|
||||
;; capture templates can access and enter this information easily.
|
||||
;;
|
||||
;; The available properties for each entry are listed here:
|
||||
;;
|
||||
;; :author :publisher :volume :pages
|
||||
;; :editor :url :number :journal
|
||||
;; :title :year :series :address
|
||||
;; :booktitle :month :annote :abstract
|
||||
;; :key :btype
|
||||
;;
|
||||
;; Here is an example of a capture template that use some of this
|
||||
;; information (:author :year :title :journal :pages):
|
||||
;;
|
||||
;; (setq org-capture-templates
|
||||
;; '((?b "* READ %?\n\n%a\n\n%:author (%:year): %:title\n \
|
||||
;; In %:journal, %:pages.")))
|
||||
;;
|
||||
;; Let's say you want to capture this BibTeX entry:
|
||||
;;
|
||||
;; @Article{dolev83,
|
||||
;; author = {Danny Dolev and Andrew C. Yao},
|
||||
;; title = {On the security of public-key protocols},
|
||||
;; journal = {IEEE Transaction on Information Theory},
|
||||
;; year = 1983,
|
||||
;; volume = 2,
|
||||
;; number = 29,
|
||||
;; pages = {198--208},
|
||||
;; month = {Mars}
|
||||
;; }
|
||||
;;
|
||||
;; M-x `org-capture' on this entry will produce this buffer:
|
||||
;;
|
||||
;; =====================================================================
|
||||
;; * READ <== [point here]
|
||||
;;
|
||||
;; [[file:file.bib::dolev83][Dolev & Yao 1983: security of public key protocols]]
|
||||
;;
|
||||
;; Danny Dolev and Andrew C. Yao (1983): On the security of public-key protocols
|
||||
;; In IEEE Transaction on Information Theory, 198--208.
|
||||
;; =====================================================================
|
||||
;;
|
||||
;; Additionally, the following functions are now available for storing
|
||||
;; bibtex entries within Org-mode documents.
|
||||
;;
|
||||
;; - Run `org-bibtex' to export the current file to a .bib.
|
||||
;;
|
||||
;; - Run `org-bibtex-check' or `org-bibtex-check-all' to check and
|
||||
;; fill in missing field of either the current, or all headlines
|
||||
;;
|
||||
;; - Run `org-bibtex-create' to add a bibtex entry
|
||||
;;
|
||||
;; - Use `org-bibtex-read' to read a bibtex entry after `point' or in
|
||||
;; the active region, then call `org-bibtex-write' in a .org file to
|
||||
;; insert a heading for the read bibtex entry
|
||||
;;
|
||||
;; - All Bibtex information is taken from the document compiled by
|
||||
;; Andrew Roberts from the Bibtex manual, available at
|
||||
;; http://www.andy-roberts.net/res/writing/latex/bibentries.pdf
|
||||
;;
|
||||
;;; History:
|
||||
;;
|
||||
;; The link creation part has been part of Org-mode for a long time.
|
||||
;;
|
||||
;; Creating better capture template information was inspired by a request
|
||||
;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112
|
||||
;; and then implemented by Bastien Guerry.
|
||||
;;
|
||||
;; Eric Schulte eventually added the functions for translating between
|
||||
;; Org-mode headlines and Bibtex entries, and for fleshing out the Bibtex
|
||||
;; fields of existing Org-mode headlines.
|
||||
;;
|
||||
;; Org-mode loads this module by default - if this is not what you want,
|
||||
;; configure the variable `org-modules'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'bibtex)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'org-compat)
|
||||
|
||||
(defvar org-bibtex-description nil) ; dynamically scoped from org.el
|
||||
(defvar org-id-locations)
|
||||
|
||||
(declare-function bibtex-beginning-of-entry "bibtex" ())
|
||||
(declare-function bibtex-generate-autokey "bibtex" ())
|
||||
(declare-function bibtex-parse-entry "bibtex" (&optional content))
|
||||
(declare-function bibtex-url "bibtex" (&optional pos no-browse))
|
||||
(declare-function org-babel-trim "ob-core" (string &optional regexp))
|
||||
|
||||
|
||||
;;; Bibtex data
|
||||
(defvar org-bibtex-types
|
||||
'((:article
|
||||
(:description . "An article from a journal or magazine")
|
||||
(:required :author :title :journal :year)
|
||||
(:optional :volume :number :pages :month :note))
|
||||
(:book
|
||||
(:description . "A book with an explicit publisher")
|
||||
(:required (:editor :author) :title :publisher :year)
|
||||
(:optional (:volume :number) :series :address :edition :month :note))
|
||||
(:booklet
|
||||
(:description . "A work that is printed and bound, but without a named publisher or sponsoring institution.")
|
||||
(:required :title)
|
||||
(:optional :author :howpublished :address :month :year :note))
|
||||
(:conference
|
||||
(:description . "")
|
||||
(:required :author :title :booktitle :year)
|
||||
(:optional :editor :pages :organization :publisher :address :month :note))
|
||||
(:inbook
|
||||
(:description . "A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.")
|
||||
(:required (:author :editor) :title (:chapter :pages) :publisher :year)
|
||||
(:optional :crossref (:volume :number) :series :type :address :edition :month :note))
|
||||
(:incollection
|
||||
(:description . "A part of a book having its own title.")
|
||||
(:required :author :title :booktitle :publisher :year)
|
||||
(:optional :crossref :editor (:volume :number) :series :type :chapter :pages :address :edition :month :note))
|
||||
(:inproceedings
|
||||
(:description . "An article in a conference proceedings")
|
||||
(:required :author :title :booktitle :year)
|
||||
(:optional :crossref :editor (:volume :number) :series :pages :address :month :organization :publisher :note))
|
||||
(:manual
|
||||
(:description . "Technical documentation.")
|
||||
(:required :title)
|
||||
(:optional :author :organization :address :edition :month :year :note))
|
||||
(:mastersthesis
|
||||
(:description . "A Master’s thesis.")
|
||||
(:required :author :title :school :year)
|
||||
(:optional :type :address :month :note))
|
||||
(:misc
|
||||
(:description . "Use this type when nothing else fits.")
|
||||
(:required)
|
||||
(:optional :author :title :howpublished :month :year :note))
|
||||
(:phdthesis
|
||||
(:description . "A PhD thesis.")
|
||||
(:required :author :title :school :year)
|
||||
(:optional :type :address :month :note))
|
||||
(:proceedings
|
||||
(:description . "The proceedings of a conference.")
|
||||
(:required :title :year)
|
||||
(:optional :editor (:volume :number) :series :address :month :organization :publisher :note))
|
||||
(:techreport
|
||||
(:description . "A report published by a school or other institution.")
|
||||
(:required :author :title :institution :year)
|
||||
(:optional :type :address :month :note))
|
||||
(:unpublished
|
||||
(:description . "A document having an author and title, but not formally published.")
|
||||
(:required :author :title :note)
|
||||
(:optional :month :year)))
|
||||
"Bibtex entry types with required and optional parameters.")
|
||||
|
||||
(defvar org-bibtex-fields
|
||||
'((:address . "Usually the address of the publisher or other type of institution. For major publishing houses, van Leunen recommends omitting the information entirely. For small publishers, on the other hand, you can help the reader by giving the complete address.")
|
||||
(:annote . "An annotation. It is not used by the standard bibliography styles, but may be used by others that produce an annotated bibliography.")
|
||||
(:author . "The name(s) of the author(s), in the format described in the LaTeX book. Remember, all names are separated with the and keyword, and not commas.")
|
||||
(:booktitle . "Title of a book, part of which is being cited. See the LaTeX book for how to type titles. For book entries, use the title field instead.")
|
||||
(:chapter . "A chapter (or section or whatever) number.")
|
||||
(:crossref . "The database key of the entry being cross referenced.")
|
||||
(:edition . "The edition of a book for example, 'Second'. This should be an ordinal, and should have the first letter capitalized, as shown here; the standard styles convert to lower case when necessary.")
|
||||
(:editor . "Name(s) of editor(s), typed as indicated in the LaTeX book. If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears.")
|
||||
(:howpublished . "How something strange has been published. The first word should be capitalized.")
|
||||
(:institution . "The sponsoring institution of a technical report.")
|
||||
(:journal . "A journal name.")
|
||||
(:key . "Used for alphabetizing, cross-referencing, and creating a label when the author information is missing. This field should not be confused with the key that appears in the \\cite command and at the beginning of the database entry.")
|
||||
(:month . "The month in which the work was published or, for an unpublished work, in which it was written. You should use the standard three-letter abbreviation,")
|
||||
(:note . "Any additional information that can help the reader. The first word should be capitalized.")
|
||||
(:number . "Any additional information that can help the reader. The first word should be capitalized.")
|
||||
(:organization . "The organization that sponsors a conference or that publishes a manual.")
|
||||
(:pages . "One or more page numbers or range of numbers, such as 42-111 or 7,41,73-97 or 43+ (the ‘+’ in this last example indicates pages following that don’t form simple range). BibTEX requires double dashes for page ranges (--).")
|
||||
(:publisher . "The publisher’s name.")
|
||||
(:school . "The name of the school where a thesis was written.")
|
||||
(:series . "The name of a series or set of books. When citing an entire book, the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
|
||||
(:title . "The work’s title, typed as explained in the LaTeX book.")
|
||||
(:type . "The type of a technical report for example, 'Research Note'.")
|
||||
(:volume . "The volume of a journal or multi-volume book.")
|
||||
(:year . "The year of publication or, for an unpublished work, the year it was written. Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'"))
|
||||
"Bibtex fields with descriptions.")
|
||||
|
||||
(defvar org-bibtex-entries nil
|
||||
"List to hold parsed bibtex entries.")
|
||||
|
||||
(defcustom org-bibtex-autogen-keys nil
|
||||
"Set to a truth value to use `bibtex-generate-autokey' to generate keys."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-bibtex-prefix nil
|
||||
"Optional prefix for all bibtex property names.
|
||||
For example setting to `BIB_' would allow interoperability with fireforg."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type '(choice
|
||||
(const nil)
|
||||
(string)))
|
||||
|
||||
(defcustom org-bibtex-treat-headline-as-title t
|
||||
"Treat headline text as title if title property is absent.
|
||||
If an entry is missing a title property, use the headline text as
|
||||
the property. If this value is t, `org-bibtex-check' will ignore
|
||||
a missing title field."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-bibtex-export-arbitrary-fields nil
|
||||
"When converting to bibtex allow fields not defined in `org-bibtex-fields'.
|
||||
This only has effect if `org-bibtex-prefix' is defined, so as to
|
||||
ensure that other org-properties, such as CATEGORY or LOGGING are
|
||||
not placed in the exported bibtex entry."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-bibtex-key-property "CUSTOM_ID"
|
||||
"Property that holds the bibtex key.
|
||||
By default, this is CUSTOM_ID, which enables easy linking to
|
||||
bibtex headlines from within an org file. This can be set to ID
|
||||
to enable global links, but only with great caution, as global
|
||||
IDs must be unique."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-bibtex-tags nil
|
||||
"List of tag(s) that should be added to new bib entries."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type '(repeat :tag "Tag" (string)))
|
||||
|
||||
(defcustom org-bibtex-tags-are-keywords nil
|
||||
"Convert the value of the keywords field to tags and vice versa.
|
||||
|
||||
When non-nil, comma-separated entries in a bibtex entry's keywords
|
||||
field will be converted to Org tags. Note: spaces will be escaped
|
||||
with underscores, and characters that are not permitted in Org
|
||||
tags will be removed.
|
||||
|
||||
When non-nil, local tags in an Org entry will be exported as
|
||||
a comma-separated string of keywords when exported to bibtex.
|
||||
If `org-bibtex-inherit-tags' is non-nil, inherited tags will also
|
||||
be exported as keywords. Tags defined in `org-bibtex-tags' or
|
||||
`org-bibtex-no-export-tags' will not be exported."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-bibtex-no-export-tags nil
|
||||
"List of tag(s) that should not be converted to keywords.
|
||||
This variable is relevant only if `org-bibtex-tags-are-keywords'
|
||||
is non-nil."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type '(repeat :tag "Tag" (string)))
|
||||
|
||||
(defcustom org-bibtex-inherit-tags nil
|
||||
"Controls whether inherited tags are converted to bibtex keywords.
|
||||
It is relevant only if `org-bibtex-tags-are-keywords' is non-nil.
|
||||
Tag inheritence itself is controlled by `org-use-tag-inheritence'
|
||||
and `org-exclude-tags-from-inheritence'."
|
||||
:group 'org-bibtex
|
||||
:version "25.1"
|
||||
:package-version '(Org . "8.3")
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-bibtex-type-property-name "btype"
|
||||
"Property in which to store bibtex entry type (e.g., article)."
|
||||
:group 'org-bibtex
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
|
||||
;;; Utility functions
|
||||
(defun org-bibtex-get (property)
|
||||
(let ((it (let ((org-special-properties
|
||||
(delete "FILE" (copy-sequence org-special-properties))))
|
||||
(or
|
||||
(org-entry-get (point) (upcase property))
|
||||
(org-entry-get (point) (concat org-bibtex-prefix
|
||||
(upcase property)))))))
|
||||
(when it (org-babel-trim it))))
|
||||
|
||||
(defun org-bibtex-put (property value)
|
||||
(let ((prop (upcase (if (keywordp property)
|
||||
(substring (symbol-name property) 1)
|
||||
property))))
|
||||
(org-set-property
|
||||
(concat (unless (string= org-bibtex-key-property prop) org-bibtex-prefix)
|
||||
prop)
|
||||
value)))
|
||||
|
||||
(defun org-bibtex-headline ()
|
||||
"Return a bibtex entry of the given headline as a string."
|
||||
(let* ((val (lambda (key lst) (cdr (assoc key lst))))
|
||||
(to (lambda (string) (intern (concat ":" string))))
|
||||
(from (lambda (key) (substring (symbol-name key) 1)))
|
||||
flatten ; silent compiler warning
|
||||
(flatten (lambda (&rest lsts)
|
||||
(apply #'append (mapcar
|
||||
(lambda (e)
|
||||
(if (listp e) (apply flatten e) (list e)))
|
||||
lsts))))
|
||||
(notes (buffer-string))
|
||||
(id (org-bibtex-get org-bibtex-key-property))
|
||||
(type (org-bibtex-get org-bibtex-type-property-name))
|
||||
(tags (when org-bibtex-tags-are-keywords
|
||||
(delq nil
|
||||
(mapcar
|
||||
(lambda (tag)
|
||||
(unless (member tag
|
||||
(append org-bibtex-tags
|
||||
org-bibtex-no-export-tags))
|
||||
tag))
|
||||
(if org-bibtex-inherit-tags
|
||||
(org-get-tags-at)
|
||||
(org-get-local-tags-at)))))))
|
||||
(when type
|
||||
(let ((entry (format
|
||||
"@%s{%s,\n%s\n}\n" type id
|
||||
(mapconcat
|
||||
(lambda (pair)
|
||||
(format " %s={%s}" (car pair) (cdr pair)))
|
||||
(remove nil
|
||||
(if (and org-bibtex-export-arbitrary-fields
|
||||
org-bibtex-prefix)
|
||||
(mapcar
|
||||
(lambda (kv)
|
||||
(let ((key (car kv)) (val0 (cdr kv)))
|
||||
(when (and
|
||||
(string-match org-bibtex-prefix key)
|
||||
(not (string=
|
||||
(downcase (concat org-bibtex-prefix
|
||||
org-bibtex-type-property-name))
|
||||
(downcase key))))
|
||||
(cons (downcase (replace-regexp-in-string
|
||||
org-bibtex-prefix "" key))
|
||||
val0))))
|
||||
(org-entry-properties nil 'standard))
|
||||
(mapcar
|
||||
(lambda (field)
|
||||
(let ((value (or (org-bibtex-get (funcall from field))
|
||||
(and (equal :title field)
|
||||
(nth 4 (org-heading-components))))))
|
||||
(when value (cons (funcall from field) value))))
|
||||
(funcall flatten
|
||||
(funcall val :required (funcall val (funcall to type) org-bibtex-types))
|
||||
(funcall val :optional (funcall val (funcall to type) org-bibtex-types))))))
|
||||
",\n"))))
|
||||
(with-temp-buffer
|
||||
(insert entry)
|
||||
(when tags
|
||||
(bibtex-beginning-of-entry)
|
||||
(if (re-search-forward "keywords.*=.*{\\(.*\\)}" nil t)
|
||||
(progn (goto-char (match-end 1)) (insert ", "))
|
||||
(search-forward ",\n" nil t)
|
||||
(insert " keywords={},\n")
|
||||
(search-backward "}," nil t))
|
||||
(insert (mapconcat #'identity tags ", ")))
|
||||
(buffer-string))))))
|
||||
|
||||
(defun org-bibtex-ask (field)
|
||||
(unless (assoc field org-bibtex-fields)
|
||||
(error "Field:%s is not known" field))
|
||||
(save-window-excursion
|
||||
(let* ((name (substring (symbol-name field) 1))
|
||||
(buf-name (format "*Bibtex Help %s*" name)))
|
||||
(with-output-to-temp-buffer buf-name
|
||||
(princ (cdr (assoc field org-bibtex-fields))))
|
||||
(with-current-buffer buf-name (visual-line-mode 1))
|
||||
(org-fit-window-to-buffer (get-buffer-window buf-name))
|
||||
(let ((result (read-from-minibuffer (format "%s: " name))))
|
||||
(when (> (length result) 0) result)))))
|
||||
|
||||
(defun org-bibtex-autokey ()
|
||||
"Generate an autokey for the current headline."
|
||||
(org-bibtex-put org-bibtex-key-property
|
||||
(if org-bibtex-autogen-keys
|
||||
(let* ((entry (org-bibtex-headline))
|
||||
(key
|
||||
(with-temp-buffer
|
||||
(insert entry)
|
||||
(bibtex-generate-autokey))))
|
||||
;; test for duplicate IDs if using global ID
|
||||
(when (and
|
||||
(equal org-bibtex-key-property "ID")
|
||||
(featurep 'org-id)
|
||||
(hash-table-p org-id-locations)
|
||||
(gethash key org-id-locations))
|
||||
(warn "Another entry has the same ID"))
|
||||
key)
|
||||
(read-from-minibuffer "id: "))))
|
||||
|
||||
(defun org-bibtex-fleshout (type &optional optional)
|
||||
"Fleshout current heading, ensuring all required fields are present.
|
||||
With optional argument OPTIONAL, also prompt for optional fields."
|
||||
(let ((val (lambda (key lst) (cdr (assoc key lst))))
|
||||
(keyword (lambda (name) (intern (concat ":" (downcase name)))))
|
||||
(name (lambda (keyword) (substring (symbol-name keyword) 1))))
|
||||
(dolist (field (append
|
||||
(if org-bibtex-treat-headline-as-title
|
||||
(remove :title (funcall val :required (funcall val type org-bibtex-types)))
|
||||
(funcall val :required (funcall val type org-bibtex-types)))
|
||||
(when optional (funcall val :optional (funcall val type org-bibtex-types)))))
|
||||
(when (consp field) ; or'd pair of fields e.g., (:editor :author)
|
||||
(let ((present (first (remove
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (f) (when (org-bibtex-get (funcall name f)) f))
|
||||
field)))))
|
||||
(setf field (or present (funcall keyword
|
||||
(org-icompleting-read
|
||||
"Field: " (mapcar name field)))))))
|
||||
(let ((name (funcall name field)))
|
||||
(unless (org-bibtex-get name)
|
||||
(let ((prop (org-bibtex-ask field)))
|
||||
(when prop (org-bibtex-put name prop)))))))
|
||||
(when (and type (assoc type org-bibtex-types)
|
||||
(not (org-bibtex-get org-bibtex-key-property)))
|
||||
(org-bibtex-autokey)))
|
||||
|
||||
|
||||
;;; Bibtex link functions
|
||||
(org-add-link-type "bibtex" 'org-bibtex-open)
|
||||
(add-hook 'org-store-link-functions 'org-bibtex-store-link)
|
||||
|
||||
(defun org-bibtex-open (path)
|
||||
"Visit the bibliography entry on PATH."
|
||||
(let* ((search (when (string-match "::\\(.+\\)\\'" path)
|
||||
(match-string 1 path)))
|
||||
(path (substring path 0 (match-beginning 0))))
|
||||
(org-open-file path t nil search)))
|
||||
|
||||
(defun org-bibtex-store-link ()
|
||||
"Store a link to a BibTeX entry."
|
||||
(when (eq major-mode 'bibtex-mode)
|
||||
(let* ((search (org-create-file-search-in-bibtex))
|
||||
(link (concat "file:" (abbreviate-file-name buffer-file-name)
|
||||
"::" search))
|
||||
(entry (mapcar ; repair strings enclosed in "..." or {...}
|
||||
(lambda(c)
|
||||
(if (string-match
|
||||
"^\\(?:{\\|\"\\)\\(.*\\)\\(?:}\\|\"\\)$" (cdr c))
|
||||
(cons (car c) (match-string 1 (cdr c))) c))
|
||||
(save-excursion
|
||||
(bibtex-beginning-of-entry)
|
||||
(bibtex-parse-entry)))))
|
||||
(org-store-link-props
|
||||
:key (cdr (assoc "=key=" entry))
|
||||
:author (or (cdr (assoc "author" entry)) "[no author]")
|
||||
:editor (or (cdr (assoc "editor" entry)) "[no editor]")
|
||||
:title (or (cdr (assoc "title" entry)) "[no title]")
|
||||
:booktitle (or (cdr (assoc "booktitle" entry)) "[no booktitle]")
|
||||
:journal (or (cdr (assoc "journal" entry)) "[no journal]")
|
||||
:publisher (or (cdr (assoc "publisher" entry)) "[no publisher]")
|
||||
:pages (or (cdr (assoc "pages" entry)) "[no pages]")
|
||||
:url (or (cdr (assoc "url" entry)) "[no url]")
|
||||
:year (or (cdr (assoc "year" entry)) "[no year]")
|
||||
:month (or (cdr (assoc "month" entry)) "[no month]")
|
||||
:address (or (cdr (assoc "address" entry)) "[no address]")
|
||||
:volume (or (cdr (assoc "volume" entry)) "[no volume]")
|
||||
:number (or (cdr (assoc "number" entry)) "[no number]")
|
||||
:annote (or (cdr (assoc "annote" entry)) "[no annotation]")
|
||||
:series (or (cdr (assoc "series" entry)) "[no series]")
|
||||
:abstract (or (cdr (assoc "abstract" entry)) "[no abstract]")
|
||||
:btype (or (cdr (assoc "=type=" entry)) "[no type]")
|
||||
:type "bibtex"
|
||||
:link link
|
||||
:description org-bibtex-description))))
|
||||
|
||||
(defun org-create-file-search-in-bibtex ()
|
||||
"Create the search string and description for a BibTeX database entry."
|
||||
;; Make a good description for this entry, using names, year and the title
|
||||
;; Put it into the `description' variable which is dynamically scoped.
|
||||
(let ((bibtex-autokey-names 1)
|
||||
(bibtex-autokey-names-stretch 1)
|
||||
(bibtex-autokey-name-case-convert-function 'identity)
|
||||
(bibtex-autokey-name-separator " & ")
|
||||
(bibtex-autokey-additional-names " et al.")
|
||||
(bibtex-autokey-year-length 4)
|
||||
(bibtex-autokey-name-year-separator " ")
|
||||
(bibtex-autokey-titlewords 3)
|
||||
(bibtex-autokey-titleword-separator " ")
|
||||
(bibtex-autokey-titleword-case-convert-function 'identity)
|
||||
(bibtex-autokey-titleword-length 'infty)
|
||||
(bibtex-autokey-year-title-separator ": "))
|
||||
(setq org-bibtex-description (bibtex-generate-autokey)))
|
||||
;; Now parse the entry, get the key and return it.
|
||||
(save-excursion
|
||||
(bibtex-beginning-of-entry)
|
||||
(cdr (assoc "=key=" (bibtex-parse-entry)))))
|
||||
|
||||
(defun org-execute-file-search-in-bibtex (s)
|
||||
"Find the link search string S as a key for a database entry."
|
||||
(when (eq major-mode 'bibtex-mode)
|
||||
;; Yes, we want to do the search in this file.
|
||||
;; We construct a regexp that searches for "@entrytype{" followed by the key
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward (concat "@[a-zA-Z]+[ \t\n]*{[ \t\n]*"
|
||||
(regexp-quote s) "[ \t\n]*,") nil t)
|
||||
(goto-char (match-beginning 0)))
|
||||
(if (and (match-beginning 0) (equal current-prefix-arg '(16)))
|
||||
;; Use double prefix to indicate that any web link should be browsed
|
||||
(let ((b (current-buffer)) (p (point)))
|
||||
;; Restore the window configuration because we just use the web link
|
||||
(set-window-configuration org-window-config-before-follow-link)
|
||||
(with-current-buffer b
|
||||
(goto-char p)
|
||||
(bibtex-url)))
|
||||
(recenter 0)) ; Move entry start to beginning of window
|
||||
;; return t to indicate that the search is done.
|
||||
t))
|
||||
|
||||
;; Finally add the link search function to the right hook.
|
||||
(add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex)
|
||||
|
||||
|
||||
;;; Bibtex <-> Org-mode headline translation functions
|
||||
(defun org-bibtex (filename)
|
||||
"Export each headline in the current file to a bibtex entry.
|
||||
Headlines are exported using `org-bibtex-headline'."
|
||||
(interactive
|
||||
(list (read-file-name
|
||||
"Bibtex file: " nil nil nil
|
||||
(let ((file (buffer-file-name (buffer-base-buffer))))
|
||||
(and file
|
||||
(file-name-nondirectory
|
||||
(concat (file-name-sans-extension file) ".bib")))))))
|
||||
(let ((error-point
|
||||
(catch 'bib
|
||||
(let ((bibtex-entries
|
||||
(remove nil (org-map-entries
|
||||
(lambda ()
|
||||
(condition-case foo
|
||||
(org-bibtex-headline)
|
||||
(error (throw 'bib (point)))))))))
|
||||
(with-temp-file filename
|
||||
(insert (mapconcat #'identity bibtex-entries "\n")))
|
||||
(message "Successfully exported %d BibTeX entries to %s"
|
||||
(length bibtex-entries) filename) nil))))
|
||||
(when error-point
|
||||
(goto-char error-point)
|
||||
(message "Bibtex error at %S" (nth 4 (org-heading-components))))))
|
||||
|
||||
(defun org-bibtex-check (&optional optional)
|
||||
"Check the current headline for required fields.
|
||||
With prefix argument OPTIONAL also prompt for optional fields."
|
||||
(interactive "P")
|
||||
(save-restriction
|
||||
(org-narrow-to-subtree)
|
||||
(let ((type (let ((name (org-bibtex-get org-bibtex-type-property-name)))
|
||||
(when name (intern (concat ":" name))))))
|
||||
(when type (org-bibtex-fleshout type optional)))))
|
||||
|
||||
(defun org-bibtex-check-all (&optional optional)
|
||||
"Check all headlines in the current file.
|
||||
With prefix argument OPTIONAL also prompt for optional fields."
|
||||
(interactive) (org-map-entries (lambda () (org-bibtex-check optional))))
|
||||
|
||||
(defun org-bibtex-create (&optional arg nonew)
|
||||
"Create a new entry at the given level.
|
||||
With a prefix arg, query for optional fields as well.
|
||||
If nonew is t, add data to the headline of the entry at point."
|
||||
(interactive "P")
|
||||
(let* ((type (org-icompleting-read
|
||||
"Type: " (mapcar (lambda (type)
|
||||
(substring (symbol-name (car type)) 1))
|
||||
org-bibtex-types)
|
||||
nil nil (when nonew
|
||||
(org-bibtex-get org-bibtex-type-property-name))))
|
||||
(type (if (keywordp type) type (intern (concat ":" type))))
|
||||
(org-bibtex-treat-headline-as-title (if nonew nil t)))
|
||||
(unless (assoc type org-bibtex-types)
|
||||
(error "Type:%s is not known" type))
|
||||
(if nonew
|
||||
(org-back-to-heading)
|
||||
(org-insert-heading)
|
||||
(let ((title (org-bibtex-ask :title)))
|
||||
(insert title)
|
||||
(org-bibtex-put "TITLE" title)))
|
||||
(org-bibtex-put org-bibtex-type-property-name
|
||||
(substring (symbol-name type) 1))
|
||||
(org-bibtex-fleshout type arg)
|
||||
(mapc (lambda (tag) (org-toggle-tag tag 'on)) org-bibtex-tags)))
|
||||
|
||||
(defun org-bibtex-create-in-current-entry (&optional arg)
|
||||
"Add bibliographical data to the current entry.
|
||||
With a prefix arg, query for optional fields."
|
||||
(interactive "P")
|
||||
(org-bibtex-create arg t))
|
||||
|
||||
(defun org-bibtex-read ()
|
||||
"Read a bibtex entry and save to `org-bibtex-entries'.
|
||||
This uses `bibtex-parse-entry'."
|
||||
(interactive)
|
||||
(let ((keyword (lambda (str) (intern (concat ":" (downcase str)))))
|
||||
(clean-space (lambda (str) (replace-regexp-in-string
|
||||
"[[:space:]\n\r]+" " " str)))
|
||||
(strip-delim
|
||||
(lambda (str) ; strip enclosing "..." and {...}
|
||||
(dolist (pair '((34 . 34) (123 . 125) (123 . 125)))
|
||||
(when (and (> (length str) 1)
|
||||
(= (aref str 0) (car pair))
|
||||
(= (aref str (1- (length str))) (cdr pair)))
|
||||
(setf str (substring str 1 (1- (length str)))))) str)))
|
||||
(push (mapcar
|
||||
(lambda (pair)
|
||||
(cons (let ((field (funcall keyword (car pair))))
|
||||
(case field
|
||||
(:=type= :type)
|
||||
(:=key= :key)
|
||||
(otherwise field)))
|
||||
(funcall clean-space (funcall strip-delim (cdr pair)))))
|
||||
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
|
||||
org-bibtex-entries)))
|
||||
|
||||
(defun org-bibtex-read-buffer (buffer)
|
||||
"Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
|
||||
Return the number of saved entries."
|
||||
(interactive "bBuffer: ")
|
||||
(let ((start-length (length org-bibtex-entries)))
|
||||
(with-current-buffer buffer
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (not (= (point) (point-min)))
|
||||
(backward-char 1)
|
||||
(org-bibtex-read)
|
||||
(bibtex-beginning-of-entry))))
|
||||
(let ((added (- (length org-bibtex-entries) start-length)))
|
||||
(message "Parsed %d entries" added)
|
||||
added)))
|
||||
|
||||
(defun org-bibtex-read-file (file)
|
||||
"Read FILE with `org-bibtex-read-buffer'."
|
||||
(interactive "fFile: ")
|
||||
(org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile)))
|
||||
|
||||
(defun org-bibtex-write ()
|
||||
"Insert a heading built from the first element of `org-bibtex-entries'."
|
||||
(interactive)
|
||||
(when (= (length org-bibtex-entries) 0)
|
||||
(error "No entries in `org-bibtex-entries'"))
|
||||
(let* ((entry (pop org-bibtex-entries))
|
||||
(org-special-properties nil) ; avoids errors with `org-entry-put'
|
||||
(val (lambda (field) (cdr (assoc field entry))))
|
||||
(togtag (lambda (tag) (org-toggle-tag tag 'on))))
|
||||
(org-insert-heading)
|
||||
(insert (funcall val :title))
|
||||
(org-bibtex-put "TITLE" (funcall val :title))
|
||||
(org-bibtex-put org-bibtex-type-property-name
|
||||
(downcase (funcall val :type)))
|
||||
(dolist (pair entry)
|
||||
(case (car pair)
|
||||
(:title nil)
|
||||
(:type nil)
|
||||
(:key (org-bibtex-put org-bibtex-key-property (cdr pair)))
|
||||
(:keywords (if org-bibtex-tags-are-keywords
|
||||
(mapc
|
||||
(lambda (kw)
|
||||
(funcall
|
||||
togtag
|
||||
(replace-regexp-in-string
|
||||
"[^[:alnum:]_@#%]" ""
|
||||
(replace-regexp-in-string "[ \t]+" "_" kw))))
|
||||
(split-string (cdr pair) ", *"))
|
||||
(org-bibtex-put (car pair) (cdr pair))))
|
||||
(otherwise (org-bibtex-put (car pair) (cdr pair)))))
|
||||
(mapc togtag org-bibtex-tags)))
|
||||
|
||||
(defun org-bibtex-yank ()
|
||||
"If kill ring holds a bibtex entry yank it as an Org-mode headline."
|
||||
(interactive)
|
||||
(let (entry)
|
||||
(with-temp-buffer (yank 1) (setf entry (org-bibtex-read)))
|
||||
(if entry
|
||||
(org-bibtex-write)
|
||||
(error "Yanked text does not appear to contain a BibTeX entry"))))
|
||||
|
||||
(defun org-bibtex-import-from-file (file)
|
||||
"Read bibtex entries from FILE and insert as Org-mode headlines after point."
|
||||
(interactive "fFile: ")
|
||||
(dotimes (_ (org-bibtex-read-file file))
|
||||
(save-excursion (org-bibtex-write))
|
||||
(re-search-forward org-property-end-re)
|
||||
(open-line 1) (forward-char 1)))
|
||||
|
||||
(defun org-bibtex-export-to-kill-ring ()
|
||||
"Export current headline to kill ring as bibtex entry."
|
||||
(interactive)
|
||||
(let ((result (org-bibtex-headline)))
|
||||
(kill-new result) result))
|
||||
|
||||
(defun org-bibtex-search (string)
|
||||
"Search for bibliographical entries in agenda files.
|
||||
This function relies `org-search-view' to locate results."
|
||||
(interactive "sSearch string: ")
|
||||
(let ((org-agenda-overriding-header "Bib search results:")
|
||||
(org-agenda-search-view-always-boolean t))
|
||||
(org-search-view nil
|
||||
(format "%s +{:%s%s:}"
|
||||
string (or org-bibtex-prefix "")
|
||||
org-bibtex-type-property-name))))
|
||||
|
||||
(provide 'org-bibtex)
|
||||
|
||||
;;; org-bibtex.el ends here
|
1855
elpa/org-20160919/org-capture.el
Normal file
1855
elpa/org-20160919/org-capture.el
Normal file
File diff suppressed because it is too large
Load Diff
3044
elpa/org-20160919/org-clock.el
Normal file
3044
elpa/org-20160919/org-clock.el
Normal file
File diff suppressed because it is too large
Load Diff
1604
elpa/org-20160919/org-colview.el
Normal file
1604
elpa/org-20160919/org-colview.el
Normal file
File diff suppressed because it is too large
Load Diff
566
elpa/org-20160919/org-compat.el
Normal file
566
elpa/org-20160919/org-compat.el
Normal file
@ -0,0 +1,566 @@
|
||||
;;; org-compat.el --- Compatibility code for Org-mode
|
||||
|
||||
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains code needed for compatibility with XEmacs and older
|
||||
;; versions of GNU Emacs.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(require 'org-macs)
|
||||
|
||||
;; The following constant is for backward compatibility. We do not use
|
||||
;; it in org-mode, because the Byte compiler evaluates (featurep 'xemacs)
|
||||
;; at compilation time and can therefore optimize code better.
|
||||
(defconst org-xemacs-p (featurep 'xemacs))
|
||||
|
||||
(defun org-compatible-face (inherits specs)
|
||||
"Make a compatible face specification.
|
||||
If INHERITS is an existing face and if the Emacs version supports it,
|
||||
just inherit the face. If INHERITS is set and the Emacs version does
|
||||
not support it, copy the face specification from the inheritance face.
|
||||
If INHERITS is not given and SPECS is, use SPECS to define the face.
|
||||
XEmacs and Emacs 21 do not know about the `min-colors' attribute.
|
||||
For them we convert a (min-colors 8) entry to a `tty' entry and move it
|
||||
to the top of the list. The `min-colors' attribute will be removed from
|
||||
any other entries, and any resulting duplicates will be removed entirely."
|
||||
(when (and inherits (facep inherits) (not specs))
|
||||
(setq specs (or specs
|
||||
(get inherits 'saved-face)
|
||||
(get inherits 'face-defface-spec))))
|
||||
(cond
|
||||
((and inherits (facep inherits)
|
||||
(not (featurep 'xemacs))
|
||||
(>= emacs-major-version 22)
|
||||
;; do not inherit outline faces before Emacs 23
|
||||
(or (>= emacs-major-version 23)
|
||||
(not (string-match "\\`outline-[0-9]+"
|
||||
(symbol-name inherits)))))
|
||||
(list (list t :inherit inherits)))
|
||||
((or (featurep 'xemacs) (< emacs-major-version 22))
|
||||
;; These do not understand the `min-colors' attribute.
|
||||
(let (r e a)
|
||||
(while (setq e (pop specs))
|
||||
(cond
|
||||
((memq (car e) '(t default)) (push e r))
|
||||
((setq a (member '(min-colors 8) (car e)))
|
||||
(nconc r (list (cons (cons '(type tty) (delq (car a) (car e)))
|
||||
(cdr e)))))
|
||||
((setq a (assq 'min-colors (car e)))
|
||||
(setq e (cons (delq a (car e)) (cdr e)))
|
||||
(or (assoc (car e) r) (push e r)))
|
||||
(t (or (assoc (car e) r) (push e r)))))
|
||||
(nreverse r)))
|
||||
(t specs)))
|
||||
(put 'org-compatible-face 'lisp-indent-function 1)
|
||||
|
||||
(defun org-version-check (version feature level)
|
||||
(let* ((v1 (mapcar 'string-to-number (split-string version "[.]")))
|
||||
(v2 (mapcar 'string-to-number (split-string emacs-version "[.]")))
|
||||
(rmaj (or (nth 0 v1) 99))
|
||||
(rmin (or (nth 1 v1) 99))
|
||||
(rbld (or (nth 2 v1) 99))
|
||||
(maj (or (nth 0 v2) 0))
|
||||
(min (or (nth 1 v2) 0))
|
||||
(bld (or (nth 2 v2) 0)))
|
||||
(if (or (< maj rmaj)
|
||||
(and (= maj rmaj)
|
||||
(< min rmin))
|
||||
(and (= maj rmaj)
|
||||
(= min rmin)
|
||||
(< bld rbld)))
|
||||
(if (eq level :predicate)
|
||||
;; just return if we have the version
|
||||
nil
|
||||
(let ((msg (format "Emacs %s or greater is recommended for %s"
|
||||
version feature)))
|
||||
(display-warning 'org msg level)
|
||||
t))
|
||||
t)))
|
||||
|
||||
|
||||
;;;; Emacs/XEmacs compatibility
|
||||
|
||||
(eval-and-compile
|
||||
(defun org-defvaralias (new-alias base-variable &optional docstring)
|
||||
"Compatibility function for defvaralias.
|
||||
Don't do the aliasing when `defvaralias' is not bound."
|
||||
(declare (indent 1))
|
||||
(when (fboundp 'defvaralias)
|
||||
(defvaralias new-alias base-variable docstring)))
|
||||
|
||||
(when (and (not (boundp 'user-emacs-directory))
|
||||
(boundp 'user-init-directory))
|
||||
(org-defvaralias 'user-emacs-directory 'user-init-directory)))
|
||||
|
||||
(when (featurep 'xemacs)
|
||||
(defadvice custom-handle-keyword
|
||||
(around org-custom-handle-keyword
|
||||
activate preactivate)
|
||||
"Remove custom keywords not recognized to avoid producing an error."
|
||||
(cond
|
||||
((eq (ad-get-arg 1) :package-version))
|
||||
(t ad-do-it)))
|
||||
(defadvice define-obsolete-variable-alias
|
||||
(around org-define-obsolete-variable-alias
|
||||
(obsolete-name current-name &optional when docstring)
|
||||
activate preactivate)
|
||||
"Declare arguments defined in later versions of Emacs."
|
||||
ad-do-it)
|
||||
(defadvice define-obsolete-function-alias
|
||||
(around org-define-obsolete-function-alias
|
||||
(obsolete-name current-name &optional when docstring)
|
||||
activate preactivate)
|
||||
"Declare arguments defined in later versions of Emacs."
|
||||
ad-do-it)
|
||||
(defvar customize-package-emacs-version-alist nil)
|
||||
(defvar temporary-file-directory (temp-directory)))
|
||||
|
||||
;; Keys
|
||||
(defconst org-xemacs-key-equivalents
|
||||
'(([mouse-1] . [button1])
|
||||
([mouse-2] . [button2])
|
||||
([mouse-3] . [button3])
|
||||
([C-mouse-4] . [(control mouse-4)])
|
||||
([C-mouse-5] . [(control mouse-5)]))
|
||||
"Translation alist for a couple of keys.")
|
||||
|
||||
;; Overlay compatibility functions
|
||||
(defun org-detach-overlay (ovl)
|
||||
(if (featurep 'xemacs) (detach-extent ovl) (delete-overlay ovl)))
|
||||
(defun org-overlay-display (ovl text &optional face evap)
|
||||
"Make overlay OVL display TEXT with face FACE."
|
||||
(if (featurep 'xemacs)
|
||||
(let ((gl (make-glyph text)))
|
||||
(and face (set-glyph-face gl face))
|
||||
(set-extent-property ovl 'invisible t)
|
||||
(set-extent-property ovl 'end-glyph gl))
|
||||
(overlay-put ovl 'display text)
|
||||
(if face (overlay-put ovl 'face face))
|
||||
(if evap (overlay-put ovl 'evaporate t))))
|
||||
(defun org-overlay-before-string (ovl text &optional face evap)
|
||||
"Make overlay OVL display TEXT with face FACE."
|
||||
(if (featurep 'xemacs)
|
||||
(let ((gl (make-glyph text)))
|
||||
(and face (set-glyph-face gl face))
|
||||
(set-extent-property ovl 'begin-glyph gl))
|
||||
(if face (org-add-props text nil 'face face))
|
||||
(overlay-put ovl 'before-string text)
|
||||
(if evap (overlay-put ovl 'evaporate t))))
|
||||
(defun org-find-overlays (prop &optional pos delete)
|
||||
"Find all overlays specifying PROP at POS or point.
|
||||
If DELETE is non-nil, delete all those overlays."
|
||||
(let ((overlays (overlays-at (or pos (point))))
|
||||
ov found)
|
||||
(while (setq ov (pop overlays))
|
||||
(if (overlay-get ov prop)
|
||||
(if delete (delete-overlay ov) (push ov found))))
|
||||
found))
|
||||
|
||||
(defun org-get-x-clipboard (value)
|
||||
"Get the value of the x or Windows clipboard, compatible with XEmacs, and GNU Emacs 21."
|
||||
(cond ((eq window-system 'x)
|
||||
(let ((x (org-get-x-clipboard-compat value)))
|
||||
(if x (org-no-properties x))))
|
||||
((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
|
||||
(w32-get-clipboard-data))))
|
||||
|
||||
(defsubst org-decompose-region (beg end)
|
||||
"Decompose from BEG to END."
|
||||
(if (featurep 'xemacs)
|
||||
(let ((modified-p (buffer-modified-p))
|
||||
(buffer-read-only nil))
|
||||
(remove-text-properties beg end '(composition nil))
|
||||
(set-buffer-modified-p modified-p))
|
||||
(decompose-region beg end)))
|
||||
|
||||
;; Miscellaneous functions
|
||||
|
||||
(defun org-add-hook (hook function &optional append local)
|
||||
"Add-hook, compatible with both Emacsen."
|
||||
(if (and local (featurep 'xemacs))
|
||||
(add-local-hook hook function append)
|
||||
(add-hook hook function append local)))
|
||||
|
||||
(defun org-add-props (string plist &rest props)
|
||||
"Add text properties to entire string, from beginning to end.
|
||||
PLIST may be a list of properties, PROPS are individual properties and values
|
||||
that will be added to PLIST. Returns the string that was modified."
|
||||
(add-text-properties
|
||||
0 (length string) (if props (append plist props) plist) string)
|
||||
string)
|
||||
(put 'org-add-props 'lisp-indent-function 2)
|
||||
|
||||
(defun org-fit-window-to-buffer (&optional window max-height min-height
|
||||
shrink-only)
|
||||
"Fit WINDOW to the buffer, but only if it is not a side-by-side window.
|
||||
WINDOW defaults to the selected window. MAX-HEIGHT and MIN-HEIGHT are
|
||||
passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call
|
||||
`shrink-window-if-larger-than-buffer' instead, the height limit is
|
||||
ignored in this case."
|
||||
(cond ((if (fboundp 'window-full-width-p)
|
||||
(not (window-full-width-p window))
|
||||
;; do nothing if another window would suffer
|
||||
(> (frame-width) (window-width window))))
|
||||
((and (fboundp 'fit-window-to-buffer) (not shrink-only))
|
||||
(fit-window-to-buffer window max-height min-height))
|
||||
((fboundp 'shrink-window-if-larger-than-buffer)
|
||||
(shrink-window-if-larger-than-buffer window)))
|
||||
(or window (selected-window)))
|
||||
|
||||
(defun org-number-sequence (from &optional to inc)
|
||||
"Call `number-sequence' or emulate it."
|
||||
(if (fboundp 'number-sequence)
|
||||
(number-sequence from to inc)
|
||||
(if (or (not to) (= from to))
|
||||
(list from)
|
||||
(or inc (setq inc 1))
|
||||
(when (zerop inc) (error "The increment can not be zero"))
|
||||
(let (seq (n 0) (next from))
|
||||
(if (> inc 0)
|
||||
(while (<= next to)
|
||||
(setq seq (cons next seq)
|
||||
n (1+ n)
|
||||
next (+ from (* n inc))))
|
||||
(while (>= next to)
|
||||
(setq seq (cons next seq)
|
||||
n (1+ n)
|
||||
next (+ from (* n inc)))))
|
||||
(nreverse seq)))))
|
||||
|
||||
;; `set-transient-map' is only in Emacs >= 24.4
|
||||
(defalias 'org-set-transient-map
|
||||
(if (fboundp 'set-transient-map)
|
||||
'set-transient-map
|
||||
'set-temporary-overlay-map))
|
||||
|
||||
;; Region compatibility
|
||||
|
||||
(defvar org-ignore-region nil
|
||||
"Non-nil means temporarily disable the active region.")
|
||||
|
||||
(defun org-region-active-p ()
|
||||
"Is `transient-mark-mode' on and the region active?
|
||||
Works on both Emacs and XEmacs."
|
||||
(if org-ignore-region
|
||||
nil
|
||||
(if (featurep 'xemacs)
|
||||
(and zmacs-regions (region-active-p))
|
||||
(if (fboundp 'use-region-p)
|
||||
(use-region-p)
|
||||
(and transient-mark-mode mark-active))))) ; Emacs 22 and before
|
||||
|
||||
(defun org-cursor-to-region-beginning ()
|
||||
(when (and (org-region-active-p)
|
||||
(> (point) (region-beginning)))
|
||||
(exchange-point-and-mark)))
|
||||
|
||||
;; Old alias for emacs 22 compatibility, now dropped
|
||||
(define-obsolete-function-alias 'org-activate-mark 'activate-mark)
|
||||
|
||||
;; Invisibility compatibility
|
||||
|
||||
(defun org-remove-from-invisibility-spec (arg)
|
||||
"Remove elements from `buffer-invisibility-spec'."
|
||||
(if (fboundp 'remove-from-invisibility-spec)
|
||||
(remove-from-invisibility-spec arg)
|
||||
(if (consp buffer-invisibility-spec)
|
||||
(setq buffer-invisibility-spec
|
||||
(delete arg buffer-invisibility-spec)))))
|
||||
|
||||
(defun org-in-invisibility-spec-p (arg)
|
||||
"Is ARG a member of `buffer-invisibility-spec'?"
|
||||
(if (consp buffer-invisibility-spec)
|
||||
(member arg buffer-invisibility-spec)))
|
||||
|
||||
(defmacro org-xemacs-without-invisibility (&rest body)
|
||||
"Turn off extents with invisibility while executing BODY."
|
||||
`(let ((ext-inv (extent-list nil (point-at-bol) (point-at-eol)
|
||||
'all-extents-closed-open 'invisible))
|
||||
ext-inv-specs)
|
||||
(dolist (ext ext-inv)
|
||||
(when (extent-property ext 'invisible)
|
||||
(add-to-list 'ext-inv-specs (list ext (extent-property
|
||||
ext 'invisible)))
|
||||
(set-extent-property ext 'invisible nil)))
|
||||
,@body
|
||||
(dolist (ext-inv-spec ext-inv-specs)
|
||||
(set-extent-property (car ext-inv-spec) 'invisible
|
||||
(cadr ext-inv-spec)))))
|
||||
(def-edebug-spec org-xemacs-without-invisibility (body))
|
||||
|
||||
(defun org-indent-to-column (column &optional minimum buffer)
|
||||
"Work around a bug with extents with invisibility in XEmacs."
|
||||
(if (featurep 'xemacs)
|
||||
(org-xemacs-without-invisibility (indent-to-column column minimum buffer))
|
||||
(indent-to-column column minimum)))
|
||||
|
||||
(defun org-indent-line-to (column)
|
||||
"Work around a bug with extents with invisibility in XEmacs."
|
||||
(if (featurep 'xemacs)
|
||||
(org-xemacs-without-invisibility (indent-line-to column))
|
||||
(indent-line-to column)))
|
||||
|
||||
(defun org-move-to-column (column &optional force buffer)
|
||||
"Move to column COLUMN.
|
||||
Pass COLUMN and FORCE to `move-to-column'.
|
||||
Pass BUFFER to the XEmacs version of `move-to-column'."
|
||||
(let ((buffer-invisibility-spec
|
||||
(if (listp buffer-invisibility-spec)
|
||||
(remove '(org-filtered) buffer-invisibility-spec)
|
||||
buffer-invisibility-spec)))
|
||||
(if (featurep 'xemacs)
|
||||
(org-xemacs-without-invisibility
|
||||
(move-to-column column force buffer))
|
||||
(move-to-column column force))))
|
||||
|
||||
(defun org-get-x-clipboard-compat (value)
|
||||
"Get the clipboard value on XEmacs or Emacs 21."
|
||||
(cond ((featurep 'xemacs)
|
||||
(org-no-warnings (get-selection-no-error value)))
|
||||
((fboundp 'x-get-selection)
|
||||
(condition-case nil
|
||||
(or (x-get-selection value 'UTF8_STRING)
|
||||
(x-get-selection value 'COMPOUND_TEXT)
|
||||
(x-get-selection value 'STRING)
|
||||
(x-get-selection value 'TEXT))
|
||||
(error nil)))))
|
||||
|
||||
(defun org-propertize (string &rest properties)
|
||||
(if (featurep 'xemacs)
|
||||
(progn
|
||||
(add-text-properties 0 (length string) properties string)
|
||||
string)
|
||||
(apply 'propertize string properties)))
|
||||
|
||||
(defmacro org-find-library-dir (library)
|
||||
`(file-name-directory (or (locate-library ,library) "")))
|
||||
|
||||
(defun org-count-lines (s)
|
||||
"How many lines in string S?"
|
||||
(let ((start 0) (n 1))
|
||||
(while (string-match "\n" s start)
|
||||
(setq start (match-end 0) n (1+ n)))
|
||||
(if (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
|
||||
(setq n (1- n)))
|
||||
n))
|
||||
|
||||
(defun org-kill-new (string &rest args)
|
||||
(remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t)
|
||||
string)
|
||||
(apply 'kill-new string args))
|
||||
|
||||
(defun org-select-frame-set-input-focus (frame)
|
||||
"Select FRAME, raise it, and set input focus, if possible."
|
||||
(cond ((featurep 'xemacs)
|
||||
(if (fboundp 'select-frame-set-input-focus)
|
||||
(select-frame-set-input-focus frame)
|
||||
(raise-frame frame)
|
||||
(select-frame frame)
|
||||
(focus-frame frame)))
|
||||
;; `select-frame-set-input-focus' defined in Emacs 21 will not
|
||||
;; set the input focus.
|
||||
((>= emacs-major-version 22)
|
||||
(select-frame-set-input-focus frame))
|
||||
(t
|
||||
(raise-frame frame)
|
||||
(select-frame frame)
|
||||
(cond ((memq window-system '(x ns mac))
|
||||
(x-focus-frame frame))
|
||||
((and (eq window-system 'w32)
|
||||
(fboundp 'w32-focus-frame))
|
||||
(w32-focus-frame frame)))
|
||||
(when focus-follows-mouse
|
||||
(set-mouse-position frame (1- (frame-width frame)) 0)))))
|
||||
|
||||
(defalias 'org-float-time
|
||||
(if (featurep 'xemacs) 'time-to-seconds 'float-time))
|
||||
|
||||
;; `user-error' is only available from 24.2.50 on
|
||||
(unless (fboundp 'user-error)
|
||||
(defalias 'user-error 'error))
|
||||
|
||||
;; ‘format-message’ is available only from 25 on
|
||||
(unless (fboundp 'format-message)
|
||||
(defalias 'format-message 'format))
|
||||
|
||||
;; `font-lock-ensure' is only available from 24.4.50 on
|
||||
(defalias 'org-font-lock-ensure
|
||||
(if (fboundp 'font-lock-ensure)
|
||||
#'font-lock-ensure
|
||||
(lambda (&optional _beg _end)
|
||||
(with-no-warnings (font-lock-fontify-buffer)))))
|
||||
|
||||
(defmacro org-no-popups (&rest body)
|
||||
"Suppress popup windows.
|
||||
Let-bind some variables to nil around BODY to achieve the desired
|
||||
effect, which variables to use depends on the Emacs version."
|
||||
(if (org-version-check "24.2.50" "" :predicate)
|
||||
`(let (pop-up-frames display-buffer-alist)
|
||||
,@body)
|
||||
`(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function)
|
||||
,@body)))
|
||||
|
||||
(if (fboundp 'string-match-p)
|
||||
(defalias 'org-string-match-p 'string-match-p)
|
||||
(defun org-string-match-p (regexp string &optional start)
|
||||
(save-match-data
|
||||
(funcall 'string-match regexp string start))))
|
||||
|
||||
(if (fboundp 'looking-at-p)
|
||||
(defalias 'org-looking-at-p 'looking-at-p)
|
||||
(defun org-looking-at-p (&rest args)
|
||||
(save-match-data
|
||||
(apply 'looking-at args))))
|
||||
|
||||
;; XEmacs does not have `looking-back'.
|
||||
(if (fboundp 'looking-back)
|
||||
(defalias 'org-looking-back 'looking-back)
|
||||
(defun org-looking-back (regexp &optional limit greedy)
|
||||
"Return non-nil if text before point matches regular expression REGEXP.
|
||||
Like `looking-at' except matches before point, and is slower.
|
||||
LIMIT if non-nil speeds up the search by specifying a minimum
|
||||
starting position, to avoid checking matches that would start
|
||||
before LIMIT.
|
||||
|
||||
If GREEDY is non-nil, extend the match backwards as far as
|
||||
possible, stopping when a single additional previous character
|
||||
cannot be part of a match for REGEXP. When the match is
|
||||
extended, its starting position is allowed to occur before
|
||||
LIMIT."
|
||||
(let ((start (point))
|
||||
(pos
|
||||
(save-excursion
|
||||
(and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)
|
||||
(point)))))
|
||||
(if (and greedy pos)
|
||||
(save-restriction
|
||||
(narrow-to-region (point-min) start)
|
||||
(while (and (> pos (point-min))
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(backward-char 1)
|
||||
(looking-at (concat "\\(?:" regexp "\\)\\'"))))
|
||||
(setq pos (1- pos)))
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(looking-at (concat "\\(?:" regexp "\\)\\'")))))
|
||||
(not (null pos)))))
|
||||
|
||||
(defun org-floor* (x &optional y)
|
||||
"Return a list of the floor of X and the fractional part of X.
|
||||
With two arguments, return floor and remainder of their quotient."
|
||||
(let ((q (floor x y)))
|
||||
(list q (- x (if y (* y q) q)))))
|
||||
|
||||
;; `pop-to-buffer-same-window' has been introduced in Emacs 24.1.
|
||||
(defun org-pop-to-buffer-same-window
|
||||
(&optional buffer-or-name norecord label)
|
||||
"Pop to buffer specified by BUFFER-OR-NAME in the selected window."
|
||||
(if (fboundp 'pop-to-buffer-same-window)
|
||||
(funcall
|
||||
'pop-to-buffer-same-window buffer-or-name norecord)
|
||||
(funcall 'switch-to-buffer buffer-or-name norecord)))
|
||||
|
||||
;; RECURSIVE has been introduced with Emacs 23.2.
|
||||
;; This is copying and adapted from `tramp-compat-delete-directory'
|
||||
(defun org-delete-directory (directory &optional recursive)
|
||||
"Compatibility function for `delete-directory'."
|
||||
(if (null recursive)
|
||||
(delete-directory directory)
|
||||
(condition-case nil
|
||||
(funcall 'delete-directory directory recursive)
|
||||
;; This Emacs version does not support the RECURSIVE flag. We
|
||||
;; use the implementation from Emacs 23.2.
|
||||
(wrong-number-of-arguments
|
||||
(setq directory (directory-file-name (expand-file-name directory)))
|
||||
(if (not (file-symlink-p directory))
|
||||
(mapc (lambda (file)
|
||||
(if (eq t (car (file-attributes file)))
|
||||
(org-delete-directory file recursive)
|
||||
(delete-file file)))
|
||||
(directory-files
|
||||
directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
|
||||
(delete-directory directory)))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro org-check-version ()
|
||||
"Try very hard to provide sensible version strings."
|
||||
(let* ((org-dir (org-find-library-dir "org"))
|
||||
(org-version.el (concat org-dir "org-version.el"))
|
||||
(org-fixup.el (concat org-dir "../mk/org-fixup.el")))
|
||||
(if (require 'org-version org-version.el 'noerror)
|
||||
'(progn
|
||||
(autoload 'org-release "org-version.el")
|
||||
(autoload 'org-git-version "org-version.el"))
|
||||
(if (require 'org-fixup org-fixup.el 'noerror)
|
||||
'(org-fixup)
|
||||
;; provide fallback definitions and complain
|
||||
(warn "Could not define org version correctly. Check installation!")
|
||||
'(progn
|
||||
(defun org-release () "N/A")
|
||||
(defun org-git-version () "N/A !!check installation!!"))))))
|
||||
|
||||
(defun org-file-equal-p (f1 f2)
|
||||
"Return t if files F1 and F2 are the same.
|
||||
Implements `file-equal-p' for older emacsen and XEmacs."
|
||||
(if (fboundp 'file-equal-p)
|
||||
(file-equal-p f1 f2)
|
||||
(let (f1-attr f2-attr)
|
||||
(and (setq f1-attr (file-attributes (file-truename f1)))
|
||||
(setq f2-attr (file-attributes (file-truename f2)))
|
||||
(equal f1-attr f2-attr)))))
|
||||
|
||||
;; `buffer-narrowed-p' is available for Emacs >=24.3
|
||||
(defun org-buffer-narrowed-p ()
|
||||
"Compatibility function for `buffer-narrowed-p'."
|
||||
(if (fboundp 'buffer-narrowed-p)
|
||||
(buffer-narrowed-p)
|
||||
(/= (- (point-max) (point-min)) (buffer-size))))
|
||||
|
||||
;; As of Emacs 25.1, `outline-mode` functions are under the 'outline-'
|
||||
;; prefix.
|
||||
(when (< emacs-major-version 25)
|
||||
(defalias 'outline-show-all 'show-all)
|
||||
(defalias 'outline-hide-subtree 'hide-subtree)
|
||||
(defalias 'outline-show-subtree 'show-subtree)
|
||||
(defalias 'outline-show-branches 'show-branches)
|
||||
(defalias 'outline-show-children 'show-children)
|
||||
(defalias 'outline-show-entry 'show-entry)
|
||||
(defalias 'outline-hide-entry 'hide-entry)
|
||||
(defalias 'outline-hide-sublevels 'hide-sublevels))
|
||||
|
||||
(defmacro org-with-silent-modifications (&rest body)
|
||||
(if (fboundp 'with-silent-modifications)
|
||||
`(with-silent-modifications ,@body)
|
||||
`(org-unmodified ,@body)))
|
||||
(def-edebug-spec org-with-silent-modifications (body))
|
||||
|
||||
(provide 'org-compat)
|
||||
|
||||
;;; org-compat.el ends here
|
276
elpa/org-20160919/org-crypt.el
Normal file
276
elpa/org-20160919/org-crypt.el
Normal file
@ -0,0 +1,276 @@
|
||||
;;; org-crypt.el --- Public key encryption for org-mode entries
|
||||
|
||||
;; Copyright (C) 2007-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Emacs Lisp Archive Entry
|
||||
;; Filename: org-crypt.el
|
||||
;; Keywords: org-mode
|
||||
;; Author: John Wiegley <johnw@gnu.org>
|
||||
;; Maintainer: Peter Jones <pjones@pmade.com>
|
||||
;; Description: Adds public key encryption to org-mode buffers
|
||||
;; URL: http://www.newartisans.com/software/emacs.html
|
||||
;; Compatibility: Emacs22
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Right now this is just a set of functions to play with. It depends
|
||||
;; on the epg library. Here's how you would use it:
|
||||
;;
|
||||
;; 1. To mark an entry for encryption, tag the heading with "crypt".
|
||||
;; You can change the tag to any complex tag matching string by
|
||||
;; setting the `org-crypt-tag-matcher' variable.
|
||||
;;
|
||||
;; 2. Set the encryption key to use in the `org-crypt-key' variable,
|
||||
;; or use `M-x org-set-property' to set the property CRYPTKEY to
|
||||
;; any address in your public keyring. The text of the entry (but
|
||||
;; not its properties or headline) will be encrypted for this user.
|
||||
;; For them to read it, the corresponding secret key must be
|
||||
;; located in the secret key ring of the account where you try to
|
||||
;; decrypt it. This makes it possible to leave secure notes that
|
||||
;; only the intended recipient can read in a shared-org-mode-files
|
||||
;; scenario.
|
||||
;; If the key is not set, org-crypt will default to symmetric encryption.
|
||||
;;
|
||||
;; 3. To later decrypt an entry, use `org-decrypt-entries' or
|
||||
;; `org-decrypt-entry'. It might be useful to bind this to a key,
|
||||
;; like C-c C-/. I hope that in the future, C-c C-r can be might
|
||||
;; overloaded to also decrypt an entry if it's encrypted, since
|
||||
;; that fits nicely with the meaning of "reveal".
|
||||
;;
|
||||
;; 4. To automatically encrypt all necessary entries when saving a
|
||||
;; file, call `org-crypt-use-before-save-magic' after loading
|
||||
;; org-crypt.el.
|
||||
|
||||
;;; Thanks:
|
||||
|
||||
;; - Carsten Dominik
|
||||
;; - Vitaly Ostanin
|
||||
|
||||
(require 'org)
|
||||
|
||||
;;; Code:
|
||||
|
||||
(declare-function epg-decrypt-string "epg" (context cipher))
|
||||
(declare-function epg-list-keys "epg" (context &optional name mode))
|
||||
(declare-function epg-make-context "epg"
|
||||
(&optional protocol armor textmode include-certs
|
||||
cipher-algorithm digest-algorithm
|
||||
compress-algorithm))
|
||||
(declare-function epg-encrypt-string "epg"
|
||||
(context plain recipients &optional sign always-trust))
|
||||
(defvar epg-context)
|
||||
|
||||
|
||||
(defgroup org-crypt nil
|
||||
"Org Crypt."
|
||||
:tag "Org Crypt"
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-crypt-tag-matcher "crypt"
|
||||
"The tag matcher used to find headings whose contents should be encrypted.
|
||||
|
||||
See the \"Match syntax\" section of the org manual for more details."
|
||||
:type 'string
|
||||
:group 'org-crypt)
|
||||
|
||||
(defcustom org-crypt-key ""
|
||||
"The default key to use when encrypting the contents of a heading.
|
||||
|
||||
This setting can also be overridden in the CRYPTKEY property."
|
||||
:type 'string
|
||||
:group 'org-crypt)
|
||||
|
||||
(defcustom org-crypt-disable-auto-save 'ask
|
||||
"What org-decrypt should do if `auto-save-mode' is enabled.
|
||||
|
||||
t : Disable auto-save-mode for the current buffer
|
||||
prior to decrypting an entry.
|
||||
|
||||
nil : Leave auto-save-mode enabled.
|
||||
This may cause data to be written to disk unencrypted!
|
||||
|
||||
`ask' : Ask user whether or not to disable auto-save-mode
|
||||
for the current buffer.
|
||||
|
||||
`encrypt': Leave auto-save-mode enabled for the current buffer,
|
||||
but automatically re-encrypt all decrypted entries
|
||||
*before* auto-saving.
|
||||
NOTE: This only works for entries which have a tag
|
||||
that matches `org-crypt-tag-matcher'."
|
||||
:group 'org-crypt
|
||||
:version "24.1"
|
||||
:type '(choice (const :tag "Always" t)
|
||||
(const :tag "Never" nil)
|
||||
(const :tag "Ask" ask)
|
||||
(const :tag "Encrypt" encrypt)))
|
||||
|
||||
(defun org-crypt-check-auto-save ()
|
||||
"Check whether auto-save-mode is enabled for the current buffer.
|
||||
|
||||
`auto-save-mode' may cause leakage when decrypting entries, so
|
||||
check whether it's enabled, and decide what to do about it.
|
||||
|
||||
See `org-crypt-disable-auto-save'."
|
||||
(when buffer-auto-save-file-name
|
||||
(cond
|
||||
((or
|
||||
(eq org-crypt-disable-auto-save t)
|
||||
(and
|
||||
(eq org-crypt-disable-auto-save 'ask)
|
||||
(y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? ")))
|
||||
(message "org-decrypt: Disabling auto-save-mode for %s"
|
||||
(or (buffer-file-name) (current-buffer)))
|
||||
;; The argument to auto-save-mode has to be "-1", since
|
||||
;; giving a "nil" argument toggles instead of disabling.
|
||||
(auto-save-mode -1))
|
||||
((eq org-crypt-disable-auto-save nil)
|
||||
(message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))
|
||||
((eq org-crypt-disable-auto-save 'encrypt)
|
||||
(message "org-decrypt: Enabling re-encryption on auto-save.")
|
||||
(org-add-hook 'auto-save-hook
|
||||
(lambda ()
|
||||
(message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
|
||||
(org-encrypt-entries))
|
||||
nil t))
|
||||
(t nil))))
|
||||
|
||||
(defun org-crypt-key-for-heading ()
|
||||
"Return the encryption key for the current heading."
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(or (org-entry-get nil "CRYPTKEY" 'selective)
|
||||
org-crypt-key
|
||||
(and (boundp 'epa-file-encrypt-to) epa-file-encrypt-to)
|
||||
(message "No crypt key set, using symmetric encryption."))))
|
||||
|
||||
(defun org-encrypt-string (str crypt-key)
|
||||
"Return STR encrypted with CRYPT-KEY."
|
||||
;; Text and key have to be identical, otherwise we re-crypt.
|
||||
(if (and (string= crypt-key (get-text-property 0 'org-crypt-key str))
|
||||
(string= (sha1 str) (get-text-property 0 'org-crypt-checksum str)))
|
||||
(get-text-property 0 'org-crypt-text str)
|
||||
(set (make-local-variable 'epg-context) (epg-make-context nil t t))
|
||||
(epg-encrypt-string epg-context str (epg-list-keys epg-context crypt-key))))
|
||||
|
||||
(defun org-encrypt-entry ()
|
||||
"Encrypt the content of the current headline."
|
||||
(interactive)
|
||||
(require 'epg)
|
||||
(org-with-wide-buffer
|
||||
(org-back-to-heading t)
|
||||
(set (make-local-variable 'epg-context) (epg-make-context nil t t))
|
||||
(let ((start-heading (point)))
|
||||
(org-end-of-meta-data)
|
||||
(unless (looking-at "-----BEGIN PGP MESSAGE-----")
|
||||
(let ((folded (outline-invisible-p))
|
||||
(crypt-key (org-crypt-key-for-heading))
|
||||
(beg (point))
|
||||
end encrypted-text)
|
||||
(goto-char start-heading)
|
||||
(org-end-of-subtree t t)
|
||||
(org-back-over-empty-lines)
|
||||
(setq end (point)
|
||||
encrypted-text
|
||||
(org-encrypt-string (buffer-substring beg end) crypt-key))
|
||||
(delete-region beg end)
|
||||
(insert encrypted-text)
|
||||
(when folded
|
||||
(goto-char start-heading)
|
||||
(outline-hide-subtree))
|
||||
nil)))))
|
||||
|
||||
(defun org-decrypt-entry ()
|
||||
"Decrypt the content of the current headline."
|
||||
(interactive)
|
||||
(require 'epg)
|
||||
(unless (org-before-first-heading-p)
|
||||
(org-with-wide-buffer
|
||||
(org-back-to-heading t)
|
||||
(let ((heading-point (point))
|
||||
(heading-was-invisible-p
|
||||
(save-excursion
|
||||
(outline-end-of-heading)
|
||||
(outline-invisible-p))))
|
||||
(org-end-of-meta-data)
|
||||
(when (looking-at "-----BEGIN PGP MESSAGE-----")
|
||||
(org-crypt-check-auto-save)
|
||||
(set (make-local-variable 'epg-context) (epg-make-context nil t t))
|
||||
(let* ((end (save-excursion
|
||||
(search-forward "-----END PGP MESSAGE-----")
|
||||
(forward-line)
|
||||
(point)))
|
||||
(encrypted-text (buffer-substring-no-properties (point) end))
|
||||
(decrypted-text
|
||||
(decode-coding-string
|
||||
(epg-decrypt-string
|
||||
epg-context
|
||||
encrypted-text)
|
||||
'utf-8)))
|
||||
;; Delete region starting just before point, because the
|
||||
;; outline property starts at the \n of the heading.
|
||||
(delete-region (1- (point)) end)
|
||||
;; Store a checksum of the decrypted and the encrypted
|
||||
;; text value. This allows reusing the same encrypted text
|
||||
;; if the text does not change, and therefore avoid a
|
||||
;; re-encryption process.
|
||||
(insert "\n" (propertize decrypted-text
|
||||
'org-crypt-checksum (sha1 decrypted-text)
|
||||
'org-crypt-key (org-crypt-key-for-heading)
|
||||
'org-crypt-text encrypted-text))
|
||||
(when heading-was-invisible-p
|
||||
(goto-char heading-point)
|
||||
(org-flag-subtree t))
|
||||
nil))))))
|
||||
|
||||
(defun org-encrypt-entries ()
|
||||
"Encrypt all top-level entries in the current buffer."
|
||||
(interactive)
|
||||
(let (todo-only)
|
||||
(org-scan-tags
|
||||
'org-encrypt-entry
|
||||
(cdr (org-make-tags-matcher org-crypt-tag-matcher))
|
||||
todo-only)))
|
||||
|
||||
(defun org-decrypt-entries ()
|
||||
"Decrypt all entries in the current buffer."
|
||||
(interactive)
|
||||
(let (todo-only)
|
||||
(org-scan-tags
|
||||
'org-decrypt-entry
|
||||
(cdr (org-make-tags-matcher org-crypt-tag-matcher))
|
||||
todo-only)))
|
||||
|
||||
(defun org-at-encrypted-entry-p ()
|
||||
"Is the current entry encrypted?"
|
||||
(unless (org-before-first-heading-p)
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(search-forward "-----BEGIN PGP MESSAGE-----"
|
||||
(save-excursion (outline-next-heading)) t))))
|
||||
|
||||
(defun org-crypt-use-before-save-magic ()
|
||||
"Add a hook to automatically encrypt entries before a file is saved to disk."
|
||||
(add-hook
|
||||
'org-mode-hook
|
||||
(lambda () (org-add-hook 'before-save-hook 'org-encrypt-entries nil t))))
|
||||
|
||||
(add-hook 'org-reveal-start-hook 'org-decrypt-entry)
|
||||
|
||||
(provide 'org-crypt)
|
||||
|
||||
;;; org-crypt.el ends here
|
542
elpa/org-20160919/org-ctags.el
Normal file
542
elpa/org-20160919/org-ctags.el
Normal file
@ -0,0 +1,542 @@
|
||||
;;; org-ctags.el - Integrate Emacs "tags" facility with org mode.
|
||||
;;
|
||||
;; Copyright (C) 2007-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Paul Sexton <eeeickythump@gmail.com>
|
||||
|
||||
|
||||
;; Keywords: org, wp
|
||||
;;
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;
|
||||
;; Synopsis
|
||||
;; ========
|
||||
;;
|
||||
;; Allows org-mode to make use of the Emacs `etags' system. Defines tag
|
||||
;; destinations in org-mode files as any text between <<double angled
|
||||
;; brackets>>. This allows the tags-generation program `exuberant ctags' to
|
||||
;; parse these files and create tag tables that record where these
|
||||
;; destinations are found. Plain [[links]] in org mode files which do not have
|
||||
;; <<matching destinations>> within the same file will then be interpreted as
|
||||
;; links to these 'tagged' destinations, allowing seamless navigation between
|
||||
;; multiple org-mode files. Topics can be created in any org mode file and
|
||||
;; will always be found by plain links from other files. Other file types
|
||||
;; recognized by ctags (source code files, latex files, etc) will also be
|
||||
;; available as destinations for plain links, and similarly, org-mode links
|
||||
;; will be available as tags from source files. Finally, the function
|
||||
;; `org-ctags-find-tag-interactive' lets you choose any known tag, using
|
||||
;; autocompletion, and quickly jump to it.
|
||||
;;
|
||||
;; Installation
|
||||
;; ============
|
||||
;;
|
||||
;; Install org mode
|
||||
;; Ensure org-ctags.el is somewhere in your emacs load path.
|
||||
;; Download and install Exuberant ctags -- "http://ctags.sourceforge.net/"
|
||||
;; Edit your .emacs file (see next section) and load emacs.
|
||||
|
||||
;; To put in your init file (.emacs):
|
||||
;; ==================================
|
||||
;;
|
||||
;; Assuming you already have org mode installed and set up:
|
||||
;;
|
||||
;; (setq org-ctags-path-to-ctags "/path/to/ctags/executable")
|
||||
;; (add-hook 'org-mode-hook
|
||||
;; (lambda ()
|
||||
;; (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive)))
|
||||
;;
|
||||
;; By default, with org-ctags loaded, org will first try and visit the tag
|
||||
;; with the same name as the link; then, if unsuccessful, ask the user if
|
||||
;; he/she wants to rebuild the 'TAGS' database and try again; then ask if
|
||||
;; the user wishes to append 'tag' as a new toplevel heading at the end of
|
||||
;; the buffer; and finally, defer to org's default behavior which is to
|
||||
;; search the entire text of the current buffer for 'tag'.
|
||||
;;
|
||||
;; This behavior can be modified by changing the value of
|
||||
;; ORG-CTAGS-OPEN-LINK-FUNCTIONS. For example I have the following in my
|
||||
;; .emacs, which describes the same behavior as the above paragraph with
|
||||
;; one difference:
|
||||
;;
|
||||
;; (setq org-ctags-open-link-functions
|
||||
;; '(org-ctags-find-tag
|
||||
;; org-ctags-ask-rebuild-tags-file-then-find-tag
|
||||
;; org-ctags-ask-append-topic
|
||||
;; org-ctags-fail-silently)) ; <-- prevents org default behavior
|
||||
;;
|
||||
;;
|
||||
;; Usage
|
||||
;; =====
|
||||
;;
|
||||
;; When you click on a link "[[foo]]" and org cannot find a matching "<<foo>>"
|
||||
;; in the current buffer, the tags facility will take over. The file TAGS in
|
||||
;; the active directory is examined to see if the tags facility knows about
|
||||
;; "<<foo>>" in any other files. If it does, the matching file will be opened
|
||||
;; and the cursor will jump to the position of "<<foo>>" in that file.
|
||||
;;
|
||||
;; User-visible functions:
|
||||
;; - `org-ctags-find-tag-interactive': type a tag (plain link) name and visit
|
||||
;; it. With autocompletion. Bound to ctrl-O in the above setup.
|
||||
;; - All the etags functions should work. These include:
|
||||
;;
|
||||
;; M-. `find-tag' -- finds the tag at point
|
||||
;;
|
||||
;; C-M-. find-tag based on regular expression
|
||||
;;
|
||||
;; M-x tags-search RET -- like C-M-. but searches through ENTIRE TEXT
|
||||
;; of ALL the files referenced in the TAGS file. A quick way to
|
||||
;; search through an entire 'project'.
|
||||
;;
|
||||
;; M-* "go back" from a tag jump. Like `org-mark-ring-goto'.
|
||||
;; You may need to bind this key yourself with (eg)
|
||||
;; (global-set-key (kbd "<M-kp-multiply>") 'pop-tag-mark)
|
||||
;;
|
||||
;; (see etags chapter in Emacs manual for more)
|
||||
;;
|
||||
;;
|
||||
;; Keeping the TAGS file up to date
|
||||
;; ================================
|
||||
;;
|
||||
;; Tags mode has no way of knowing that you have created new tags by typing in
|
||||
;; your org-mode buffer. New tags make it into the TAGS file in 3 ways:
|
||||
;;
|
||||
;; 1. You re-run (org-ctags-create-tags "directory") to rebuild the file.
|
||||
;; 2. You put the function `org-ctags-ask-rebuild-tags-file-then-find-tag' in
|
||||
;; your `org-open-link-functions' list, as is done in the setup
|
||||
;; above. This will cause the TAGS file to be rebuilt whenever a link
|
||||
;; cannot be found. This may be slow with large file collections however.
|
||||
;; 3. You run the following from the command line (all 1 line):
|
||||
;;
|
||||
;; ctags --langdef=orgmode --langmap=orgmode:.org
|
||||
;; --regex-orgmode="/<<([^>]+)>>/\1/d,definition/"
|
||||
;; -f /your/path/TAGS -e -R /your/path/*.org
|
||||
;;
|
||||
;; If you are paranoid, you might want to run (org-ctags-create-tags
|
||||
;; "/path/to/org/files") at startup, by including the following toplevel form
|
||||
;; in .emacs. However this can cause a pause of several seconds if ctags has
|
||||
;; to scan lots of files.
|
||||
;;
|
||||
;; (progn
|
||||
;; (message "-- rebuilding tags tables...")
|
||||
;; (mapc 'org-ctags-create-tags tags-table-list))
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(require 'org)
|
||||
|
||||
(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
|
||||
|
||||
(defgroup org-ctags nil
|
||||
"Options concerning use of ctags within org mode."
|
||||
:tag "Org-Ctags"
|
||||
:group 'org-link)
|
||||
|
||||
(defvar org-ctags-enabled-p t
|
||||
"Activate ctags support in org mode?")
|
||||
|
||||
(defvar org-ctags-tag-regexp "/<<([^>]+)>>/\\1/d,definition/"
|
||||
"Regexp expression used by ctags external program.
|
||||
The regexp matches tag destinations in org-mode files.
|
||||
Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/
|
||||
See the ctags documentation for more information.")
|
||||
|
||||
(defcustom org-ctags-path-to-ctags
|
||||
(if (executable-find "ctags-exuberant") "ctags-exuberant" "ctags")
|
||||
"Name of the ctags executable file."
|
||||
:group 'org-ctags
|
||||
:version "24.1"
|
||||
:type 'file)
|
||||
|
||||
(defcustom org-ctags-open-link-functions
|
||||
'(org-ctags-find-tag
|
||||
org-ctags-ask-rebuild-tags-file-then-find-tag
|
||||
org-ctags-ask-append-topic)
|
||||
"List of functions to be prepended to ORG-OPEN-LINK-FUNCTIONS when ORG-CTAGS is active."
|
||||
:group 'org-ctags
|
||||
:version "24.1"
|
||||
:type 'hook
|
||||
:options '(org-ctags-find-tag
|
||||
org-ctags-ask-rebuild-tags-file-then-find-tag
|
||||
org-ctags-rebuild-tags-file-then-find-tag
|
||||
org-ctags-ask-append-topic
|
||||
org-ctags-append-topic
|
||||
org-ctags-ask-visit-buffer-or-file
|
||||
org-ctags-visit-buffer-or-file
|
||||
org-ctags-fail-silently))
|
||||
|
||||
|
||||
(defvar org-ctags-tag-list nil
|
||||
"List of all tags in the active TAGS file.
|
||||
Created as a local variable in each buffer.")
|
||||
|
||||
(defcustom org-ctags-new-topic-template
|
||||
"* <<%t>>\n\n\n\n\n\n"
|
||||
"Text to insert when creating a new org file via opening a hyperlink.
|
||||
The following patterns are replaced in the string:
|
||||
`%t' - replaced with the capitalized title of the hyperlink"
|
||||
:group 'org-ctags
|
||||
:version "24.1"
|
||||
:type 'string)
|
||||
|
||||
|
||||
(add-hook 'org-mode-hook
|
||||
(lambda ()
|
||||
(when (and org-ctags-enabled-p
|
||||
(buffer-file-name))
|
||||
;; Make sure this file's directory is added to default
|
||||
;; directories in which to search for tags.
|
||||
(let ((tags-filename
|
||||
(expand-file-name
|
||||
(concat (file-name-directory (buffer-file-name))
|
||||
"/TAGS"))))
|
||||
(when (file-exists-p tags-filename)
|
||||
(visit-tags-table tags-filename))))))
|
||||
|
||||
|
||||
(defadvice visit-tags-table (after org-ctags-load-tag-list activate compile)
|
||||
(when (and org-ctags-enabled-p tags-file-name)
|
||||
(set (make-local-variable 'org-ctags-tag-list)
|
||||
(org-ctags-all-tags-in-current-tags-table))))
|
||||
|
||||
|
||||
(defun org-ctags-enable ()
|
||||
(put 'org-mode 'find-tag-default-function 'org-ctags-find-tag-at-point)
|
||||
(setq org-ctags-enabled-p t)
|
||||
(dolist (fn org-ctags-open-link-functions)
|
||||
(add-hook 'org-open-link-functions fn t)))
|
||||
|
||||
|
||||
;;; General utility functions. ===============================================
|
||||
;; These work outside org-ctags mode.
|
||||
|
||||
(defun org-ctags-get-filename-for-tag (tag)
|
||||
"TAG is a string. Search the active TAGS file for a matching tag.
|
||||
If the tag is found, return a list containing the filename, line number, and
|
||||
buffer position where the tag is found."
|
||||
(interactive "sTag: ")
|
||||
(unless tags-file-name
|
||||
(call-interactively (visit-tags-table)))
|
||||
(save-excursion
|
||||
(visit-tags-table-buffer 'same)
|
||||
(when tags-file-name
|
||||
(with-current-buffer (get-file-buffer tags-file-name)
|
||||
(goto-char (point-min))
|
||||
(cond
|
||||
((re-search-forward (format "^.*%s\\([0-9]+\\),\\([0-9]+\\)$"
|
||||
(regexp-quote tag)) nil t)
|
||||
(let ((line (string-to-number (match-string 1)))
|
||||
(pos (string-to-number (match-string 2))))
|
||||
(cond
|
||||
((re-search-backward "\n\\(.*\\),[0-9]+\n")
|
||||
(list (match-string 1) line pos))
|
||||
(t ; can't find a file name preceding the matched
|
||||
; tag??
|
||||
(error "Malformed TAGS file: %s" (buffer-name))))))
|
||||
(t ; tag not found
|
||||
nil))))))
|
||||
|
||||
|
||||
(defun org-ctags-all-tags-in-current-tags-table ()
|
||||
"Read all tags defined in the active TAGS file, into a list of strings.
|
||||
Return the list."
|
||||
(interactive)
|
||||
(let ((taglist nil))
|
||||
(unless tags-file-name
|
||||
(call-interactively (visit-tags-table)))
|
||||
(save-excursion
|
||||
(visit-tags-table-buffer 'same)
|
||||
(with-current-buffer (get-file-buffer tags-file-name)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^.*\\(.*\\)\\([0-9]+\\),\\([0-9]+\\)$"
|
||||
nil t)
|
||||
(push (substring-no-properties (match-string 1)) taglist)))
|
||||
taglist)))
|
||||
|
||||
|
||||
(defun org-ctags-string-search-and-replace (search replace string)
|
||||
"Replace all instances of SEARCH with REPLACE in STRING."
|
||||
(replace-regexp-in-string (regexp-quote search) replace string t t))
|
||||
|
||||
|
||||
(defun y-or-n-minibuffer (prompt)
|
||||
(let ((use-dialog-box nil))
|
||||
(y-or-n-p prompt)))
|
||||
|
||||
|
||||
;;; Internal functions =======================================================
|
||||
|
||||
|
||||
(defun org-ctags-open-file (name &optional title)
|
||||
"Visit or create a file called `NAME.org', and insert a new topic.
|
||||
The new topic will be titled NAME (or TITLE if supplied)."
|
||||
(interactive "sFile name: ")
|
||||
(let ((filename (substitute-in-file-name (expand-file-name name))))
|
||||
(condition-case v
|
||||
(progn
|
||||
(org-open-file name t)
|
||||
(message "Opened file OK")
|
||||
(goto-char (point-max))
|
||||
(insert (org-ctags-string-search-and-replace
|
||||
"%t" (capitalize (or title name))
|
||||
org-ctags-new-topic-template))
|
||||
(message "Inserted new file text OK")
|
||||
(org-mode-restart))
|
||||
(error (error "Error %S in org-ctags-open-file" v)))))
|
||||
|
||||
|
||||
;;;; Misc interoperability with etags system =================================
|
||||
|
||||
|
||||
(defadvice find-tag (before org-ctags-set-org-mark-before-finding-tag
|
||||
activate compile)
|
||||
"Before trying to find a tag, save our current position on org mark ring."
|
||||
(save-excursion
|
||||
(if (and (derived-mode-p 'org-mode) org-ctags-enabled-p)
|
||||
(org-mark-ring-push))))
|
||||
|
||||
|
||||
|
||||
(defun org-ctags-find-tag-at-point ()
|
||||
"Determine default tag to search for, based on text at point.
|
||||
If there is no plausible default, return nil."
|
||||
(let (from to bound)
|
||||
(when (or (ignore-errors
|
||||
;; Look for hyperlink around `point'.
|
||||
(save-excursion
|
||||
(search-backward "[[") (setq from (+ 2 (point))))
|
||||
(save-excursion
|
||||
(goto-char from)
|
||||
(search-forward "]") (setq to (- (point) 1)))
|
||||
(and (> to from) (>= (point) from) (<= (point) to)))
|
||||
(progn
|
||||
;; Look at text around `point'.
|
||||
(save-excursion
|
||||
(skip-syntax-backward "w_") (setq from (point)))
|
||||
(save-excursion
|
||||
(skip-syntax-forward "w_") (setq to (point)))
|
||||
(> to from))
|
||||
;; Look between `line-beginning-position' and `point'.
|
||||
(save-excursion
|
||||
(and (setq bound (line-beginning-position))
|
||||
(skip-syntax-backward "^w_" bound)
|
||||
(> (setq to (point)) bound)
|
||||
(skip-syntax-backward "w_")
|
||||
(setq from (point))))
|
||||
;; Look between `point' and `line-end-position'.
|
||||
(save-excursion
|
||||
(and (setq bound (line-end-position))
|
||||
(skip-syntax-forward "^w_" bound)
|
||||
(< (setq from (point)) bound)
|
||||
(skip-syntax-forward "w_")
|
||||
(setq to (point)))))
|
||||
(buffer-substring-no-properties from to))))
|
||||
|
||||
|
||||
;;; Functions for use with 'org-open-link-functions' hook =================
|
||||
|
||||
|
||||
(defun org-ctags-find-tag (name)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Look for a tag called `NAME' in the current TAGS table. If it is found,
|
||||
visit the file and location where the tag is found."
|
||||
(interactive "sTag: ")
|
||||
(let ((old-buf (current-buffer))
|
||||
(old-pnt (point-marker))
|
||||
(old-mark (copy-marker (mark-marker))))
|
||||
(condition-case nil
|
||||
(progn (find-tag name)
|
||||
t)
|
||||
(error
|
||||
;; only restore old location if find-tag raises error
|
||||
(set-buffer old-buf)
|
||||
(goto-char old-pnt)
|
||||
(set-marker (mark-marker) old-mark)
|
||||
nil))))
|
||||
|
||||
|
||||
(defun org-ctags-visit-buffer-or-file (name &optional create)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Visit buffer named `NAME.org'. If there is no such buffer, visit the file
|
||||
with the same name if it exists. If the file does not exist, then behavior
|
||||
depends on the value of CREATE.
|
||||
|
||||
If CREATE is nil (default), then return nil. Do not create a new file.
|
||||
If CREATE is t, create the new file and visit it.
|
||||
If CREATE is the symbol `ask', then ask the user if they wish to create
|
||||
the new file."
|
||||
(interactive)
|
||||
(let ((filename (concat (substitute-in-file-name
|
||||
(expand-file-name name))
|
||||
".org")))
|
||||
(cond
|
||||
((get-buffer (concat name ".org"))
|
||||
;; Buffer is already open
|
||||
(org-pop-to-buffer-same-window (get-buffer (concat name ".org"))))
|
||||
((file-exists-p filename)
|
||||
;; File exists but is not open --> open it
|
||||
(message "Opening existing org file `%S'..."
|
||||
filename)
|
||||
(org-open-file filename t))
|
||||
((or (eql create t)
|
||||
(and (eql create 'ask)
|
||||
(y-or-n-p (format-message
|
||||
"File `%s.org' not found; create?" name))))
|
||||
(org-ctags-open-file filename name))
|
||||
(t ;; File does not exist, and we don't want to create it.
|
||||
nil))))
|
||||
|
||||
|
||||
(defun org-ctags-ask-visit-buffer-or-file (name)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Wrapper for org-ctags-visit-buffer-or-file, which ensures the user is
|
||||
asked before creating a new file."
|
||||
(org-ctags-visit-buffer-or-file name 'ask))
|
||||
|
||||
|
||||
(defun org-ctags-append-topic (name &optional narrowp)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Append a new toplevel heading to the end of the current buffer. The
|
||||
heading contains NAME surrounded by <<angular brackets>>, thus making
|
||||
the heading a destination for the tag `NAME'."
|
||||
(interactive "sTopic: ")
|
||||
(widen)
|
||||
(goto-char (point-max))
|
||||
(newline 2)
|
||||
(message "Adding topic in buffer %s" (buffer-name))
|
||||
(insert (org-ctags-string-search-and-replace
|
||||
"%t" (capitalize name) org-ctags-new-topic-template))
|
||||
(backward-char 4)
|
||||
(org-update-radio-target-regexp)
|
||||
(end-of-line)
|
||||
(forward-line 2)
|
||||
(when narrowp
|
||||
;;(org-tree-to-indirect-buffer 1) ;; opens new frame
|
||||
(org-narrow-to-subtree))
|
||||
t)
|
||||
|
||||
|
||||
(defun org-ctags-ask-append-topic (name &optional narrowp)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Wrapper for org-ctags-append-topic, which first asks the user if they want
|
||||
to append a new topic."
|
||||
(if (y-or-n-p (format-message
|
||||
"Topic `%s' not found; append to end of buffer?" name))
|
||||
(org-ctags-append-topic name narrowp)
|
||||
nil))
|
||||
|
||||
|
||||
(defun org-ctags-rebuild-tags-file-then-find-tag (name)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Like ORG-CTAGS-FIND-TAG, but calls the external ctags program first,
|
||||
to rebuild (update) the TAGS file."
|
||||
(unless tags-file-name
|
||||
(call-interactively (visit-tags-table)))
|
||||
(when (buffer-file-name)
|
||||
(org-ctags-create-tags))
|
||||
(org-ctags-find-tag name))
|
||||
|
||||
|
||||
(defun org-ctags-ask-rebuild-tags-file-then-find-tag (name)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Wrapper for org-ctags-rebuild-tags-file-then-find-tag."
|
||||
(if (and (buffer-file-name)
|
||||
(y-or-n-p
|
||||
(format-message
|
||||
"Tag `%s' not found. Rebuild table `%s/TAGS' and look again?"
|
||||
name
|
||||
(file-name-directory (buffer-file-name)))))
|
||||
(org-ctags-rebuild-tags-file-then-find-tag name)
|
||||
nil))
|
||||
|
||||
|
||||
(defun org-ctags-fail-silently (name)
|
||||
"This function is intended to be used in ORG-OPEN-LINK-FUNCTIONS.
|
||||
Put as the last function in the list if you want to prevent org's default
|
||||
behavior of free text search."
|
||||
t)
|
||||
|
||||
|
||||
;;; User-visible functions ===================================================
|
||||
|
||||
|
||||
(defun org-ctags-create-tags (&optional directory-name)
|
||||
"(Re)create tags file in the directory of the active buffer.
|
||||
The file will contain tag definitions for all the files in the
|
||||
directory and its subdirectories which are recognized by ctags.
|
||||
This will include files ending in `.org' as well as most other
|
||||
source files (.C, .H, .EL, .LISP, etc). All the resulting tags
|
||||
end up in one file, called TAGS, located in the directory. This
|
||||
function may take several seconds to finish if the directory or
|
||||
its subdirectories contain large numbers of taggable files."
|
||||
(interactive)
|
||||
(assert (buffer-file-name))
|
||||
(let ((dir-name (or directory-name
|
||||
(file-name-directory (buffer-file-name))))
|
||||
(exitcode nil))
|
||||
(save-excursion
|
||||
(setq exitcode
|
||||
(shell-command
|
||||
(format (concat "%s --langdef=orgmode --langmap=orgmode:.org "
|
||||
"--regex-orgmode=\"%s\" -f \"%s\" -e -R \"%s\"")
|
||||
org-ctags-path-to-ctags
|
||||
org-ctags-tag-regexp
|
||||
(expand-file-name (concat dir-name "/TAGS"))
|
||||
(expand-file-name (concat dir-name "/*")))))
|
||||
(cond
|
||||
((eql 0 exitcode)
|
||||
(set (make-local-variable 'org-ctags-tag-list)
|
||||
(org-ctags-all-tags-in-current-tags-table)))
|
||||
(t
|
||||
;; This seems to behave differently on Linux, so just ignore
|
||||
;; error codes for now
|
||||
;;(error "Calling ctags executable resulted in error code: %s"
|
||||
;; exitcode)
|
||||
nil)))))
|
||||
|
||||
|
||||
(defvar org-ctags-find-tag-history nil
|
||||
"History of tags visited by org-ctags-find-tag-interactive.")
|
||||
|
||||
(defun org-ctags-find-tag-interactive ()
|
||||
"Prompt for the name of a tag, with autocompletion, then visit the named tag.
|
||||
Uses `ido-mode' if available.
|
||||
If the user enters a string that does not match an existing tag, create
|
||||
a new topic."
|
||||
(interactive)
|
||||
(let* ((completing-read-fn (if (fboundp 'ido-completing-read)
|
||||
'ido-completing-read
|
||||
'completing-read))
|
||||
(tag (funcall completing-read-fn "Topic: " org-ctags-tag-list
|
||||
nil 'confirm nil 'org-ctags-find-tag-history)))
|
||||
(when tag
|
||||
(cond
|
||||
((member tag org-ctags-tag-list)
|
||||
;; Existing tag
|
||||
(push tag org-ctags-find-tag-history)
|
||||
(find-tag tag))
|
||||
(t
|
||||
;; New tag
|
||||
(run-hook-with-args-until-success
|
||||
'org-open-link-functions tag))))))
|
||||
|
||||
|
||||
(org-ctags-enable)
|
||||
|
||||
(provide 'org-ctags)
|
||||
|
||||
;;; org-ctags.el ends here
|
219
elpa/org-20160919/org-datetree.el
Normal file
219
elpa/org-20160919/org-datetree.el
Normal file
@ -0,0 +1,219 @@
|
||||
;;; org-datetree.el --- Create date entries in a tree
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains code to create entries in a tree where the top-level
|
||||
;; nodes represent years, the level 2 nodes represent the months, and the
|
||||
;; level 1 entries days.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defvar org-datetree-base-level 1
|
||||
"The level at which years should be placed in the date tree.
|
||||
This is normally one, but if the buffer has an entry with a DATE_TREE
|
||||
property (any value), the date tree will become a subtree under that entry,
|
||||
so the base level will be properly adjusted.")
|
||||
|
||||
(defcustom org-datetree-add-timestamp nil
|
||||
"When non-nil, add a time stamp matching date of entry.
|
||||
Added time stamp is active unless value is `inactive'."
|
||||
:group 'org-capture
|
||||
:version "24.3"
|
||||
:type '(choice
|
||||
(const :tag "Do not add a time stamp" nil)
|
||||
(const :tag "Add an inactive time stamp" inactive)
|
||||
(const :tag "Add an active time stamp" active)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-datetree-find-date-create (date &optional keep-restriction)
|
||||
"Find or create an entry for DATE.
|
||||
If KEEP-RESTRICTION is non-nil, do not widen the buffer.
|
||||
When it is nil, the buffer will be widened to make sure an existing date
|
||||
tree can be found."
|
||||
(org-set-local 'org-datetree-base-level 1)
|
||||
(or keep-restriction (widen))
|
||||
(save-restriction
|
||||
(let ((prop (org-find-property "DATE_TREE")))
|
||||
(when prop
|
||||
(goto-char prop)
|
||||
(org-set-local 'org-datetree-base-level
|
||||
(org-get-valid-level (org-current-level) 1))
|
||||
(org-narrow-to-subtree)))
|
||||
(goto-char (point-min))
|
||||
(let ((year (nth 2 date))
|
||||
(month (car date))
|
||||
(day (nth 1 date)))
|
||||
(org-datetree-find-year-create year)
|
||||
(org-datetree-find-month-create year month)
|
||||
(org-datetree-find-day-create year month day))))
|
||||
|
||||
(defun org-datetree-find-year-create (year)
|
||||
"Find the YEAR datetree or create it."
|
||||
(let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)")
|
||||
match)
|
||||
(goto-char (point-min))
|
||||
(while (and (setq match (re-search-forward re nil t))
|
||||
(goto-char (match-beginning 1))
|
||||
(< (string-to-number (match-string 1)) year)))
|
||||
(cond
|
||||
((not match)
|
||||
(goto-char (point-max))
|
||||
(or (bolp) (newline))
|
||||
(org-datetree-insert-line year))
|
||||
((= (string-to-number (match-string 1)) year)
|
||||
(goto-char (point-at-bol)))
|
||||
(t
|
||||
(beginning-of-line 1)
|
||||
(org-datetree-insert-line year)))))
|
||||
|
||||
(defun org-datetree-find-month-create (year month)
|
||||
"Find the datetree for YEAR and MONTH or create it."
|
||||
(org-narrow-to-subtree)
|
||||
(let ((re (format "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$" year))
|
||||
match)
|
||||
(goto-char (point-min))
|
||||
(while (and (setq match (re-search-forward re nil t))
|
||||
(goto-char (match-beginning 1))
|
||||
(< (string-to-number (match-string 1)) month)))
|
||||
(cond
|
||||
((not match)
|
||||
(goto-char (point-max))
|
||||
(or (bolp) (newline))
|
||||
(org-datetree-insert-line year month))
|
||||
((= (string-to-number (match-string 1)) month)
|
||||
(goto-char (point-at-bol)))
|
||||
(t
|
||||
(beginning-of-line 1)
|
||||
(org-datetree-insert-line year month)))))
|
||||
|
||||
(defun org-datetree-find-day-create (year month day)
|
||||
"Find the datetree for YEAR, MONTH and DAY or create it."
|
||||
(org-narrow-to-subtree)
|
||||
(let ((re (format "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" year month))
|
||||
match)
|
||||
(goto-char (point-min))
|
||||
(while (and (setq match (re-search-forward re nil t))
|
||||
(goto-char (match-beginning 1))
|
||||
(< (string-to-number (match-string 1)) day)))
|
||||
(cond
|
||||
((not match)
|
||||
(goto-char (point-max))
|
||||
(or (bolp) (newline))
|
||||
(org-datetree-insert-line year month day))
|
||||
((= (string-to-number (match-string 1)) day)
|
||||
(goto-char (point-at-bol)))
|
||||
(t
|
||||
(beginning-of-line 1)
|
||||
(org-datetree-insert-line year month day)))))
|
||||
|
||||
(defun org-datetree-insert-line (year &optional month day)
|
||||
(delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point))
|
||||
(insert "\n" (make-string org-datetree-base-level ?*) " \n")
|
||||
(backward-char)
|
||||
(when month (org-do-demote))
|
||||
(when day (org-do-demote))
|
||||
(insert (format "%d" year))
|
||||
(when month
|
||||
(insert
|
||||
(format "-%02d" month)
|
||||
(if day
|
||||
(format "-%02d %s"
|
||||
day
|
||||
(format-time-string "%A" (encode-time 0 0 0 day month year)))
|
||||
(format " %s"
|
||||
(format-time-string "%B" (encode-time 0 0 0 1 month year))))))
|
||||
(when (and day org-datetree-add-timestamp)
|
||||
(save-excursion
|
||||
(insert "\n")
|
||||
(org-indent-line)
|
||||
(org-insert-time-stamp
|
||||
(encode-time 0 0 0 day month year)
|
||||
nil
|
||||
(eq org-datetree-add-timestamp 'inactive))))
|
||||
(beginning-of-line))
|
||||
|
||||
(defun org-datetree-file-entry-under (txt date)
|
||||
"Insert a node TXT into the date tree under DATE."
|
||||
(org-datetree-find-date-create date)
|
||||
(let ((level (org-get-valid-level (funcall outline-level) 1)))
|
||||
(org-end-of-subtree t t)
|
||||
(org-back-over-empty-lines)
|
||||
(org-paste-subtree level txt)))
|
||||
|
||||
(defun org-datetree-cleanup ()
|
||||
"Make sure all entries in the current tree are under the correct date.
|
||||
It may be useful to restrict the buffer to the applicable portion
|
||||
before running this command, even though the command tries to be smart."
|
||||
(interactive)
|
||||
(goto-char (point-min))
|
||||
(let ((dre (concat "\\<" org-deadline-string "\\>[ \t]*\\'"))
|
||||
(sre (concat "\\<" org-scheduled-string "\\>[ \t]*\\'"))
|
||||
dct ts tmp date year month day pos hdl-pos)
|
||||
(while (re-search-forward org-ts-regexp nil t)
|
||||
(catch 'next
|
||||
(setq ts (match-string 0))
|
||||
(setq tmp (buffer-substring
|
||||
(max (point-at-bol) (- (match-beginning 0)
|
||||
org-ds-keyword-length))
|
||||
(match-beginning 0)))
|
||||
(if (or (string-match "-\\'" tmp)
|
||||
(string-match dre tmp)
|
||||
(string-match sre tmp))
|
||||
(throw 'next nil))
|
||||
(setq dct (decode-time (org-time-string-to-time (match-string 0)))
|
||||
date (list (nth 4 dct) (nth 3 dct) (nth 5 dct))
|
||||
year (nth 2 date)
|
||||
month (car date)
|
||||
day (nth 1 date)
|
||||
pos (point))
|
||||
(org-back-to-heading t)
|
||||
(setq hdl-pos (point))
|
||||
(unless (org-up-heading-safe)
|
||||
;; No parent, we are not in a date tree
|
||||
(goto-char pos)
|
||||
(throw 'next nil))
|
||||
(unless (looking-at "\\*+[ \t]+[0-9]+-[0-1][0-9]-[0-3][0-9]")
|
||||
;; Parent looks wrong, we are not in a date tree
|
||||
(goto-char pos)
|
||||
(throw 'next nil))
|
||||
(when (looking-at (format "\\*+[ \t]+%d-%02d-%02d" year month day))
|
||||
;; At correct date already, do nothing
|
||||
(progn (goto-char pos) (throw 'next nil)))
|
||||
;; OK, we need to refile this entry
|
||||
(goto-char hdl-pos)
|
||||
(org-cut-subtree)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(org-datetree-file-entry-under (current-kill 0) date)))))))
|
||||
|
||||
(provide 'org-datetree)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-datetree.el ends here
|
102
elpa/org-20160919/org-docview.el
Normal file
102
elpa/org-20160919/org-docview.el
Normal file
@ -0,0 +1,102 @@
|
||||
;;; org-docview.el --- support for links to doc-view-mode buffers
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Jan Böcker <jan.boecker at jboecker dot de>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file implements links to open files in doc-view-mode.
|
||||
;; Org-mode loads this module by default - if this is not what you want,
|
||||
;; configure the variable `org-modules'.
|
||||
|
||||
;; The links take the form
|
||||
;;
|
||||
;; docview:<file path>::<page number>
|
||||
;;
|
||||
;; for example: [[docview:~/.elisp/org/doc/org.pdf::1][Org-Mode Manual]]
|
||||
;;
|
||||
;; Autocompletion for inserting links is supported; you will be
|
||||
;; prompted for a file and a page number.
|
||||
;;
|
||||
;; If you use org-store-link in a doc-view mode buffer, the stored
|
||||
;; link will point to the current page.
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
||||
(require 'org)
|
||||
(require 'doc-view)
|
||||
|
||||
(declare-function doc-view-goto-page "doc-view" (page))
|
||||
(declare-function image-mode-window-get "image-mode" (prop &optional winprops))
|
||||
|
||||
(org-add-link-type "docview" 'org-docview-open 'org-docview-export)
|
||||
(add-hook 'org-store-link-functions 'org-docview-store-link)
|
||||
|
||||
(defun org-docview-export (link description format)
|
||||
"Export a docview link from Org files."
|
||||
(let* ((path (if (string-match "\\(.+\\)::.+" link) (match-string 1 link)
|
||||
link))
|
||||
(desc (or description link)))
|
||||
(when (stringp path)
|
||||
(setq path (org-link-escape (expand-file-name path)))
|
||||
(cond
|
||||
((eq format 'html) (format "<a href=\"%s\">%s</a>" path desc))
|
||||
((eq format 'latex) (format "\\href{%s}{%s}" path desc))
|
||||
((eq format 'ascii) (format "%s (%s)" desc path))
|
||||
(t path)))))
|
||||
|
||||
(defun org-docview-open (link)
|
||||
(string-match "\\(.*?\\)\\(?:::\\([0-9]+\\)\\)?$" link)
|
||||
(let ((path (match-string 1 link))
|
||||
(page (and (match-beginning 2)
|
||||
(string-to-number (match-string 2 link)))))
|
||||
;; Let Org mode open the file (in-emacs = 1) to ensure
|
||||
;; org-link-frame-setup is respected.
|
||||
(org-open-file path 1)
|
||||
(when page (doc-view-goto-page page))))
|
||||
|
||||
(defun org-docview-store-link ()
|
||||
"Store a link to a docview buffer."
|
||||
(when (eq major-mode 'doc-view-mode)
|
||||
;; This buffer is in doc-view-mode
|
||||
(let* ((path buffer-file-name)
|
||||
(page (image-mode-window-get 'page))
|
||||
(link (concat "docview:" path "::" (number-to-string page)))
|
||||
(description ""))
|
||||
(org-store-link-props
|
||||
:type "docview"
|
||||
:link link
|
||||
:description path))))
|
||||
|
||||
(defun org-docview-complete-link ()
|
||||
"Use the existing file name completion for file.
|
||||
Links to get the file name, then ask the user for the page number
|
||||
and append it."
|
||||
(concat (replace-regexp-in-string "^file:" "docview:" (org-file-complete-link))
|
||||
"::"
|
||||
(read-from-minibuffer "Page:" "1")))
|
||||
|
||||
|
||||
(provide 'org-docview)
|
||||
|
||||
;;; org-docview.el ends here
|
6042
elpa/org-20160919/org-element.el
Normal file
6042
elpa/org-20160919/org-element.el
Normal file
File diff suppressed because it is too large
Load Diff
611
elpa/org-20160919/org-entities.el
Normal file
611
elpa/org-20160919/org-entities.el
Normal file
@ -0,0 +1,611 @@
|
||||
;;; org-entities.el --- Support for special entities in Org-mode
|
||||
|
||||
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>,
|
||||
;; Ulf Stegemann <ulf at zeitform dot de>
|
||||
;; Keywords: outlines, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(declare-function org-toggle-pretty-entities "org" ())
|
||||
(declare-function org-table-align "org-table" ())
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defgroup org-entities nil
|
||||
"Options concerning entities in Org-mode."
|
||||
:tag "Org Entities"
|
||||
:group 'org)
|
||||
|
||||
(defun org-entities--user-safe-p (v)
|
||||
"Non-nil if V is a safe value for `org-entities-user'."
|
||||
(or (null v)
|
||||
(and (listp v)
|
||||
(= (length v) 7)
|
||||
(stringp (nth 0 v))
|
||||
(stringp (nth 1 v))
|
||||
(booleanp (nth 2 v))
|
||||
(stringp (nth 3 v))
|
||||
(stringp (nth 4 v))
|
||||
(stringp (nth 5 v))
|
||||
(stringp (nth 6 v)))))
|
||||
|
||||
(defcustom org-entities-user nil
|
||||
"User-defined entities used in Org-mode to produce special characters.
|
||||
Each entry in this list is a list of strings. It associates the name
|
||||
of the entity that can be inserted into an Org file as \\name with the
|
||||
appropriate replacements for the different export backends. The order
|
||||
of the fields is the following
|
||||
|
||||
name As a string, without the leading backslash.
|
||||
LaTeX replacement In ready LaTeX, no further processing will take place.
|
||||
LaTeX mathp Either t or nil. When t this entity needs to be in
|
||||
math mode.
|
||||
HTML replacement In ready HTML, no further processing will take place.
|
||||
Usually this will be an &...; entity.
|
||||
ASCII replacement Plain ASCII, no extensions.
|
||||
Latin1 replacement Use the special characters available in latin1.
|
||||
utf-8 replacement Use the special characters available in utf-8.
|
||||
|
||||
If you define new entities here that require specific LaTeX
|
||||
packages to be loaded, add these packages to `org-latex-packages-alist'."
|
||||
:group 'org-entities
|
||||
:version "24.1"
|
||||
:type '(repeat
|
||||
(list
|
||||
(string :tag "name ")
|
||||
(string :tag "LaTeX ")
|
||||
(boolean :tag "Require LaTeX math?")
|
||||
(string :tag "HTML ")
|
||||
(string :tag "ASCII ")
|
||||
(string :tag "Latin1")
|
||||
(string :tag "utf-8 ")))
|
||||
:safe #'org-entities--user-safe-p)
|
||||
|
||||
(defconst org-entities
|
||||
(append
|
||||
'("* Letters"
|
||||
"** Latin"
|
||||
("Agrave" "\\`{A}" nil "À" "A" "À" "À")
|
||||
("agrave" "\\`{a}" nil "à" "a" "à" "à")
|
||||
("Aacute" "\\'{A}" nil "Á" "A" "Á" "Á")
|
||||
("aacute" "\\'{a}" nil "á" "a" "á" "á")
|
||||
("Acirc" "\\^{A}" nil "Â" "A" "Â" "Â")
|
||||
("acirc" "\\^{a}" nil "â" "a" "â" "â")
|
||||
("Atilde" "\\~{A}" nil "Ã" "A" "Ã" "Ã")
|
||||
("atilde" "\\~{a}" nil "ã" "a" "ã" "ã")
|
||||
("Auml" "\\\"{A}" nil "Ä" "Ae" "Ä" "Ä")
|
||||
("auml" "\\\"{a}" nil "ä" "ae" "ä" "ä")
|
||||
("Aring" "\\AA{}" nil "Å" "A" "Å" "Å")
|
||||
("AA" "\\AA{}" nil "Å" "A" "Å" "Å")
|
||||
("aring" "\\aa{}" nil "å" "a" "å" "å")
|
||||
("AElig" "\\AE{}" nil "Æ" "AE" "Æ" "Æ")
|
||||
("aelig" "\\ae{}" nil "æ" "ae" "æ" "æ")
|
||||
("Ccedil" "\\c{C}" nil "Ç" "C" "Ç" "Ç")
|
||||
("ccedil" "\\c{c}" nil "ç" "c" "ç" "ç")
|
||||
("Egrave" "\\`{E}" nil "È" "E" "È" "È")
|
||||
("egrave" "\\`{e}" nil "è" "e" "è" "è")
|
||||
("Eacute" "\\'{E}" nil "É" "E" "É" "É")
|
||||
("eacute" "\\'{e}" nil "é" "e" "é" "é")
|
||||
("Ecirc" "\\^{E}" nil "Ê" "E" "Ê" "Ê")
|
||||
("ecirc" "\\^{e}" nil "ê" "e" "ê" "ê")
|
||||
("Euml" "\\\"{E}" nil "Ë" "E" "Ë" "Ë")
|
||||
("euml" "\\\"{e}" nil "ë" "e" "ë" "ë")
|
||||
("Igrave" "\\`{I}" nil "Ì" "I" "Ì" "Ì")
|
||||
("igrave" "\\`{i}" nil "ì" "i" "ì" "ì")
|
||||
("Iacute" "\\'{I}" nil "Í" "I" "Í" "Í")
|
||||
("iacute" "\\'{i}" nil "í" "i" "í" "í")
|
||||
("Icirc" "\\^{I}" nil "Î" "I" "Î" "Î")
|
||||
("icirc" "\\^{i}" nil "î" "i" "î" "î")
|
||||
("Iuml" "\\\"{I}" nil "Ï" "I" "Ï" "Ï")
|
||||
("iuml" "\\\"{i}" nil "ï" "i" "ï" "ï")
|
||||
("Ntilde" "\\~{N}" nil "Ñ" "N" "Ñ" "Ñ")
|
||||
("ntilde" "\\~{n}" nil "ñ" "n" "ñ" "ñ")
|
||||
("Ograve" "\\`{O}" nil "Ò" "O" "Ò" "Ò")
|
||||
("ograve" "\\`{o}" nil "ò" "o" "ò" "ò")
|
||||
("Oacute" "\\'{O}" nil "Ó" "O" "Ó" "Ó")
|
||||
("oacute" "\\'{o}" nil "ó" "o" "ó" "ó")
|
||||
("Ocirc" "\\^{O}" nil "Ô" "O" "Ô" "Ô")
|
||||
("ocirc" "\\^{o}" nil "ô" "o" "ô" "ô")
|
||||
("Otilde" "\\~{O}" nil "Õ" "O" "Õ" "Õ")
|
||||
("otilde" "\\~{o}" nil "õ" "o" "õ" "õ")
|
||||
("Ouml" "\\\"{O}" nil "Ö" "Oe" "Ö" "Ö")
|
||||
("ouml" "\\\"{o}" nil "ö" "oe" "ö" "ö")
|
||||
("Oslash" "\\O" nil "Ø" "O" "Ø" "Ø")
|
||||
("oslash" "\\o{}" nil "ø" "o" "ø" "ø")
|
||||
("OElig" "\\OE{}" nil "Œ" "OE" "OE" "Œ")
|
||||
("oelig" "\\oe{}" nil "œ" "oe" "oe" "œ")
|
||||
("Scaron" "\\v{S}" nil "Š" "S" "S" "Š")
|
||||
("scaron" "\\v{s}" nil "š" "s" "s" "š")
|
||||
("szlig" "\\ss{}" nil "ß" "ss" "ß" "ß")
|
||||
("Ugrave" "\\`{U}" nil "Ù" "U" "Ù" "Ù")
|
||||
("ugrave" "\\`{u}" nil "ù" "u" "ù" "ù")
|
||||
("Uacute" "\\'{U}" nil "Ú" "U" "Ú" "Ú")
|
||||
("uacute" "\\'{u}" nil "ú" "u" "ú" "ú")
|
||||
("Ucirc" "\\^{U}" nil "Û" "U" "Û" "Û")
|
||||
("ucirc" "\\^{u}" nil "û" "u" "û" "û")
|
||||
("Uuml" "\\\"{U}" nil "Ü" "Ue" "Ü" "Ü")
|
||||
("uuml" "\\\"{u}" nil "ü" "ue" "ü" "ü")
|
||||
("Yacute" "\\'{Y}" nil "Ý" "Y" "Ý" "Ý")
|
||||
("yacute" "\\'{y}" nil "ý" "y" "ý" "ý")
|
||||
("Yuml" "\\\"{Y}" nil "Ÿ" "Y" "Y" "Ÿ")
|
||||
("yuml" "\\\"{y}" nil "ÿ" "y" "ÿ" "ÿ")
|
||||
|
||||
"** Latin (special face)"
|
||||
("fnof" "\\textit{f}" nil "ƒ" "f" "f" "ƒ")
|
||||
("real" "\\Re" t "ℜ" "R" "R" "ℜ")
|
||||
("image" "\\Im" t "ℑ" "I" "I" "ℑ")
|
||||
("weierp" "\\wp" t "℘" "P" "P" "℘")
|
||||
("ell" "\\ell" t "ℓ" "ell" "ell" "ℓ")
|
||||
("imath" "\\imath" t "ı" "[dotless i]" "dotless i" "ı")
|
||||
("jmath" "\\jmath" t "ȷ" "[dotless j]" "dotless j" "ȷ")
|
||||
|
||||
"** Greek"
|
||||
("Alpha" "A" nil "Α" "Alpha" "Alpha" "Α")
|
||||
("alpha" "\\alpha" t "α" "alpha" "alpha" "α")
|
||||
("Beta" "B" nil "Β" "Beta" "Beta" "Β")
|
||||
("beta" "\\beta" t "β" "beta" "beta" "β")
|
||||
("Gamma" "\\Gamma" t "Γ" "Gamma" "Gamma" "Γ")
|
||||
("gamma" "\\gamma" t "γ" "gamma" "gamma" "γ")
|
||||
("Delta" "\\Delta" t "Δ" "Delta" "Delta" "Δ")
|
||||
("delta" "\\delta" t "δ" "delta" "delta" "δ")
|
||||
("Epsilon" "E" nil "Ε" "Epsilon" "Epsilon" "Ε")
|
||||
("epsilon" "\\epsilon" t "ε" "epsilon" "epsilon" "ε")
|
||||
("varepsilon" "\\varepsilon" t "ε" "varepsilon" "varepsilon" "ε")
|
||||
("Zeta" "Z" nil "Ζ" "Zeta" "Zeta" "Ζ")
|
||||
("zeta" "\\zeta" t "ζ" "zeta" "zeta" "ζ")
|
||||
("Eta" "H" nil "Η" "Eta" "Eta" "Η")
|
||||
("eta" "\\eta" t "η" "eta" "eta" "η")
|
||||
("Theta" "\\Theta" t "Θ" "Theta" "Theta" "Θ")
|
||||
("theta" "\\theta" t "θ" "theta" "theta" "θ")
|
||||
("thetasym" "\\vartheta" t "ϑ" "theta" "theta" "ϑ")
|
||||
("vartheta" "\\vartheta" t "ϑ" "theta" "theta" "ϑ")
|
||||
("Iota" "I" nil "Ι" "Iota" "Iota" "Ι")
|
||||
("iota" "\\iota" t "ι" "iota" "iota" "ι")
|
||||
("Kappa" "K" nil "Κ" "Kappa" "Kappa" "Κ")
|
||||
("kappa" "\\kappa" t "κ" "kappa" "kappa" "κ")
|
||||
("Lambda" "\\Lambda" t "Λ" "Lambda" "Lambda" "Λ")
|
||||
("lambda" "\\lambda" t "λ" "lambda" "lambda" "λ")
|
||||
("Mu" "M" nil "Μ" "Mu" "Mu" "Μ")
|
||||
("mu" "\\mu" t "μ" "mu" "mu" "μ")
|
||||
("nu" "\\nu" t "ν" "nu" "nu" "ν")
|
||||
("Nu" "N" nil "Ν" "Nu" "Nu" "Ν")
|
||||
("Xi" "\\Xi" t "Ξ" "Xi" "Xi" "Ξ")
|
||||
("xi" "\\xi" t "ξ" "xi" "xi" "ξ")
|
||||
("Omicron" "O" nil "Ο" "Omicron" "Omicron" "Ο")
|
||||
("omicron" "\\textit{o}" nil "ο" "omicron" "omicron" "ο")
|
||||
("Pi" "\\Pi" t "Π" "Pi" "Pi" "Π")
|
||||
("pi" "\\pi" t "π" "pi" "pi" "π")
|
||||
("Rho" "P" nil "Ρ" "Rho" "Rho" "Ρ")
|
||||
("rho" "\\rho" t "ρ" "rho" "rho" "ρ")
|
||||
("Sigma" "\\Sigma" t "Σ" "Sigma" "Sigma" "Σ")
|
||||
("sigma" "\\sigma" t "σ" "sigma" "sigma" "σ")
|
||||
("sigmaf" "\\varsigma" t "ς" "sigmaf" "sigmaf" "ς")
|
||||
("varsigma" "\\varsigma" t "ς" "varsigma" "varsigma" "ς")
|
||||
("Tau" "T" nil "Τ" "Tau" "Tau" "Τ")
|
||||
("Upsilon" "\\Upsilon" t "Υ" "Upsilon" "Upsilon" "Υ")
|
||||
("upsih" "\\Upsilon" t "ϒ" "upsilon" "upsilon" "ϒ")
|
||||
("upsilon" "\\upsilon" t "υ" "upsilon" "upsilon" "υ")
|
||||
("Phi" "\\Phi" t "Φ" "Phi" "Phi" "Φ")
|
||||
("phi" "\\phi" t "φ" "phi" "phi" "ɸ")
|
||||
("varphi" "\\varphi" t "ϕ" "varphi" "varphi" "φ")
|
||||
("Chi" "X" nil "Χ" "Chi" "Chi" "Χ")
|
||||
("chi" "\\chi" t "χ" "chi" "chi" "χ")
|
||||
("acutex" "\\acute x" t "´x" "'x" "'x" "𝑥́")
|
||||
("Psi" "\\Psi" t "Ψ" "Psi" "Psi" "Ψ")
|
||||
("psi" "\\psi" t "ψ" "psi" "psi" "ψ")
|
||||
("tau" "\\tau" t "τ" "tau" "tau" "τ")
|
||||
("Omega" "\\Omega" t "Ω" "Omega" "Omega" "Ω")
|
||||
("omega" "\\omega" t "ω" "omega" "omega" "ω")
|
||||
("piv" "\\varpi" t "ϖ" "omega-pi" "omega-pi" "ϖ")
|
||||
("varpi" "\\varpi" t "ϖ" "omega-pi" "omega-pi" "ϖ")
|
||||
("partial" "\\partial" t "∂" "[partial differential]" "[partial differential]" "∂")
|
||||
|
||||
"** Hebrew"
|
||||
("alefsym" "\\aleph" t "ℵ" "aleph" "aleph" "ℵ")
|
||||
("aleph" "\\aleph" t "ℵ" "aleph" "aleph" "ℵ")
|
||||
("gimel" "\\gimel" t "ℷ" "gimel" "gimel" "ℷ")
|
||||
("beth" "\\beth" t "ℶ" "beth" "beth" "ב")
|
||||
("dalet" "\\daleth" t "ℸ" "dalet" "dalet" "ד")
|
||||
|
||||
"** Dead languages"
|
||||
("ETH" "\\DH{}" nil "Ð" "D" "Ð" "Ð")
|
||||
("eth" "\\dh{}" nil "ð" "dh" "ð" "ð")
|
||||
("THORN" "\\TH{}" nil "Þ" "TH" "Þ" "Þ")
|
||||
("thorn" "\\th{}" nil "þ" "th" "þ" "þ")
|
||||
|
||||
"* Punctuation"
|
||||
"** Dots and Marks"
|
||||
("dots" "\\dots{}" nil "…" "..." "..." "…")
|
||||
("cdots" "\\cdots{}" t "⋯" "..." "..." "⋯")
|
||||
("hellip" "\\dots{}" nil "…" "..." "..." "…")
|
||||
("middot" "\\textperiodcentered{}" nil "·" "." "·" "·")
|
||||
("iexcl" "!`" nil "¡" "!" "¡" "¡")
|
||||
("iquest" "?`" nil "¿" "?" "¿" "¿")
|
||||
|
||||
"** Dash-like"
|
||||
("shy" "\\-" nil "­" "" "" "")
|
||||
("ndash" "--" nil "–" "-" "-" "–")
|
||||
("mdash" "---" nil "—" "--" "--" "—")
|
||||
|
||||
"** Quotations"
|
||||
("quot" "\\textquotedbl{}" nil """ "\"" "\"" "\"")
|
||||
("acute" "\\textasciiacute{}" nil "´" "'" "´" "´")
|
||||
("ldquo" "\\textquotedblleft{}" nil "“" "\"" "\"" "“")
|
||||
("rdquo" "\\textquotedblright{}" nil "”" "\"" "\"" "”")
|
||||
("bdquo" "\\quotedblbase{}" nil "„" "\"" "\"" "„")
|
||||
("lsquo" "\\textquoteleft{}" nil "‘" "`" "`" "‘")
|
||||
("rsquo" "\\textquoteright{}" nil "’" "'" "'" "’")
|
||||
("sbquo" "\\quotesinglbase{}" nil "‚" "," "," "‚")
|
||||
("laquo" "\\guillemotleft{}" nil "«" "<<" "«" "«")
|
||||
("raquo" "\\guillemotright{}" nil "»" ">>" "»" "»")
|
||||
("lsaquo" "\\guilsinglleft{}" nil "‹" "<" "<" "‹")
|
||||
("rsaquo" "\\guilsinglright{}" nil "›" ">" ">" "›")
|
||||
|
||||
"* Other"
|
||||
"** Misc. (often used)"
|
||||
("circ" "\\^{}" nil "ˆ" "^" "^" "∘")
|
||||
("vert" "\\vert{}" t "|" "|" "|" "|")
|
||||
("brvbar" "\\textbrokenbar{}" nil "¦" "|" "¦" "¦")
|
||||
("S" "\\S" nil "§" "paragraph" "§" "§")
|
||||
("sect" "\\S" nil "§" "paragraph" "§" "§")
|
||||
("amp" "\\&" nil "&" "&" "&" "&")
|
||||
("lt" "\\textless{}" nil "<" "<" "<" "<")
|
||||
("gt" "\\textgreater{}" nil ">" ">" ">" ">")
|
||||
("tilde" "\\textasciitilde{}" nil "~" "~" "~" "~")
|
||||
("slash" "/" nil "/" "/" "/" "/")
|
||||
("plus" "+" nil "+" "+" "+" "+")
|
||||
("under" "\\_" nil "_" "_" "_" "_")
|
||||
("equal" "=" nil "=" "=" "=" "=")
|
||||
("asciicirc" "\\textasciicircum{}" nil "^" "^" "^" "^")
|
||||
("dagger" "\\textdagger{}" nil "†" "[dagger]" "[dagger]" "†")
|
||||
("dag" "\\dag{}" nil "†" "[dagger]" "[dagger]" "†")
|
||||
("Dagger" "\\textdaggerdbl{}" nil "‡" "[doubledagger]" "[doubledagger]" "‡")
|
||||
("ddag" "\\ddag{}" nil "‡" "[doubledagger]" "[doubledagger]" "‡")
|
||||
|
||||
"** Whitespace"
|
||||
("nbsp" "~" nil " " " " " " " ")
|
||||
("ensp" "\\hspace*{.5em}" nil " " " " " " " ")
|
||||
("emsp" "\\hspace*{1em}" nil " " " " " " " ")
|
||||
("thinsp" "\\hspace*{.2em}" nil " " " " " " " ")
|
||||
|
||||
"** Currency"
|
||||
("curren" "\\textcurrency{}" nil "¤" "curr." "¤" "¤")
|
||||
("cent" "\\textcent{}" nil "¢" "cent" "¢" "¢")
|
||||
("pound" "\\pounds{}" nil "£" "pound" "£" "£")
|
||||
("yen" "\\textyen{}" nil "¥" "yen" "¥" "¥")
|
||||
("euro" "\\texteuro{}" nil "€" "EUR" "EUR" "€")
|
||||
("EUR" "\\texteuro{}" nil "€" "EUR" "EUR" "€")
|
||||
|
||||
"** Property Marks"
|
||||
("copy" "\\textcopyright{}" nil "©" "(c)" "©" "©")
|
||||
("reg" "\\textregistered{}" nil "®" "(r)" "®" "®")
|
||||
("trade" "\\texttrademark{}" nil "™" "TM" "TM" "™")
|
||||
|
||||
"** Science et al."
|
||||
("minus" "\\minus" t "−" "-" "-" "−")
|
||||
("pm" "\\textpm{}" nil "±" "+-" "±" "±")
|
||||
("plusmn" "\\textpm{}" nil "±" "+-" "±" "±")
|
||||
("times" "\\texttimes{}" nil "×" "*" "×" "×")
|
||||
("frasl" "/" nil "⁄" "/" "/" "⁄")
|
||||
("colon" "\\colon" t ":" ":" ":" ":")
|
||||
("div" "\\textdiv{}" nil "÷" "/" "÷" "÷")
|
||||
("frac12" "\\textonehalf{}" nil "½" "1/2" "½" "½")
|
||||
("frac14" "\\textonequarter{}" nil "¼" "1/4" "¼" "¼")
|
||||
("frac34" "\\textthreequarters{}" nil "¾" "3/4" "¾" "¾")
|
||||
("permil" "\\textperthousand{}" nil "‰" "per thousand" "per thousand" "‰")
|
||||
("sup1" "\\textonesuperior{}" nil "¹" "^1" "¹" "¹")
|
||||
("sup2" "\\texttwosuperior{}" nil "²" "^2" "²" "²")
|
||||
("sup3" "\\textthreesuperior{}" nil "³" "^3" "³" "³")
|
||||
("radic" "\\sqrt{\\,}" t "√" "[square root]" "[square root]" "√")
|
||||
("sum" "\\sum" t "∑" "[sum]" "[sum]" "∑")
|
||||
("prod" "\\prod" t "∏" "[product]" "[n-ary product]" "∏")
|
||||
("micro" "\\textmu{}" nil "µ" "micro" "µ" "µ")
|
||||
("macr" "\\textasciimacron{}" nil "¯" "[macron]" "¯" "¯")
|
||||
("deg" "\\textdegree{}" nil "°" "degree" "°" "°")
|
||||
("prime" "\\prime" t "′" "'" "'" "′")
|
||||
("Prime" "\\prime{}\\prime" t "″" "''" "''" "″")
|
||||
("infin" "\\infty" t "∞" "[infinity]" "[infinity]" "∞")
|
||||
("infty" "\\infty" t "∞" "[infinity]" "[infinity]" "∞")
|
||||
("prop" "\\propto" t "∝" "[proportional to]" "[proportional to]" "∝")
|
||||
("propto" "\\propto" t "∝" "[proportional to]" "[proportional to]" "∝")
|
||||
("not" "\\textlnot{}" nil "¬" "[angled dash]" "¬" "¬")
|
||||
("neg" "\\neg{}" t "¬" "[angled dash]" "¬" "¬")
|
||||
("land" "\\land" t "∧" "[logical and]" "[logical and]" "∧")
|
||||
("wedge" "\\wedge" t "∧" "[logical and]" "[logical and]" "∧")
|
||||
("lor" "\\lor" t "∨" "[logical or]" "[logical or]" "∨")
|
||||
("vee" "\\vee" t "∨" "[logical or]" "[logical or]" "∨")
|
||||
("cap" "\\cap" t "∩" "[intersection]" "[intersection]" "∩")
|
||||
("cup" "\\cup" t "∪" "[union]" "[union]" "∪")
|
||||
("smile" "\\smile" t "⌣" "[cup product]" "[cup product]" "⌣")
|
||||
("frown" "\\frown" t "⌢" "[Cap product]" "[cap product]" "⌢")
|
||||
("int" "\\int" t "∫" "[integral]" "[integral]" "∫")
|
||||
("therefore" "\\therefore" t "∴" "[therefore]" "[therefore]" "∴")
|
||||
("there4" "\\therefore" t "∴" "[therefore]" "[therefore]" "∴")
|
||||
("because" "\\because" t "∵" "[because]" "[because]" "∵")
|
||||
("sim" "\\sim" t "∼" "~" "~" "∼")
|
||||
("cong" "\\cong" t "≅" "[approx. equal to]" "[approx. equal to]" "≅")
|
||||
("simeq" "\\simeq" t "≅" "[approx. equal to]" "[approx. equal to]" "≅")
|
||||
("asymp" "\\asymp" t "≈" "[almost equal to]" "[almost equal to]" "≈")
|
||||
("approx" "\\approx" t "≈" "[almost equal to]" "[almost equal to]" "≈")
|
||||
("ne" "\\ne" t "≠" "[not equal to]" "[not equal to]" "≠")
|
||||
("neq" "\\neq" t "≠" "[not equal to]" "[not equal to]" "≠")
|
||||
("equiv" "\\equiv" t "≡" "[identical to]" "[identical to]" "≡")
|
||||
|
||||
("triangleq" "\\triangleq" t "≜" "[defined to]" "[defined to]" "≜")
|
||||
("le" "\\le" t "≤" "<=" "<=" "≤")
|
||||
("leq" "\\le" t "≤" "<=" "<=" "≤")
|
||||
("ge" "\\ge" t "≥" ">=" ">=" "≥")
|
||||
("geq" "\\ge" t "≥" ">=" ">=" "≥")
|
||||
("lessgtr" "\\lessgtr" t "≶" "[less than or greater than]" "[less than or greater than]" "≶")
|
||||
("lesseqgtr" "\\lesseqgtr" t "⋚" "[less than or equal or greater than or equal]" "[less than or equal or greater than or equal]" "⋚")
|
||||
("ll" "\\ll" t "≪" "<<" "<<" "≪")
|
||||
("Ll" "\\lll" t "⋘" "<<<" "<<<" "⋘")
|
||||
("lll" "\\lll" t "⋘" "<<<" "<<<" "⋘")
|
||||
("gg" "\\gg" t "≫" ">>" ">>" "≫")
|
||||
("Gg" "\\ggg" t "⋙" ">>>" ">>>" "⋙")
|
||||
("ggg" "\\ggg" t "⋙" ">>>" ">>>" "⋙")
|
||||
("prec" "\\prec" t "≺" "[precedes]" "[precedes]" "≺")
|
||||
("preceq" "\\preceq" t "≼" "[precedes or equal]" "[precedes or equal]" "≼")
|
||||
("preccurlyeq" "\\preccurlyeq" t "≼" "[precedes or equal]" "[precedes or equal]" "≼")
|
||||
("succ" "\\succ" t "≻" "[succeeds]" "[succeeds]" "≻")
|
||||
("succeq" "\\succeq" t "≽" "[succeeds or equal]" "[succeeds or equal]" "≽")
|
||||
("succcurlyeq" "\\succcurlyeq" t "≽" "[succeeds or equal]" "[succeeds or equal]" "≽")
|
||||
("sub" "\\subset" t "⊂" "[subset of]" "[subset of]" "⊂")
|
||||
("subset" "\\subset" t "⊂" "[subset of]" "[subset of]" "⊂")
|
||||
("sup" "\\supset" t "⊃" "[superset of]" "[superset of]" "⊃")
|
||||
("supset" "\\supset" t "⊃" "[superset of]" "[superset of]" "⊃")
|
||||
("nsub" "\\not\\subset" t "⊄" "[not a subset of]" "[not a subset of" "⊄")
|
||||
("sube" "\\subseteq" t "⊆" "[subset of or equal to]" "[subset of or equal to]" "⊆")
|
||||
("nsup" "\\not\\supset" t "⊅" "[not a superset of]" "[not a superset of]" "⊅")
|
||||
("supe" "\\supseteq" t "⊇" "[superset of or equal to]" "[superset of or equal to]" "⊇")
|
||||
("setminus" "\\setminus" t "∖" "\" "\" "⧵")
|
||||
("forall" "\\forall" t "∀" "[for all]" "[for all]" "∀")
|
||||
("exist" "\\exists" t "∃" "[there exists]" "[there exists]" "∃")
|
||||
("exists" "\\exists" t "∃" "[there exists]" "[there exists]" "∃")
|
||||
("nexist" "\\nexists" t "∃" "[there does not exists]" "[there does not exists]" "∄")
|
||||
("nexists" "\\nexists" t "∃" "[there does not exists]" "[there does not exists]" "∄")
|
||||
("empty" "\\empty" t "∅" "[empty set]" "[empty set]" "∅")
|
||||
("emptyset" "\\emptyset" t "∅" "[empty set]" "[empty set]" "∅")
|
||||
("isin" "\\in" t "∈" "[element of]" "[element of]" "∈")
|
||||
("in" "\\in" t "∈" "[element of]" "[element of]" "∈")
|
||||
("notin" "\\notin" t "∉" "[not an element of]" "[not an element of]" "∉")
|
||||
("ni" "\\ni" t "∋" "[contains as member]" "[contains as member]" "∋")
|
||||
("nabla" "\\nabla" t "∇" "[nabla]" "[nabla]" "∇")
|
||||
("ang" "\\angle" t "∠" "[angle]" "[angle]" "∠")
|
||||
("angle" "\\angle" t "∠" "[angle]" "[angle]" "∠")
|
||||
("perp" "\\perp" t "⊥" "[up tack]" "[up tack]" "⊥")
|
||||
("parallel" "\\parallel" t "∥" "||" "||" "∥")
|
||||
("sdot" "\\cdot" t "⋅" "[dot]" "[dot]" "⋅")
|
||||
("cdot" "\\cdot" t "⋅" "[dot]" "[dot]" "⋅")
|
||||
("lceil" "\\lceil" t "⌈" "[left ceiling]" "[left ceiling]" "⌈")
|
||||
("rceil" "\\rceil" t "⌉" "[right ceiling]" "[right ceiling]" "⌉")
|
||||
("lfloor" "\\lfloor" t "⌊" "[left floor]" "[left floor]" "⌊")
|
||||
("rfloor" "\\rfloor" t "⌋" "[right floor]" "[right floor]" "⌋")
|
||||
("lang" "\\langle" t "⟨" "<" "<" "⟨")
|
||||
("rang" "\\rangle" t "⟩" ">" ">" "⟩")
|
||||
("langle" "\\langle" t "⟨" "<" "<" "⟨")
|
||||
("rangle" "\\rangle" t "⟩" ">" ">" "⟩")
|
||||
("hbar" "\\hbar" t "ℏ" "hbar" "hbar" "ℏ")
|
||||
("mho" "\\mho" t "℧" "mho" "mho" "℧")
|
||||
|
||||
"** Arrows"
|
||||
("larr" "\\leftarrow" t "←" "<-" "<-" "←")
|
||||
("leftarrow" "\\leftarrow" t "←" "<-" "<-" "←")
|
||||
("gets" "\\gets" t "←" "<-" "<-" "←")
|
||||
("lArr" "\\Leftarrow" t "⇐" "<=" "<=" "⇐")
|
||||
("Leftarrow" "\\Leftarrow" t "⇐" "<=" "<=" "⇐")
|
||||
("uarr" "\\uparrow" t "↑" "[uparrow]" "[uparrow]" "↑")
|
||||
("uparrow" "\\uparrow" t "↑" "[uparrow]" "[uparrow]" "↑")
|
||||
("uArr" "\\Uparrow" t "⇑" "[dbluparrow]" "[dbluparrow]" "⇑")
|
||||
("Uparrow" "\\Uparrow" t "⇑" "[dbluparrow]" "[dbluparrow]" "⇑")
|
||||
("rarr" "\\rightarrow" t "→" "->" "->" "→")
|
||||
("to" "\\to" t "→" "->" "->" "→")
|
||||
("rightarrow" "\\rightarrow" t "→" "->" "->" "→")
|
||||
("rArr" "\\Rightarrow" t "⇒" "=>" "=>" "⇒")
|
||||
("Rightarrow" "\\Rightarrow" t "⇒" "=>" "=>" "⇒")
|
||||
("darr" "\\downarrow" t "↓" "[downarrow]" "[downarrow]" "↓")
|
||||
("downarrow" "\\downarrow" t "↓" "[downarrow]" "[downarrow]" "↓")
|
||||
("dArr" "\\Downarrow" t "⇓" "[dbldownarrow]" "[dbldownarrow]" "⇓")
|
||||
("Downarrow" "\\Downarrow" t "⇓" "[dbldownarrow]" "[dbldownarrow]" "⇓")
|
||||
("harr" "\\leftrightarrow" t "↔" "<->" "<->" "↔")
|
||||
("leftrightarrow" "\\leftrightarrow" t "↔" "<->" "<->" "↔")
|
||||
("hArr" "\\Leftrightarrow" t "⇔" "<=>" "<=>" "⇔")
|
||||
("Leftrightarrow" "\\Leftrightarrow" t "⇔" "<=>" "<=>" "⇔")
|
||||
("crarr" "\\hookleftarrow" t "↵" "<-'" "<-'" "↵")
|
||||
("hookleftarrow" "\\hookleftarrow" t "↵" "<-'" "<-'" "↵")
|
||||
|
||||
"** Function names"
|
||||
("arccos" "\\arccos" t "arccos" "arccos" "arccos" "arccos")
|
||||
("arcsin" "\\arcsin" t "arcsin" "arcsin" "arcsin" "arcsin")
|
||||
("arctan" "\\arctan" t "arctan" "arctan" "arctan" "arctan")
|
||||
("arg" "\\arg" t "arg" "arg" "arg" "arg")
|
||||
("cos" "\\cos" t "cos" "cos" "cos" "cos")
|
||||
("cosh" "\\cosh" t "cosh" "cosh" "cosh" "cosh")
|
||||
("cot" "\\cot" t "cot" "cot" "cot" "cot")
|
||||
("coth" "\\coth" t "coth" "coth" "coth" "coth")
|
||||
("csc" "\\csc" t "csc" "csc" "csc" "csc")
|
||||
("deg" "\\deg" t "°" "deg" "deg" "deg")
|
||||
("det" "\\det" t "det" "det" "det" "det")
|
||||
("dim" "\\dim" t "dim" "dim" "dim" "dim")
|
||||
("exp" "\\exp" t "exp" "exp" "exp" "exp")
|
||||
("gcd" "\\gcd" t "gcd" "gcd" "gcd" "gcd")
|
||||
("hom" "\\hom" t "hom" "hom" "hom" "hom")
|
||||
("inf" "\\inf" t "inf" "inf" "inf" "inf")
|
||||
("ker" "\\ker" t "ker" "ker" "ker" "ker")
|
||||
("lg" "\\lg" t "lg" "lg" "lg" "lg")
|
||||
("lim" "\\lim" t "lim" "lim" "lim" "lim")
|
||||
("liminf" "\\liminf" t "liminf" "liminf" "liminf" "liminf")
|
||||
("limsup" "\\limsup" t "limsup" "limsup" "limsup" "limsup")
|
||||
("ln" "\\ln" t "ln" "ln" "ln" "ln")
|
||||
("log" "\\log" t "log" "log" "log" "log")
|
||||
("max" "\\max" t "max" "max" "max" "max")
|
||||
("min" "\\min" t "min" "min" "min" "min")
|
||||
("Pr" "\\Pr" t "Pr" "Pr" "Pr" "Pr")
|
||||
("sec" "\\sec" t "sec" "sec" "sec" "sec")
|
||||
("sin" "\\sin" t "sin" "sin" "sin" "sin")
|
||||
("sinh" "\\sinh" t "sinh" "sinh" "sinh" "sinh")
|
||||
("sup" "\\sup" t "⊃" "sup" "sup" "sup")
|
||||
("tan" "\\tan" t "tan" "tan" "tan" "tan")
|
||||
("tanh" "\\tanh" t "tanh" "tanh" "tanh" "tanh")
|
||||
|
||||
"** Signs & Symbols"
|
||||
("bull" "\\textbullet{}" nil "•" "*" "*" "•")
|
||||
("bullet" "\\textbullet{}" nil "•" "*" "*" "•")
|
||||
("star" "\\star" t "*" "*" "*" "⋆")
|
||||
("lowast" "\\ast" t "∗" "*" "*" "∗")
|
||||
("ast" "\\ast" t "∗" "*" "*" "*")
|
||||
("odot" "\\odot" t "o" "[circled dot]" "[circled dot]" "ʘ")
|
||||
("oplus" "\\oplus" t "⊕" "[circled plus]" "[circled plus]" "⊕")
|
||||
("otimes" "\\otimes" t "⊗" "[circled times]" "[circled times]" "⊗")
|
||||
("check" "\\checkmark" t "✓" "[checkmark]" "[checkmark]" "✓")
|
||||
("checkmark" "\\checkmark" t "✓" "[checkmark]" "[checkmark]" "✓")
|
||||
|
||||
"** Miscellaneous (seldom used)"
|
||||
("para" "\\P{}" nil "¶" "[pilcrow]" "¶" "¶")
|
||||
("ordf" "\\textordfeminine{}" nil "ª" "_a_" "ª" "ª")
|
||||
("ordm" "\\textordmasculine{}" nil "º" "_o_" "º" "º")
|
||||
("cedil" "\\c{}" nil "¸" "[cedilla]" "¸" "¸")
|
||||
("oline" "\\overline{~}" t "‾" "[overline]" "¯" "‾")
|
||||
("uml" "\\textasciidieresis{}" nil "¨" "[diaeresis]" "¨" "¨")
|
||||
("zwnj" "\\/{}" nil "‌" "" "" "")
|
||||
("zwj" "" nil "‍" "" "" "")
|
||||
("lrm" "" nil "‎" "" "" "")
|
||||
("rlm" "" nil "‏" "" "" "")
|
||||
|
||||
"** Smilies"
|
||||
("smiley" "\\ddot\\smile" t "☺" ":-)" ":-)" "☺")
|
||||
("blacksmile" "\\ddot\\smile" t "☻" ":-)" ":-)" "☻")
|
||||
("sad" "\\ddot\\frown" t "☹" ":-(" ":-(" "☹")
|
||||
("frowny" "\\ddot\\frown" t "☹" ":-(" ":-(" "☹")
|
||||
|
||||
"** Suits"
|
||||
("clubs" "\\clubsuit" t "♣" "[clubs]" "[clubs]" "♣")
|
||||
("clubsuit" "\\clubsuit" t "♣" "[clubs]" "[clubs]" "♣")
|
||||
("spades" "\\spadesuit" t "♠" "[spades]" "[spades]" "♠")
|
||||
("spadesuit" "\\spadesuit" t "♠" "[spades]" "[spades]" "♠")
|
||||
("hearts" "\\heartsuit" t "♥" "[hearts]" "[hearts]" "♥")
|
||||
("heartsuit" "\\heartsuit" t "♥" "[hearts]" "[hearts]" "♥")
|
||||
("diams" "\\diamondsuit" t "♦" "[diamonds]" "[diamonds]" "◆")
|
||||
("diamondsuit" "\\diamondsuit" t "♦" "[diamonds]" "[diamonds]" "◆")
|
||||
("diamond" "\\diamondsuit" t "⋄" "[diamond]" "[diamond]" "◆")
|
||||
("Diamond" "\\diamondsuit" t "⋄" "[diamond]" "[diamond]" "◆")
|
||||
("loz" "\\lozenge" t "◊" "[lozenge]" "[lozenge]" "⧫"))
|
||||
;; Add "\_ "-entity family for spaces.
|
||||
(let (space-entities html-spaces (entity "_"))
|
||||
(dotimes (n 20 (nreverse space-entities))
|
||||
(let ((n (+ 1 n))
|
||||
(spaces (make-string n ?\s)))
|
||||
(push (list (setq entity (concat entity " "))
|
||||
(format "\\hspace*{%sem}" (* n .5))
|
||||
nil
|
||||
(setq html-spaces (concat " " html-spaces))
|
||||
spaces
|
||||
spaces
|
||||
(make-string n ?\x2002))
|
||||
space-entities)))))
|
||||
"Default entities used in Org mode to produce special characters.
|
||||
For details see `org-entities-user'.")
|
||||
|
||||
(defsubst org-entity-get (name)
|
||||
"Get the proper association for NAME from the entity lists.
|
||||
This first checks the user list, then the built-in list."
|
||||
(or (assoc name org-entities-user)
|
||||
(assoc name org-entities)))
|
||||
|
||||
;; Helpfunctions to create a table for orgmode.org/worg/org-symbols.org
|
||||
|
||||
(defun org-entities-create-table ()
|
||||
"Create an Org mode table with all entities."
|
||||
(interactive)
|
||||
(let ((pos (point)) e latex mathp html latin utf8 name ascii)
|
||||
(insert "|Name|LaTeX code|LaTeX|HTML code |HTML|ASCII|Latin1|UTF-8\n|-\n")
|
||||
(mapc (lambda (e) (when (listp e)
|
||||
(setq name (car e)
|
||||
latex (nth 1 e)
|
||||
mathp (nth 2 e)
|
||||
html (nth 3 e)
|
||||
ascii (nth 4 e)
|
||||
latin (nth 5 e)
|
||||
utf8 (nth 6 e))
|
||||
(if (equal ascii "|") (setq ascii "\\vert"))
|
||||
(if (equal latin "|") (setq latin "\\vert"))
|
||||
(if (equal utf8 "|") (setq utf8 "\\vert"))
|
||||
(if (equal ascii "=>") (setq ascii "= >"))
|
||||
(if (equal latin "=>") (setq latin "= >"))
|
||||
(insert "|" name
|
||||
"|" (format "=%s=" latex)
|
||||
"|" (format (if mathp "$%s$" "$\\mbox{%s}$")
|
||||
latex)
|
||||
"|" (format "=%s=" html) "|" html
|
||||
"|" ascii "|" latin "|" utf8
|
||||
"|\n")))
|
||||
org-entities)
|
||||
(goto-char pos)
|
||||
(org-table-align)))
|
||||
|
||||
(defvar org-pretty-entities) ;; declare defcustom from org
|
||||
(defun org-entities-help ()
|
||||
"Create a Help buffer with all available entities."
|
||||
(interactive)
|
||||
(with-output-to-temp-buffer "*Org Entity Help*"
|
||||
(princ "Org-mode entities\n=================\n\n")
|
||||
(let ((ll (append '("* User-defined additions (variable org-entities-user)")
|
||||
org-entities-user
|
||||
org-entities))
|
||||
e latex mathp html latin utf8 name ascii
|
||||
(lastwasstring t)
|
||||
(head (concat
|
||||
"\n"
|
||||
" Symbol Org entity LaTeX code HTML code\n"
|
||||
" -----------------------------------------------------------\n")))
|
||||
(while ll
|
||||
(setq e (pop ll))
|
||||
(if (stringp e)
|
||||
(progn
|
||||
(princ e)
|
||||
(princ "\n")
|
||||
(setq lastwasstring t))
|
||||
(if lastwasstring (princ head))
|
||||
(setq lastwasstring nil)
|
||||
(setq name (car e)
|
||||
latex (nth 1 e)
|
||||
html (nth 3 e)
|
||||
utf8 (nth 6 e))
|
||||
(princ (format " %-8s \\%-16s %-22s %-13s\n"
|
||||
utf8 name latex html))))))
|
||||
(with-current-buffer "*Org Entity Help*"
|
||||
(org-mode)
|
||||
(when org-pretty-entities
|
||||
(org-toggle-pretty-entities)))
|
||||
(select-window (get-buffer-window "*Org Entity Help*")))
|
||||
|
||||
|
||||
(provide 'org-entities)
|
||||
|
||||
;; Local variables:
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
;;; org-entities.el ends here
|
65
elpa/org-20160919/org-eshell.el
Normal file
65
elpa/org-20160919/org-eshell.el
Normal file
@ -0,0 +1,65 @@
|
||||
;;; org-eshell.el - Support for links to working directories in eshell
|
||||
|
||||
;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Konrad Hinsen <konrad.hinsen AT fastmail.net>
|
||||
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'eshell)
|
||||
(require 'esh-mode)
|
||||
|
||||
(org-add-link-type "eshell" 'org-eshell-open)
|
||||
(add-hook 'org-store-link-functions 'org-eshell-store-link)
|
||||
|
||||
(defun org-eshell-open (link)
|
||||
"Switch to am eshell buffer and execute a command line.
|
||||
The link can be just a command line (executed in the default
|
||||
eshell buffer) or a command line prefixed by a buffer name
|
||||
followed by a colon."
|
||||
(let* ((buffer-and-command
|
||||
(if (string-match "\\([A-Za-z0-9-+*]+\\):\\(.*\\)" link)
|
||||
(list (match-string 1 link)
|
||||
(match-string 2 link))
|
||||
(list eshell-buffer-name link)))
|
||||
(eshell-buffer-name (car buffer-and-command))
|
||||
(command (cadr buffer-and-command)))
|
||||
(if (get-buffer eshell-buffer-name)
|
||||
(org-pop-to-buffer-same-window eshell-buffer-name)
|
||||
(eshell))
|
||||
(goto-char (point-max))
|
||||
(eshell-kill-input)
|
||||
(insert command)
|
||||
(eshell-send-input)))
|
||||
|
||||
(defun org-eshell-store-link ()
|
||||
"Store a link that, when opened, switches back to the current eshell buffer
|
||||
and the current working directory."
|
||||
(when (eq major-mode 'eshell-mode)
|
||||
(let* ((command (concat "cd " dired-directory))
|
||||
(link (concat (buffer-name) ":" command)))
|
||||
(org-store-link-props
|
||||
:link (concat "eshell:" link)
|
||||
:description command))))
|
||||
|
||||
(provide 'org-eshell)
|
||||
|
||||
;;; org-eshell.el ends here
|
811
elpa/org-20160919/org-faces.el
Normal file
811
elpa/org-20160919/org-faces.el
Normal file
@ -0,0 +1,811 @@
|
||||
;;; org-faces.el --- Face definitions for Org-mode.
|
||||
|
||||
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains the face definitions for Org.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
|
||||
(when (featurep 'xemacs)
|
||||
(put 'mode-line 'face-alias 'modeline))
|
||||
|
||||
(defgroup org-faces nil
|
||||
"Faces in Org-mode."
|
||||
:tag "Org Faces"
|
||||
:group 'org-appearance)
|
||||
|
||||
(defface org-default
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used for default text."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-hide
|
||||
'((((background light)) (:foreground "white"))
|
||||
(((background dark)) (:foreground "black")))
|
||||
"Face used to hide leading stars in headlines.
|
||||
The foreground color of this face should be equal to the background
|
||||
color of the frame."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-1 ;; originally copied from font-lock-function-name-face
|
||||
(org-compatible-face 'outline-1
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 8)) (:foreground "blue" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face used for level 1 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-2 ;; originally copied from font-lock-variable-name-face
|
||||
(org-compatible-face 'outline-2
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "yellow"))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "yellow" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face used for level 2 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-3 ;; originally copied from font-lock-keyword-face
|
||||
(org-compatible-face 'outline-3
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Purple"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "Cyan1"))
|
||||
(((class color) (min-colors 16) (background light)) (:foreground "Purple"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "Cyan"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "purple" :bold t))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "cyan" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face used for level 3 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-4 ;; originally copied from font-lock-comment-face
|
||||
(org-compatible-face 'outline-4
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
|
||||
(((class color) (min-colors 16) (background light)) (:foreground "red"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "red1"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red" :bold t))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face used for level 4 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-5 ;; originally copied from font-lock-type-face
|
||||
(org-compatible-face 'outline-5
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))))
|
||||
"Face used for level 5 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-6 ;; originally copied from font-lock-constant-face
|
||||
(org-compatible-face 'outline-6
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "CadetBlue"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine"))
|
||||
(((class color) (min-colors 8)) (:foreground "magenta"))))
|
||||
"Face used for level 6 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-7 ;; originally copied from font-lock-builtin-face
|
||||
(org-compatible-face 'outline-7
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "Orchid"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue"))
|
||||
(((class color) (min-colors 8)) (:foreground "blue"))))
|
||||
"Face used for level 7 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-level-8 ;; originally copied from font-lock-string-face
|
||||
(org-compatible-face 'outline-8
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))))
|
||||
"Face used for level 8 headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-special-keyword ;; originally copied from font-lock-string-face
|
||||
(org-compatible-face 'font-lock-keyword-face
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
|
||||
(t (:italic t))))
|
||||
"Face used for special keywords."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-drawer ;; originally copied from font-lock-function-name-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 8)) (:foreground "blue" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face used for drawers."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-property-value nil
|
||||
"Face used for the value of a property."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-column
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light))
|
||||
(:background "grey90" :weight normal :slant normal :strike-through nil
|
||||
:underline nil))
|
||||
(((class color) (min-colors 16) (background dark))
|
||||
(:background "grey30" :weight normal :slant normal :strike-through nil
|
||||
:underline nil))
|
||||
(((class color) (min-colors 8))
|
||||
(:background "cyan" :foreground "black"
|
||||
:weight normal :slant normal :strike-through nil
|
||||
:underline nil))
|
||||
(t (:inverse-video t))))
|
||||
"Face for column display of entry properties.
|
||||
This is actually only part of the face definition for the text in column view.
|
||||
The following faces apply, with this priority.
|
||||
|
||||
1. The color of the reference face. This is normally the level fact that
|
||||
is used in the outline. In agenda-mode, it will be the face of the
|
||||
first character in the line. The color is explicitly retained to
|
||||
make sure that the column line still looks a bit like the structure
|
||||
line it is masking.
|
||||
|
||||
2. The `org-column' face.
|
||||
|
||||
3. The remaining properties of the reference face.
|
||||
|
||||
Since column view works by putting overlays with a display property
|
||||
over individual characters in the buffer, the face of the underlining
|
||||
character (this might for example be the a TODO keyword) might still
|
||||
shine through in some properties. So when your column view looks
|
||||
funny, with \"random\" colors, weight, strike-through, try to explicitly
|
||||
set the properties in the `org-column' face. For example, set
|
||||
:underline to nil, or the :slant to `normal'.
|
||||
|
||||
Under XEmacs, the rules are simpler, because the XEmacs version of
|
||||
column view defines special faces for each outline level. See the file
|
||||
`org-colview-xemacs.el' in Org's contrib/ directory for details."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-column-title
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light))
|
||||
(:background "grey90" :underline t :weight bold))
|
||||
(((class color) (min-colors 16) (background dark))
|
||||
(:background "grey30" :underline t :weight bold))
|
||||
(((class color) (min-colors 8))
|
||||
(:background "cyan" :foreground "black" :underline t :weight bold))
|
||||
(t (:inverse-video t))))
|
||||
"Face for column display of entry properties."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-column-dateline
|
||||
(org-compatible-face 'org-column
|
||||
'((t nil)))
|
||||
"Face used in agenda column view for datelines with summaries."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-warning
|
||||
(org-compatible-face 'font-lock-warning-face
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "Pink" :bold t))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red" :bold t))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face for deadlines and TODO keywords."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-archived ; similar to shadow
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50"))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
(:foreground "grey70"))
|
||||
(((class color) (min-colors 8) (background light))
|
||||
(:foreground "green"))
|
||||
(((class color) (min-colors 8) (background dark))
|
||||
(:foreground "yellow"))))
|
||||
"Face for headline with the ARCHIVE tag."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-link
|
||||
(org-compatible-face 'link
|
||||
'((((class color) (background light)) (:foreground "Purple" :underline t))
|
||||
(((class color) (background dark)) (:foreground "Cyan" :underline t))
|
||||
(t (:underline t))))
|
||||
"Face for links."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-footnote
|
||||
'((((class color) (background light)) (:foreground "Purple" :underline t))
|
||||
(((class color) (background dark)) (:foreground "Cyan" :underline t))
|
||||
(t (:underline t)))
|
||||
"Face for footnotes."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-ellipsis
|
||||
'((((class color) (background light)) (:foreground "DarkGoldenrod" :underline t))
|
||||
(((class color) (background dark)) (:foreground "LightGoldenrod" :underline t))
|
||||
(t (:strike-through t)))
|
||||
"Face for the ellipsis in folded text."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-target
|
||||
'((((class color) (background light)) (:underline t))
|
||||
(((class color) (background dark)) (:underline t))
|
||||
(t (:underline t)))
|
||||
"Face for link targets."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-date
|
||||
'((((class color) (background light)) (:foreground "Purple" :underline t))
|
||||
(((class color) (background dark)) (:foreground "Cyan" :underline t))
|
||||
(t (:underline t)))
|
||||
"Face for date/time stamps."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-date-selected
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "Red1" :inverse-video t))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "Pink" :inverse-video t))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red" :inverse-video t))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red" :inverse-video t))
|
||||
(t (:inverse-video t))))
|
||||
"Face for highlighting the calendar day when using `org-read-date'.
|
||||
Using a bold face here might cause discrepancies while displaying the
|
||||
calendar."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-sexp-date
|
||||
'((((class color) (background light)) (:foreground "Purple"))
|
||||
(((class color) (background dark)) (:foreground "Cyan"))
|
||||
(t (:underline t)))
|
||||
"Face for diary-like sexp date specifications."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-tag
|
||||
'((t (:bold t)))
|
||||
"Default face for tags.
|
||||
Note that the variable `org-tag-faces' can be used to overrule this face for
|
||||
specific tags."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-list-dt
|
||||
'((t (:bold t)))
|
||||
"Default face for definition terms in lists."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-todo ; font-lock-warning-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "Pink" :bold t))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red" :bold t))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
|
||||
(t (:inverse-video t :bold t))))
|
||||
"Face for TODO keywords."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-done ;; originally copied from font-lock-type-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen" :bold t))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen" :bold t))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))
|
||||
(t (:bold t))))
|
||||
"Face used for todo keywords that indicate DONE items."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-done ;; originally copied from font-lock-type-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "ForestGreen"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "PaleGreen"))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))
|
||||
(t (:bold nil))))
|
||||
"Face used in agenda, to indicate lines switched to DONE.
|
||||
This face is used to de-emphasize items that where brightly colored in the
|
||||
agenda because they were things to do, or overdue. The DONE state itself
|
||||
is of course immediately visible, but for example a passed deadline is
|
||||
\(by default) very bright read. This face could be simply the default face
|
||||
of the frame, for example."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-headline-done ;; originally copied from font-lock-string-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
|
||||
(((class color) (min-colors 8) (background light)) (:bold nil))))
|
||||
"Face used to indicate that a headline is DONE.
|
||||
This face is only used if `org-fontify-done-headline' is set. If applies
|
||||
to the part of the headline after the DONE keyword."
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-faces-easy-properties
|
||||
'((todo . :foreground) (tag . :foreground) (priority . :foreground))
|
||||
"The property changes by easy faces.
|
||||
This is an alist, the keys show the area of application, the values
|
||||
can be `:foreground' or `:background'. A color string for special
|
||||
keywords will then be interpreted as either foreground or background
|
||||
color."
|
||||
:group 'org-faces
|
||||
:group 'org-todo
|
||||
:version "24.1"
|
||||
:type '(repeat
|
||||
(cons (choice (const todo) (const tag) (const priority))
|
||||
(choice (const :foreground) (const :background)))))
|
||||
|
||||
(defcustom org-todo-keyword-faces nil
|
||||
"Faces for specific TODO keywords.
|
||||
This is a list of cons cells, with TODO keywords in the car
|
||||
and faces in the cdr. The face can be a symbol, a color
|
||||
as a string (in which case the rest is inherited from the `org-todo' face),
|
||||
or a property list of attributes, like
|
||||
(:foreground \"blue\" :weight bold :underline t).
|
||||
If it is a color string, the variable `org-faces-easy-properties'
|
||||
determines if it is a foreground or a background color."
|
||||
:group 'org-faces
|
||||
:group 'org-todo
|
||||
:type '(repeat
|
||||
(cons
|
||||
(string :tag "Keyword")
|
||||
(choice :tag "Face "
|
||||
(string :tag "Color")
|
||||
(sexp :tag "Face")))))
|
||||
|
||||
(defface org-priority ;; originally copied from font-lock-string-face
|
||||
(org-compatible-face 'font-lock-keyword-face
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
|
||||
(t (:italic t))))
|
||||
"Face used for priority cookies."
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-priority-faces nil
|
||||
"Faces for specific Priorities.
|
||||
This is a list of cons cells, with priority character in the car
|
||||
and faces in the cdr. The face can be a symbol, a color as
|
||||
as a string, or a property list of attributes, like
|
||||
(:foreground \"blue\" :weight bold :underline t).
|
||||
If it is a color string, the variable `org-faces-easy-properties'
|
||||
determines if it is a foreground or a background color."
|
||||
:group 'org-faces
|
||||
:group 'org-todo
|
||||
:type '(repeat
|
||||
(cons
|
||||
(character :tag "Priority")
|
||||
(choice :tag "Face "
|
||||
(string :tag "Color")
|
||||
(sexp :tag "Face")))))
|
||||
|
||||
(defvar org-tags-special-faces-re nil)
|
||||
(defun org-set-tag-faces (var value)
|
||||
(set var value)
|
||||
(if (not value)
|
||||
(setq org-tags-special-faces-re nil)
|
||||
(setq org-tags-special-faces-re
|
||||
(concat ":\\(" (mapconcat 'car value "\\|") "\\):"))))
|
||||
|
||||
(defface org-checkbox
|
||||
(org-compatible-face 'bold
|
||||
'((t (:bold t))))
|
||||
"Face for checkboxes."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-checkbox-statistics-todo
|
||||
'((t (:inherit org-todo)))
|
||||
"Face used for unfinished checkbox statistics."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-checkbox-statistics-done
|
||||
'((t (:inherit org-done)))
|
||||
"Face used for finished checkbox statistics."
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-tag-faces nil
|
||||
"Faces for specific tags.
|
||||
This is a list of cons cells, with tags in the car and faces in the cdr.
|
||||
The face can be a symbol, a foreground color (in which case the rest is
|
||||
inherited from the `org-tag' face) or a property list of attributes,
|
||||
like (:foreground \"blue\" :weight bold :underline t).
|
||||
If you set this variable through customize, it will immediately be effective
|
||||
in new buffers and in modified lines.
|
||||
If you set it with Lisp, a restart of Emacs is required to activate the
|
||||
changes."
|
||||
:group 'org-faces
|
||||
:group 'org-tags
|
||||
:set 'org-set-tag-faces
|
||||
:type '(repeat
|
||||
(cons
|
||||
(string :tag "Tag ")
|
||||
(choice :tag "Face"
|
||||
(string :tag "Foreground color")
|
||||
(sexp :tag "Face")))))
|
||||
|
||||
(defface org-table ;; originally copied from font-lock-function-name-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "blue"))
|
||||
(((class color) (min-colors 8) (background dark)))))
|
||||
"Face used for tables."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-formula
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red"))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red"))
|
||||
(t (:bold t :italic t))))
|
||||
"Face for formulas."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-code
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50"))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
(:foreground "grey70"))
|
||||
(((class color) (min-colors 8) (background light))
|
||||
(:foreground "green"))
|
||||
(((class color) (min-colors 8) (background dark))
|
||||
(:foreground "yellow"))))
|
||||
"Face for fixed-width text like code snippets."
|
||||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-meta-line
|
||||
(org-compatible-face 'font-lock-comment-face nil)
|
||||
"Face for meta lines starting with \"#+\"."
|
||||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-document-title
|
||||
'((((class color) (background light)) (:foreground "midnight blue" :weight bold))
|
||||
(((class color) (background dark)) (:foreground "pale turquoise" :weight bold))
|
||||
(t (:weight bold)))
|
||||
"Face for document title, i.e. that which follows the #+TITLE: keyword."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-document-info
|
||||
'((((class color) (background light)) (:foreground "midnight blue"))
|
||||
(((class color) (background dark)) (:foreground "pale turquoise"))
|
||||
(t nil))
|
||||
"Face for document date, author and email; i.e. that which
|
||||
follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-document-info-keyword
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50"))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
(:foreground "grey70"))
|
||||
(((class color) (min-colors 8) (background light))
|
||||
(:foreground "green"))
|
||||
(((class color) (min-colors 8) (background dark))
|
||||
(:foreground "yellow"))))
|
||||
"Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-block
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50"))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
(:foreground "grey70"))
|
||||
(((class color) (min-colors 8) (background light))
|
||||
(:foreground "green"))
|
||||
(((class color) (min-colors 8) (background dark))
|
||||
(:foreground "yellow"))))
|
||||
"Face text in #+begin ... #+end blocks."
|
||||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-block-begin-line
|
||||
'((t (:inherit org-meta-line)))
|
||||
"Face used for the line delimiting the begin of source blocks."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-block-end-line
|
||||
'((t (:inherit org-block-begin-line)))
|
||||
"Face used for the line delimiting the end of source blocks."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-verbatim
|
||||
(org-compatible-face 'shadow
|
||||
'((((class color grayscale) (min-colors 88) (background light))
|
||||
(:foreground "grey50" :underline t))
|
||||
(((class color grayscale) (min-colors 88) (background dark))
|
||||
(:foreground "grey70" :underline t))
|
||||
(((class color) (min-colors 8) (background light))
|
||||
(:foreground "green" :underline t))
|
||||
(((class color) (min-colors 8) (background dark))
|
||||
(:foreground "yellow" :underline t))))
|
||||
"Face for fixed-with text like code snippets."
|
||||
:group 'org-faces
|
||||
:version "22.1")
|
||||
|
||||
(defface org-quote
|
||||
'((t (:inherit org-block)))
|
||||
"Face for #+BEGIN_QUOTE ... #+END_QUOTE blocks."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-verse
|
||||
'((t (:inherit org-block)))
|
||||
"Face for #+BEGIN_VERSE ... #+END_VERSE blocks."
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-fontify-quote-and-verse-blocks nil
|
||||
"Non-nil means, add a special face to #+begin_quote and #+begin_verse block.
|
||||
When nil, format these as normal Org. This is the default, because the
|
||||
content of these blocks will still be treated as Org syntax."
|
||||
:group 'org-faces
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defface org-clock-overlay ;; copied from secondary-selection
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light))
|
||||
(:background "LightGray" :foreground "black"))
|
||||
(((class color) (min-colors 88) (background dark))
|
||||
(:background "SkyBlue4" :foreground "white"))
|
||||
(((class color) (min-colors 16) (background light))
|
||||
(:background "gray" :foreground "black"))
|
||||
(((class color) (min-colors 16) (background dark))
|
||||
(:background "SkyBlue4" :foreground "white"))
|
||||
(((class color) (min-colors 8))
|
||||
(:background "cyan" :foreground "black"))
|
||||
(t (:inverse-video t))))
|
||||
"Basic face for displaying the secondary selection."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-structure ;; originally copied from font-lock-function-name-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
|
||||
(((class color) (min-colors 8)) (:foreground "blue" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face used in agenda for captions and dates."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-date
|
||||
'((t (:inherit org-agenda-structure)))
|
||||
"Face used in agenda for normal days."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-date-today
|
||||
'((t (:inherit org-agenda-date :weight bold :italic t)))
|
||||
"Face used in agenda for today."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-clocking
|
||||
'((t (:inherit secondary-selection)))
|
||||
"Face marking the current clock item in the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-date-weekend
|
||||
'((t (:inherit org-agenda-date :weight bold)))
|
||||
"Face used in agenda for weekend days.
|
||||
|
||||
See the variable `org-agenda-weekend-days' for a definition of
|
||||
which days belong to the weekend."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-scheduled
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))
|
||||
(t (:bold t :italic t))))
|
||||
"Face for items scheduled for a certain day."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-scheduled-today
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "DarkGreen"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "PaleGreen"))
|
||||
(((class color) (min-colors 8)) (:foreground "green"))
|
||||
(t (:bold t :italic t))))
|
||||
"Face for items scheduled for a certain day."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-dimmed-todo-face
|
||||
'((((background light)) (:foreground "grey50"))
|
||||
(((background dark)) (:foreground "grey50")))
|
||||
"Face used to dim blocked tasks in the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-scheduled-previously
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red"))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face for items scheduled previously, and not yet done."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-upcoming-deadline
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
|
||||
(((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
|
||||
(((class color) (min-colors 8) (background light)) (:foreground "red"))
|
||||
(((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
|
||||
(t (:bold t))))
|
||||
"Face for items scheduled previously, and not yet done."
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-agenda-deadline-faces
|
||||
'((1.0 . org-warning)
|
||||
(0.5 . org-upcoming-deadline)
|
||||
(0.0 . default))
|
||||
"Faces for showing deadlines in the agenda.
|
||||
This is a list of cons cells. The cdr of each cell is a face to be used,
|
||||
and it can also just be like \\='(:foreground \"yellow\").
|
||||
Each car is a fraction of the head-warning time that must have passed for
|
||||
this the face in the cdr to be used for display. The numbers must be
|
||||
given in descending order. The head-warning time is normally taken
|
||||
from `org-deadline-warning-days', but can also be specified in the deadline
|
||||
timestamp itself, like this:
|
||||
|
||||
DEADLINE: <2007-08-13 Mon -8d>
|
||||
|
||||
You may use d for days, w for weeks, m for months and y for years. Months
|
||||
and years will only be treated in an approximate fashion (30.4 days for a
|
||||
month and 365.24 days for a year)."
|
||||
:group 'org-faces
|
||||
:group 'org-agenda-daily/weekly
|
||||
:type '(repeat
|
||||
(cons
|
||||
(number :tag "Fraction of head-warning time passed")
|
||||
(sexp :tag "Face"))))
|
||||
|
||||
(defface org-agenda-restriction-lock
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 88) (background light)) (:background "#eeeeee"))
|
||||
(((class color) (min-colors 88) (background dark)) (:background "#1C1C1C"))
|
||||
(((class color) (min-colors 16) (background light)) (:background "#eeeeee"))
|
||||
(((class color) (min-colors 16) (background dark)) (:background "#1C1C1C"))
|
||||
(((class color) (min-colors 8)) (:background "cyan" :foreground "black"))
|
||||
(t (:inverse-video t))))
|
||||
"Face for showing the agenda restriction lock."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-filter-tags
|
||||
(org-compatible-face 'mode-line nil)
|
||||
"Face for tag(s) in the mode-line when filtering the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-filter-regexp
|
||||
(org-compatible-face 'mode-line nil)
|
||||
"Face for regexp(s) in the mode-line when filtering the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-filter-category
|
||||
(org-compatible-face 'mode-line nil)
|
||||
"Face for categories(s) in the mode-line when filtering the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-time-grid ;; originally copied from font-lock-variable-name-face
|
||||
(org-compatible-face nil
|
||||
'((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
|
||||
(((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
|
||||
(((class color) (min-colors 8)) (:foreground "yellow" :weight light))))
|
||||
"Face used for time grids."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-current-time
|
||||
'((t (:inherit org-time-grid)))
|
||||
"Face used to show the current time in the time grid."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-diary
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used for agenda entries that come from the Emacs diary."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-calendar-event
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used to show events and appointments in the agenda."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-agenda-calendar-sexp
|
||||
(org-compatible-face 'default nil)
|
||||
"Face used to show events computed from a S-expression."
|
||||
:group 'org-faces)
|
||||
|
||||
(defconst org-level-faces
|
||||
'(org-level-1 org-level-2 org-level-3 org-level-4
|
||||
org-level-5 org-level-6 org-level-7 org-level-8
|
||||
))
|
||||
|
||||
(defcustom org-n-level-faces (length org-level-faces)
|
||||
"The number of different faces to be used for headlines.
|
||||
Org-mode defines 8 different headline faces, so this can be at most 8.
|
||||
If it is less than 8, the level-1 face gets re-used for level N+1 etc."
|
||||
:type 'integer
|
||||
:group 'org-faces)
|
||||
|
||||
(defcustom org-cycle-level-faces t
|
||||
"Non-nil means level styles cycle after level `org-n-level-faces'.
|
||||
Then so level org-n-level-faces+1 is styled like level 1.
|
||||
If nil, then all levels >=org-n-level-faces are styled like
|
||||
level org-n-level-faces"
|
||||
:group 'org-appearance
|
||||
:group 'org-faces
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defface org-latex-and-related
|
||||
(let ((font (cond ((assq :inherit custom-face-attributes)
|
||||
'(:inherit underline))
|
||||
(t '(:underline t)))))
|
||||
`((((class grayscale) (background light))
|
||||
(:foreground "DimGray" ,@font))
|
||||
(((class grayscale) (background dark))
|
||||
(:foreground "LightGray" ,@font))
|
||||
(((class color) (background light))
|
||||
(:foreground "SaddleBrown"))
|
||||
(((class color) (background dark))
|
||||
(:foreground "burlywood"))
|
||||
(t (,@font))))
|
||||
"Face used to highlight LaTeX data, entities and sub/superscript."
|
||||
:group 'org-faces
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(defface org-macro
|
||||
(org-compatible-face 'org-latex-and-related nil)
|
||||
"Face for macros."
|
||||
:group 'org-faces
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(defface org-tag-group
|
||||
(org-compatible-face 'org-tag nil)
|
||||
"Face for group tags."
|
||||
:group 'org-faces
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0"))
|
||||
|
||||
(defface org-mode-line-clock
|
||||
'((t (:inherit mode-line)))
|
||||
"Face used for clock display in mode line."
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-mode-line-clock-overrun
|
||||
'((t (:inherit mode-line :background "red")))
|
||||
"Face used for clock display for overrun tasks in mode line."
|
||||
:group 'org-faces)
|
||||
|
||||
(provide 'org-faces)
|
||||
|
||||
;;; org-faces.el ends here
|
705
elpa/org-20160919/org-feed.el
Normal file
705
elpa/org-20160919/org-feed.el
Normal file
@ -0,0 +1,705 @@
|
||||
;;; org-feed.el --- Add RSS feed items to Org files
|
||||
;;
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This module allows entries to be created and changed in an Org-mode
|
||||
;; file triggered by items in an RSS feed. The basic functionality is
|
||||
;; geared toward simply adding new items found in a feed as outline nodes
|
||||
;; to an Org file. Using hooks, arbitrary actions can be triggered for
|
||||
;; new or changed items.
|
||||
;;
|
||||
;; Selecting feeds and target locations
|
||||
;; ------------------------------------
|
||||
;;
|
||||
;; This module is configured through a single variable, `org-feed-alist'.
|
||||
;; Here is an example, using a notes/tasks feed from reQall.com.
|
||||
;;
|
||||
;; (setq org-feed-alist
|
||||
;; '(("ReQall"
|
||||
;; "http://www.reqall.com/user/feeds/rss/a1b2c3....."
|
||||
;; "~/org/feeds.org" "ReQall Entries")
|
||||
;;
|
||||
;; With this setup, the command `M-x org-feed-update-all' will
|
||||
;; collect new entries in the feed at the given URL and create
|
||||
;; entries as subheadings under the "ReQall Entries" heading in the
|
||||
;; file "~/org/feeds.org". Each feed should normally have its own
|
||||
;; heading - however see the `:drawer' parameter.
|
||||
;;
|
||||
;; Besides these standard elements that need to be specified for each
|
||||
;; feed, keyword-value pairs can set additional options. For example,
|
||||
;; to de-select transitional entries with a title containing
|
||||
;;
|
||||
;; "reQall is typing what you said",
|
||||
;;
|
||||
;; you could use the `:filter' argument:
|
||||
;;
|
||||
;; (setq org-feed-alist
|
||||
;; '(("ReQall"
|
||||
;; "http://www.reqall.com/user/feeds/rss/a1b2c3....."
|
||||
;; "~/org/feeds.org" "ReQall Entries"
|
||||
;; :filter my-reqall-filter)))
|
||||
;;
|
||||
;; (defun my-reqall-filter (e)
|
||||
;; (if (string-match "reQall is typing what you said"
|
||||
;; (plist-get e :title))
|
||||
;; nil
|
||||
;; e))
|
||||
;;
|
||||
;; See the docstring for `org-feed-alist' for more details.
|
||||
;;
|
||||
;;
|
||||
;; Keeping track of previously added entries
|
||||
;; -----------------------------------------
|
||||
;;
|
||||
;; Since Org allows you to delete, archive, or move outline nodes,
|
||||
;; org-feed.el needs to keep track of which feed items have been handled
|
||||
;; before, so that they will not be handled again. For this, org-feed.el
|
||||
;; stores information in a special drawer, FEEDSTATUS, under the heading
|
||||
;; that received the input of the feed. You should add FEEDSTATUS
|
||||
;; to your list of drawers in the files that receive feed input:
|
||||
;;
|
||||
;; #+DRAWERS: PROPERTIES CLOCK LOGBOOK RESULTS FEEDSTATUS
|
||||
;;
|
||||
;; Acknowledgments
|
||||
;; ---------------
|
||||
;;
|
||||
;; org-feed.el is based on ideas by Brad Bozarth who implemented a
|
||||
;; similar mechanism using shell and awk scripts.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'sha1)
|
||||
|
||||
(declare-function url-retrieve-synchronously "url"
|
||||
(url &optional silent inhibit-cookies timeout))
|
||||
(declare-function xml-node-children "xml" (node))
|
||||
(declare-function xml-get-children "xml" (node child-name))
|
||||
(declare-function xml-get-attribute "xml" (node attribute))
|
||||
(declare-function xml-get-attribute-or-nil "xml" (node attribute))
|
||||
(declare-function xml-substitute-special "xml" (string))
|
||||
|
||||
(declare-function org-capture-escaped-% "org-capture" ())
|
||||
(declare-function org-capture-inside-embedded-elisp-p "org-capture" ())
|
||||
(declare-function org-capture-expand-embedded-elisp "org-capture" ())
|
||||
|
||||
(defgroup org-feed nil
|
||||
"Options concerning RSS feeds as inputs for Org files."
|
||||
:tag "Org Feed"
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-feed-alist nil
|
||||
"Alist specifying RSS feeds that should create inputs for Org.
|
||||
Each entry in this list specified an RSS feed tat should be queried
|
||||
to create inbox items in Org. Each entry is a list with the following items:
|
||||
|
||||
name a custom name for this feed
|
||||
URL the Feed URL
|
||||
file the target Org file where entries should be listed, when
|
||||
nil the target becomes the current buffer (may be an
|
||||
indirect buffer) each time the feed update is invoked
|
||||
headline the headline under which entries should be listed
|
||||
|
||||
Additional arguments can be given using keyword-value pairs. Many of these
|
||||
specify functions that receive one or a list of \"entries\" as their single
|
||||
argument. An entry is a property list that describes a feed item. The
|
||||
property list has properties for each field in the item, for example `:title'
|
||||
for the `<title>' field and `:pubDate' for the publication date. In addition,
|
||||
it contains the following properties:
|
||||
|
||||
`:item-full-text' the full text in the <item> tag
|
||||
`:guid-permalink' t when the guid property is a permalink
|
||||
|
||||
Here are the keyword-value pair allows in `org-feed-alist'.
|
||||
|
||||
:drawer drawer-name
|
||||
The name of the drawer for storing feed information. The default is
|
||||
\"FEEDSTATUS\". Using different drawers for different feeds allows
|
||||
several feeds to target the same inbox heading.
|
||||
|
||||
:filter filter-function
|
||||
A function to select interesting entries in the feed. It gets a single
|
||||
entry as parameter. It should return the entry if it is relevant, or
|
||||
nil if it is not.
|
||||
|
||||
:template template-string
|
||||
The default action on new items in the feed is to add them as children
|
||||
under the headline for the feed. The template describes how the entry
|
||||
should be formatted. If not given, it defaults to
|
||||
`org-feed-default-template'.
|
||||
|
||||
:formatter formatter-function
|
||||
Instead of relying on a template, you may specify a function to format
|
||||
the outline node to be inserted as a child. This function gets passed
|
||||
a property list describing a single feed item, and it should return a
|
||||
string that is a properly formatted Org outline node of level 1.
|
||||
|
||||
:new-handler function
|
||||
If adding new items as children to the outline is not what you want
|
||||
to do with new items, define a handler function that is called with
|
||||
a list of all new items in the feed, each one represented as a property
|
||||
list. The handler should do what needs to be done, and org-feed will
|
||||
mark all items given to this handler as \"handled\", i.e. they will not
|
||||
be passed to this handler again in future readings of the feed.
|
||||
When the handler is called, point will be at the feed headline.
|
||||
|
||||
:changed-handler function
|
||||
This function gets passed a list of all entries that have been
|
||||
handled before, but are now still in the feed and have *changed*
|
||||
since last handled (as evidenced by a different sha1 hash).
|
||||
When the handler is called, point will be at the feed headline.
|
||||
|
||||
:parse-feed function
|
||||
This function gets passed a buffer, and should return a list
|
||||
of entries, each being a property list containing the
|
||||
`:guid' and `:item-full-text' keys. The default is
|
||||
`org-feed-parse-rss-feed'; `org-feed-parse-atom-feed' is an
|
||||
alternative.
|
||||
|
||||
:parse-entry function
|
||||
This function gets passed an entry as returned by the parse-feed
|
||||
function, and should return the entry with interesting properties added.
|
||||
The default is `org-feed-parse-rss-entry'; `org-feed-parse-atom-entry'
|
||||
is an alternative."
|
||||
:group 'org-feed
|
||||
:type '(repeat
|
||||
(list :value ("" "http://" "" "")
|
||||
(string :tag "Name")
|
||||
(string :tag "Feed URL")
|
||||
(file :tag "File for inbox")
|
||||
(string :tag "Headline for inbox")
|
||||
(repeat :inline t
|
||||
(choice
|
||||
(list :inline t :tag "Filter"
|
||||
(const :filter)
|
||||
(symbol :tag "Filter Function"))
|
||||
(list :inline t :tag "Template"
|
||||
(const :template)
|
||||
(string :tag "Template"))
|
||||
(list :inline t :tag "Formatter"
|
||||
(const :formatter)
|
||||
(symbol :tag "Formatter Function"))
|
||||
(list :inline t :tag "New items handler"
|
||||
(const :new-handler)
|
||||
(symbol :tag "Handler Function"))
|
||||
(list :inline t :tag "Changed items"
|
||||
(const :changed-handler)
|
||||
(symbol :tag "Handler Function"))
|
||||
(list :inline t :tag "Parse Feed"
|
||||
(const :parse-feed)
|
||||
(symbol :tag "Parse Feed Function"))
|
||||
(list :inline t :tag "Parse Entry"
|
||||
(const :parse-entry)
|
||||
(symbol :tag "Parse Entry Function"))
|
||||
)))))
|
||||
|
||||
(defcustom org-feed-drawer "FEEDSTATUS"
|
||||
"The name of the drawer for feed status information.
|
||||
Each feed may also specify its own drawer name using the `:drawer'
|
||||
parameter in `org-feed-alist'."
|
||||
:group 'org-feed
|
||||
:type '(string :tag "Drawer Name"))
|
||||
|
||||
(defcustom org-feed-default-template "\n* %h\n %U\n %description\n %a\n"
|
||||
"Template for the Org node created from RSS feed items.
|
||||
This is just the default, each feed can specify its own.
|
||||
Any fields from the feed item can be interpolated into the template with
|
||||
%name, for example %title, %description, %pubDate etc. In addition, the
|
||||
following special escapes are valid as well:
|
||||
|
||||
%h The title, or the first line of the description
|
||||
%t The date as a stamp, either from <pubDate> (if present), or
|
||||
the current date
|
||||
%T Date and time
|
||||
%u,%U Like %t,%T, but inactive time stamps
|
||||
%a A link, from <guid> if that is a permalink, else from <link>
|
||||
%(sexp) Evaluate elisp `(sexp)' and replace with the result, the simple
|
||||
%-escapes above can be used as arguments, e.g. %(capitalize \\\"%h\\\")"
|
||||
:group 'org-feed
|
||||
:type '(string :tag "Template"))
|
||||
|
||||
(defcustom org-feed-save-after-adding t
|
||||
"Non-nil means save buffer after adding new feed items."
|
||||
:group 'org-feed
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-feed-retrieve-method 'url-retrieve-synchronously
|
||||
"The method to be used to retrieve a feed URL.
|
||||
This can be `curl' or `wget' to call these external programs, or it can be
|
||||
an Emacs Lisp function that will return a buffer containing the content
|
||||
of the file pointed to by the URL."
|
||||
:group 'org-feed
|
||||
:type '(choice
|
||||
(const :tag "Internally with url.el" url-retrieve-synchronously)
|
||||
(const :tag "Externally with curl" curl)
|
||||
(const :tag "Externally with wget" wget)
|
||||
(function :tag "Function")))
|
||||
|
||||
(defcustom org-feed-before-adding-hook nil
|
||||
"Hook that is run before adding new feed items to a file.
|
||||
You might want to commit the file in its current state to version control,
|
||||
for example."
|
||||
:group 'org-feed
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-feed-after-adding-hook nil
|
||||
"Hook that is run after new items have been added to a file.
|
||||
Depending on `org-feed-save-after-adding', the buffer will already
|
||||
have been saved."
|
||||
:group 'org-feed
|
||||
:type 'hook)
|
||||
|
||||
(defvar org-feed-buffer "*Org feed*"
|
||||
"The buffer used to retrieve a feed.")
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-update-all ()
|
||||
"Get inbox items from all feeds in `org-feed-alist'."
|
||||
(interactive)
|
||||
(let ((nfeeds (length org-feed-alist))
|
||||
(nnew (apply '+ (mapcar 'org-feed-update org-feed-alist))))
|
||||
(message "%s from %d %s"
|
||||
(cond ((= nnew 0) "No new entries")
|
||||
((= nnew 1) "1 new entry")
|
||||
(t (format "%d new entries" nnew)))
|
||||
nfeeds
|
||||
(if (= nfeeds 1) "feed" "feeds"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-update (feed &optional retrieve-only)
|
||||
"Get inbox items from FEED.
|
||||
FEED can be a string with an association in `org-feed-alist', or
|
||||
it can be a list structured like an entry in `org-feed-alist'."
|
||||
(interactive (list (org-completing-read "Feed name: " org-feed-alist)))
|
||||
(if (stringp feed) (setq feed (assoc feed org-feed-alist)))
|
||||
(unless feed
|
||||
(error "No such feed in `org-feed-alist"))
|
||||
(catch 'exit
|
||||
(let ((name (car feed))
|
||||
(url (nth 1 feed))
|
||||
(file (or (nth 2 feed) (buffer-file-name (or (buffer-base-buffer)
|
||||
(current-buffer)))))
|
||||
(headline (nth 3 feed))
|
||||
(filter (nth 1 (memq :filter feed)))
|
||||
(formatter (nth 1 (memq :formatter feed)))
|
||||
(new-handler (nth 1 (memq :new-handler feed)))
|
||||
(changed-handler (nth 1 (memq :changed-handler feed)))
|
||||
(template (or (nth 1 (memq :template feed))
|
||||
org-feed-default-template))
|
||||
(drawer (or (nth 1 (memq :drawer feed))
|
||||
org-feed-drawer))
|
||||
(parse-feed (or (nth 1 (memq :parse-feed feed))
|
||||
'org-feed-parse-rss-feed))
|
||||
(parse-entry (or (nth 1 (memq :parse-entry feed))
|
||||
'org-feed-parse-rss-entry))
|
||||
feed-buffer inbox-pos new-formatted
|
||||
entries old-status status new changed guid-alist e guid olds)
|
||||
(setq feed-buffer (org-feed-get-feed url))
|
||||
(unless (and feed-buffer (bufferp (get-buffer feed-buffer)))
|
||||
(error "Cannot get feed %s" name))
|
||||
(when retrieve-only
|
||||
(throw 'exit feed-buffer))
|
||||
(setq entries (funcall parse-feed feed-buffer))
|
||||
(ignore-errors (kill-buffer feed-buffer))
|
||||
(save-excursion
|
||||
(save-window-excursion
|
||||
(setq inbox-pos (org-feed-goto-inbox-internal file headline))
|
||||
(setq old-status (org-feed-read-previous-status inbox-pos drawer))
|
||||
;; Add the "handled" status to the appropriate entries
|
||||
(setq entries (mapcar (lambda (e)
|
||||
(setq e
|
||||
(plist-put e :handled
|
||||
(nth 1 (assoc
|
||||
(plist-get e :guid)
|
||||
old-status)))))
|
||||
entries))
|
||||
;; Find out which entries are new and which are changed
|
||||
(dolist (e entries)
|
||||
(if (not (plist-get e :handled))
|
||||
(push e new)
|
||||
(setq olds (nth 2 (assoc (plist-get e :guid) old-status)))
|
||||
(if (and olds
|
||||
(not (string= (sha1
|
||||
(plist-get e :item-full-text))
|
||||
olds)))
|
||||
(push e changed))))
|
||||
|
||||
;; Parse the relevant entries fully
|
||||
(setq new (mapcar parse-entry new)
|
||||
changed (mapcar parse-entry changed))
|
||||
|
||||
;; Run the filter
|
||||
(when filter
|
||||
(setq new (delq nil (mapcar filter new))
|
||||
changed (delq nil (mapcar filter new))))
|
||||
|
||||
(when (not (or new changed))
|
||||
(message "No new items in feed %s" name)
|
||||
(throw 'exit 0))
|
||||
|
||||
;; Get alist based on guid, to look up entries
|
||||
(setq guid-alist
|
||||
(append
|
||||
(mapcar (lambda (e) (list (plist-get e :guid) e)) new)
|
||||
(mapcar (lambda (e) (list (plist-get e :guid) e)) changed)))
|
||||
|
||||
;; Construct the new status
|
||||
(setq status
|
||||
(mapcar
|
||||
(lambda (e)
|
||||
(setq guid (plist-get e :guid))
|
||||
(list guid
|
||||
;; things count as handled if we handle them now,
|
||||
;; or if they were handled previously
|
||||
(if (assoc guid guid-alist) t (plist-get e :handled))
|
||||
;; A hash, to detect changes
|
||||
(sha1 (plist-get e :item-full-text))))
|
||||
entries))
|
||||
|
||||
;; Handle new items in the feed
|
||||
(when new
|
||||
(if new-handler
|
||||
(progn
|
||||
(goto-char inbox-pos)
|
||||
(funcall new-handler new))
|
||||
;; No custom handler, do the default adding
|
||||
;; Format the new entries into an alist with GUIDs in the car
|
||||
(setq new-formatted
|
||||
(mapcar
|
||||
(lambda (e) (org-feed-format-entry e template formatter))
|
||||
new)))
|
||||
|
||||
;; Insert the new items
|
||||
(org-feed-add-items inbox-pos new-formatted))
|
||||
|
||||
;; Handle changed items in the feed
|
||||
(when (and changed-handler changed)
|
||||
(goto-char inbox-pos)
|
||||
(funcall changed-handler changed))
|
||||
|
||||
;; Write the new status
|
||||
;; We do this only now, in case something goes wrong above, so
|
||||
;; that would would end up with a status that does not reflect
|
||||
;; which items truely have been handled
|
||||
(org-feed-write-status inbox-pos drawer status)
|
||||
|
||||
;; Normalize the visibility of the inbox tree
|
||||
(goto-char inbox-pos)
|
||||
(outline-hide-subtree)
|
||||
(outline-show-children)
|
||||
(org-cycle-hide-drawers 'children)
|
||||
|
||||
;; Hooks and messages
|
||||
(when org-feed-save-after-adding (save-buffer))
|
||||
(message "Added %d new item%s from feed %s to file %s, heading %s"
|
||||
(length new) (if (> (length new) 1) "s" "")
|
||||
name
|
||||
(file-name-nondirectory file) headline)
|
||||
(run-hooks 'org-feed-after-adding-hook)
|
||||
(length new))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-goto-inbox (feed)
|
||||
"Go to the inbox that captures the feed named FEED."
|
||||
(interactive
|
||||
(list (if (= (length org-feed-alist) 1)
|
||||
(car org-feed-alist)
|
||||
(org-completing-read "Feed name: " org-feed-alist))))
|
||||
(if (stringp feed) (setq feed (assoc feed org-feed-alist)))
|
||||
(unless feed
|
||||
(error "No such feed in `org-feed-alist"))
|
||||
(org-feed-goto-inbox-internal (nth 2 feed) (nth 3 feed)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-feed-show-raw-feed (feed)
|
||||
"Show the raw feed buffer of a feed."
|
||||
(interactive
|
||||
(list (if (= (length org-feed-alist) 1)
|
||||
(car org-feed-alist)
|
||||
(org-completing-read "Feed name: " org-feed-alist))))
|
||||
(if (stringp feed) (setq feed (assoc feed org-feed-alist)))
|
||||
(unless feed
|
||||
(error "No such feed in `org-feed-alist"))
|
||||
(org-pop-to-buffer-same-window
|
||||
(org-feed-update feed 'retrieve-only))
|
||||
(goto-char (point-min)))
|
||||
|
||||
(defun org-feed-goto-inbox-internal (file heading)
|
||||
"Find or create HEADING in FILE.
|
||||
Switch to that buffer, and return the position of that headline."
|
||||
(find-file file)
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward
|
||||
(concat "^\\*+[ \t]+" heading "[ \t]*\\(:.*?:[ \t]*\\)?$")
|
||||
nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(goto-char (point-max))
|
||||
(insert "\n\n* " heading "\n\n")
|
||||
(org-back-to-heading t))
|
||||
(point))
|
||||
|
||||
(defun org-feed-read-previous-status (pos drawer)
|
||||
"Get the alist of old GUIDs from the entry at POS.
|
||||
This will find DRAWER and extract the alist."
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(let ((end (save-excursion (org-end-of-subtree t t))))
|
||||
(if (re-search-forward
|
||||
(concat "^[ \t]*:" drawer ":[ \t]*\n\\([^\000]*?\\)\n[ \t]*:END:")
|
||||
end t)
|
||||
(read (match-string 1))
|
||||
nil))))
|
||||
|
||||
(defun org-feed-write-status (pos drawer status)
|
||||
"Write the feed STATUS to DRAWER in entry at POS."
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(let ((end (save-excursion (org-end-of-subtree t t)))
|
||||
guid)
|
||||
(if (re-search-forward (concat "^[ \t]*:" drawer ":[ \t]*\n")
|
||||
end t)
|
||||
(progn
|
||||
(goto-char (match-end 0))
|
||||
(delete-region (point)
|
||||
(save-excursion
|
||||
(and (re-search-forward "^[ \t]*:END:" nil t)
|
||||
(match-beginning 0)))))
|
||||
(outline-next-heading)
|
||||
(insert " :" drawer ":\n :END:\n")
|
||||
(beginning-of-line 0))
|
||||
(insert (pp-to-string status)))))
|
||||
|
||||
(defun org-feed-add-items (pos entries)
|
||||
"Add the formatted items to the headline as POS."
|
||||
(let (entry level)
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(unless (looking-at org-complex-heading-regexp)
|
||||
(error "Wrong position"))
|
||||
(setq level (org-get-valid-level (length (match-string 1)) 1))
|
||||
(org-end-of-subtree t t)
|
||||
(skip-chars-backward " \t\n")
|
||||
(beginning-of-line 2)
|
||||
(setq pos (point))
|
||||
(while (setq entry (pop entries))
|
||||
(org-paste-subtree level entry 'yank))
|
||||
(org-mark-ring-push pos))))
|
||||
|
||||
(defun org-feed-format-entry (entry template formatter)
|
||||
"Format ENTRY so that it can be inserted into an Org file.
|
||||
ENTRY is a property list. This function adds a `:formatted-for-org' property
|
||||
and returns the full property list.
|
||||
If that property is already present, nothing changes."
|
||||
(require 'org-capture)
|
||||
(if formatter
|
||||
(funcall formatter entry)
|
||||
(let (dlines time escape name tmp
|
||||
v-h v-t v-T v-u v-U v-a)
|
||||
(setq dlines (org-split-string (or (plist-get entry :description) "???")
|
||||
"\n")
|
||||
v-h (or (plist-get entry :title) (car dlines) "???")
|
||||
time (or (if (plist-get entry :pubDate)
|
||||
(org-read-date t t (plist-get entry :pubDate)))
|
||||
(current-time))
|
||||
v-t (format-time-string (org-time-stamp-format nil nil) time)
|
||||
v-T (format-time-string (org-time-stamp-format t nil) time)
|
||||
v-u (format-time-string (org-time-stamp-format nil t) time)
|
||||
v-U (format-time-string (org-time-stamp-format t t) time)
|
||||
v-a (if (setq tmp (or (and (plist-get entry :guid-permalink)
|
||||
(plist-get entry :guid))
|
||||
(plist-get entry :link)))
|
||||
(concat "[[" tmp "]]\n")
|
||||
""))
|
||||
(with-temp-buffer
|
||||
(insert template)
|
||||
|
||||
;; Simple %-escapes
|
||||
;; before embedded elisp to support simple %-escapes as
|
||||
;; arguments for embedded elisp
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "%\\([a-zA-Z]+\\)" nil t)
|
||||
(unless (org-capture-escaped-%)
|
||||
(setq name (match-string 1)
|
||||
escape (org-capture-inside-embedded-elisp-p))
|
||||
(cond
|
||||
((member name '("h" "t" "T" "u" "U" "a"))
|
||||
(setq tmp (symbol-value (intern (concat "v-" name)))))
|
||||
((setq tmp (plist-get entry (intern (concat ":" name))))
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(beginning-of-line 1)
|
||||
(when (looking-at
|
||||
(concat "^\\([ \t]*\\)%" name "[ \t]*$"))
|
||||
(setq tmp (org-feed-make-indented-block
|
||||
tmp (org-get-indentation))))))))
|
||||
(when tmp
|
||||
;; escape string delimiters `"' when inside %() embedded lisp
|
||||
(when escape
|
||||
(setq tmp (replace-regexp-in-string "\"" "\\\\\"" tmp)))
|
||||
(replace-match tmp t t))))
|
||||
|
||||
;; %() embedded elisp
|
||||
(org-capture-expand-embedded-elisp)
|
||||
|
||||
(decode-coding-string
|
||||
(buffer-string) (detect-coding-region (point-min) (point-max) t))))))
|
||||
|
||||
(defun org-feed-make-indented-block (s n)
|
||||
"Add indentation of N spaces to a multiline string S."
|
||||
(if (not (string-match "\n" s))
|
||||
s
|
||||
(mapconcat 'identity
|
||||
(org-split-string s "\n")
|
||||
(concat "\n" (make-string n ?\ )))))
|
||||
|
||||
(defun org-feed-skip-http-headers (buffer)
|
||||
"Remove HTTP headers from BUFFER, and return it.
|
||||
Assumes headers are indeed present!"
|
||||
(with-current-buffer buffer
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(search-forward "\n\n")
|
||||
(delete-region (point-min) (point))
|
||||
buffer))
|
||||
|
||||
(defun org-feed-get-feed (url)
|
||||
"Get the RSS feed file at URL and return the buffer."
|
||||
(cond
|
||||
((eq org-feed-retrieve-method 'url-retrieve-synchronously)
|
||||
(org-feed-skip-http-headers (url-retrieve-synchronously url)))
|
||||
((eq org-feed-retrieve-method 'curl)
|
||||
(ignore-errors (kill-buffer org-feed-buffer))
|
||||
(call-process "curl" nil org-feed-buffer nil "--silent" url)
|
||||
org-feed-buffer)
|
||||
((eq org-feed-retrieve-method 'wget)
|
||||
(ignore-errors (kill-buffer org-feed-buffer))
|
||||
(call-process "wget" nil org-feed-buffer nil "-q" "-O" "-" url)
|
||||
org-feed-buffer)
|
||||
((functionp org-feed-retrieve-method)
|
||||
(funcall org-feed-retrieve-method url))))
|
||||
|
||||
(defun org-feed-parse-rss-feed (buffer)
|
||||
"Parse BUFFER for RSS feed entries.
|
||||
Returns a list of entries, with each entry a property list,
|
||||
containing the properties `:guid' and `:item-full-text'."
|
||||
(require 'xml)
|
||||
(let ((case-fold-search t)
|
||||
entries beg end item guid entry)
|
||||
(with-current-buffer buffer
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "<item\\>.*?>" nil t)
|
||||
(setq beg (point)
|
||||
end (and (re-search-forward "</item>" nil t)
|
||||
(match-beginning 0)))
|
||||
(setq item (buffer-substring beg end)
|
||||
guid (if (string-match "<guid\\>.*?>\\(.*?\\)</guid>" item)
|
||||
(xml-substitute-special (org-match-string-no-properties 1 item))))
|
||||
(setq entry (list :guid guid :item-full-text item))
|
||||
(push entry entries)
|
||||
(widen)
|
||||
(goto-char end))
|
||||
(nreverse entries))))
|
||||
|
||||
(defun org-feed-parse-rss-entry (entry)
|
||||
"Parse the `:item-full-text' field for xml tags and create new properties."
|
||||
(require 'xml)
|
||||
(with-temp-buffer
|
||||
(insert (plist-get entry :item-full-text))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\([^\000]*?\\)</\\1>"
|
||||
nil t)
|
||||
(setq entry (plist-put entry
|
||||
(intern (concat ":" (match-string 1)))
|
||||
(xml-substitute-special (match-string 2)))))
|
||||
(goto-char (point-min))
|
||||
(unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t)
|
||||
(setq entry (plist-put entry :guid-permalink t))))
|
||||
entry)
|
||||
|
||||
(defun org-feed-parse-atom-feed (buffer)
|
||||
"Parse BUFFER for Atom feed entries.
|
||||
Returns a list of entries, with each entry a property list,
|
||||
containing the properties `:guid' and `:item-full-text'.
|
||||
|
||||
The `:item-full-text' property actually contains the sexp
|
||||
formatted as a string, not the original XML data."
|
||||
(require 'xml)
|
||||
(with-current-buffer buffer
|
||||
(widen)
|
||||
(let ((feed (car (xml-parse-region (point-min) (point-max)))))
|
||||
(mapcar
|
||||
(lambda (entry)
|
||||
(list
|
||||
:guid (car (xml-node-children (car (xml-get-children entry 'id))))
|
||||
:item-full-text (prin1-to-string entry)))
|
||||
(xml-get-children feed 'entry)))))
|
||||
|
||||
(defun org-feed-parse-atom-entry (entry)
|
||||
"Parse the `:item-full-text' as a sexp and create new properties."
|
||||
(let ((xml (car (read-from-string (plist-get entry :item-full-text)))))
|
||||
;; Get first <link href='foo'/>.
|
||||
(setq entry (plist-put entry :link
|
||||
(xml-get-attribute
|
||||
(car (xml-get-children xml 'link))
|
||||
'href)))
|
||||
;; Add <title/> as :title.
|
||||
(setq entry (plist-put entry :title
|
||||
(xml-substitute-special
|
||||
(car (xml-node-children
|
||||
(car (xml-get-children xml 'title)))))))
|
||||
(let* ((content (car (xml-get-children xml 'content)))
|
||||
(type (xml-get-attribute-or-nil content 'type)))
|
||||
(when content
|
||||
(cond
|
||||
((string= type "text")
|
||||
;; We like plain text.
|
||||
(setq entry (plist-put entry :description
|
||||
(xml-substitute-special
|
||||
(car (xml-node-children content))))))
|
||||
((string= type "html")
|
||||
;; TODO: convert HTML to Org markup.
|
||||
(setq entry (plist-put entry :description
|
||||
(xml-substitute-special
|
||||
(car (xml-node-children content))))))
|
||||
((string= type "xhtml")
|
||||
;; TODO: convert XHTML to Org markup.
|
||||
(setq entry (plist-put entry :description
|
||||
(prin1-to-string
|
||||
(xml-node-children content)))))
|
||||
(t
|
||||
(setq entry (plist-put entry :description
|
||||
(format-message
|
||||
"Unknown `%s' content." type)))))))
|
||||
entry))
|
||||
|
||||
(provide 'org-feed)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-feed.el ends here
|
989
elpa/org-20160919/org-footnote.el
Normal file
989
elpa/org-20160919/org-footnote.el
Normal file
@ -0,0 +1,989 @@
|
||||
;;; org-footnote.el --- Footnote support in Org and elsewhere
|
||||
;;
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains the code dealing with footnotes in Org-mode.
|
||||
;; The code can also be used in arbitrary text modes to provide
|
||||
;; footnotes. Compared to Steven L Baur's footnote.el it provides
|
||||
;; better support for resuming editing. It is less configurable than
|
||||
;; Steve's code, though.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
|
||||
(declare-function message-point-in-header-p "message" ())
|
||||
(declare-function org-at-comment-p "org" ())
|
||||
(declare-function org-at-heading-p "org" (&optional ignored))
|
||||
(declare-function org-back-over-empty-lines "org" ())
|
||||
(declare-function org-back-to-heading "org" (&optional invisible-ok))
|
||||
(declare-function org-combine-plists "org" (&rest plists))
|
||||
(declare-function org-edit-footnote-reference "org-src" ())
|
||||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-property "org-element" (property element))
|
||||
(declare-function org-element-type "org-element" (element))
|
||||
(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
|
||||
(declare-function org-fill-paragraph "org" (&optional justify))
|
||||
(declare-function org-icompleting-read "org" (&rest args))
|
||||
(declare-function org-id-uuid "org-id" ())
|
||||
(declare-function org-in-block-p "org" (names))
|
||||
(declare-function org-in-regexp "org" (re &optional nlines visually))
|
||||
(declare-function org-in-verbatim-emphasis "org" ())
|
||||
(declare-function org-inside-LaTeX-fragment-p "org" ())
|
||||
(declare-function org-inside-latex-macro-p "org" ())
|
||||
(declare-function org-mark-ring-push "org" (&optional pos buffer))
|
||||
(declare-function org-show-context "org" (&optional key))
|
||||
(declare-function org-skip-whitespace "org" ())
|
||||
(declare-function org-skip-whitespace "org" ())
|
||||
(declare-function org-trim "org" (s))
|
||||
(declare-function outline-next-heading "outline")
|
||||
|
||||
(defvar message-cite-prefix-regexp) ; defined in message.el
|
||||
(defvar message-signature-separator) ; defined in message.el
|
||||
(defvar org-bracket-link-regexp) ; defined in org.el
|
||||
(defvar org-complex-heading-regexp) ; defined in org.el
|
||||
(defvar org-element-all-elements) ; defined in org-element.el
|
||||
(defvar org-element-all-objects) ; defined in org-element.el
|
||||
(defvar org-odd-levels-only) ; defined in org.el
|
||||
(defvar org-outline-regexp-bol) ; defined in org.el
|
||||
|
||||
(defconst org-footnote-re
|
||||
;; Only [1]-like footnotes are closed in this regexp, as footnotes
|
||||
;; from other types might contain square brackets (i.e. links) in
|
||||
;; their definition.
|
||||
;;
|
||||
;; `org-re' is used for regexp compatibility with XEmacs.
|
||||
(concat "\\[\\(?:"
|
||||
;; Match inline footnotes.
|
||||
(org-re "fn:\\([-_[:word:]]+\\)?:\\|")
|
||||
;; Match other footnotes.
|
||||
"\\(?:\\([0-9]+\\)\\]\\)\\|"
|
||||
(org-re "\\(fn:[-_[:word:]]+\\)")
|
||||
"\\)")
|
||||
"Regular expression for matching footnotes.")
|
||||
|
||||
(defconst org-footnote-definition-re
|
||||
(org-re "^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]")
|
||||
"Regular expression matching the definition of a footnote.")
|
||||
|
||||
(defconst org-footnote-forbidden-blocks
|
||||
'("ascii" "beamer" "comment" "example" "html" "latex" "odt" "src")
|
||||
"Names of blocks where footnotes are not allowed.")
|
||||
|
||||
(defgroup org-footnote nil
|
||||
"Footnotes in Org-mode."
|
||||
:tag "Org Footnote"
|
||||
:group 'org)
|
||||
|
||||
(defcustom org-footnote-section "Footnotes"
|
||||
"Outline heading containing footnote definitions.
|
||||
|
||||
This can be nil, to place footnotes locally at the end of the
|
||||
current outline node. If can also be the name of a special
|
||||
outline heading under which footnotes should be put.
|
||||
|
||||
This variable defines the place where Org puts the definition
|
||||
automatically, i.e. when creating the footnote, and when sorting
|
||||
the notes. However, by hand you may place definitions
|
||||
*anywhere*.
|
||||
|
||||
If this is a string, during export, all subtrees starting with
|
||||
this heading will be ignored.
|
||||
|
||||
If you don't use the customize interface to change this variable,
|
||||
you will need to run the following command after the change:
|
||||
|
||||
\\[universal-argument] \\[org-element-cache-reset]"
|
||||
:group 'org-footnote
|
||||
:initialize 'custom-initialize-default
|
||||
:set (lambda (var val)
|
||||
(set var val)
|
||||
(when (fboundp 'org-element-cache-reset)
|
||||
(org-element-cache-reset 'all)))
|
||||
:type '(choice
|
||||
(string :tag "Collect footnotes under heading")
|
||||
(const :tag "Define footnotes locally" nil)))
|
||||
|
||||
(defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:"
|
||||
"Tag marking the beginning of footnote section.
|
||||
The Org footnote engine can be used in arbitrary text files as well
|
||||
as in Org-mode. Outside Org mode, new footnotes are always placed at
|
||||
the end of the file. When you normalize the notes, any line containing
|
||||
only this tag will be removed, a new one will be inserted at the end
|
||||
of the file, followed by the collected and normalized footnotes.
|
||||
|
||||
If you don't want any tag in such buffers, set this variable to nil."
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(string :tag "Collect footnotes under tag")
|
||||
(const :tag "Don't use a tag" nil)))
|
||||
|
||||
(defcustom org-footnote-define-inline nil
|
||||
"Non-nil means define footnotes inline, at reference location.
|
||||
When nil, footnotes will be defined in a special section near
|
||||
the end of the document. When t, the [fn:label:definition] notation
|
||||
will be used to define the footnote at the reference position."
|
||||
:group 'org-footnote
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-footnote-auto-label t
|
||||
"Non-nil means define automatically new labels for footnotes.
|
||||
Possible values are:
|
||||
|
||||
nil Prompt the user for each label.
|
||||
t Create unique labels of the form [fn:1], [fn:2], etc.
|
||||
confirm Like t, but let the user edit the created value.
|
||||
The label can be removed from the minibuffer to create
|
||||
an anonymous footnote.
|
||||
random Automatically generate a unique, random label.
|
||||
plain Automatically create plain number labels like [1]."
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(const :tag "Prompt for label" nil)
|
||||
(const :tag "Create automatic [fn:N]" t)
|
||||
(const :tag "Offer automatic [fn:N] for editing" confirm)
|
||||
(const :tag "Create a random label" random)
|
||||
(const :tag "Create automatic [N]" plain)))
|
||||
|
||||
(defcustom org-footnote-auto-adjust nil
|
||||
"Non-nil means automatically adjust footnotes after insert/delete.
|
||||
When this is t, after each insertion or deletion of a footnote,
|
||||
simple fn:N footnotes will be renumbered, and all footnotes will be sorted.
|
||||
If you want to have just sorting or just renumbering, set this variable
|
||||
to `sort' or `renumber'.
|
||||
|
||||
The main values of this variable can be set with in-buffer options:
|
||||
|
||||
#+STARTUP: fnadjust
|
||||
#+STARTUP: nofnadjust"
|
||||
:group 'org-footnote
|
||||
:type '(choice
|
||||
(const :tag "No adjustment" nil)
|
||||
(const :tag "Renumber" renumber)
|
||||
(const :tag "Sort" sort)
|
||||
(const :tag "Renumber and Sort" t)))
|
||||
|
||||
(defcustom org-footnote-fill-after-inline-note-extraction nil
|
||||
"Non-nil means fill paragraphs after extracting footnotes.
|
||||
When extracting inline footnotes, the lengths of lines can change a lot.
|
||||
When this option is set, paragraphs from which an inline footnote has been
|
||||
extracted will be filled again."
|
||||
:group 'org-footnote
|
||||
:type 'boolean)
|
||||
|
||||
(defun org-footnote-in-valid-context-p ()
|
||||
"Is point in a context where footnotes are allowed?"
|
||||
(save-match-data
|
||||
(not (or (org-at-comment-p)
|
||||
(org-inside-LaTeX-fragment-p)
|
||||
;; Avoid literal example.
|
||||
(org-in-verbatim-emphasis)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at "[ \t]*:[ \t]+"))
|
||||
;; Avoid cited text and headers in message-mode.
|
||||
(and (derived-mode-p 'message-mode)
|
||||
(or (save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at message-cite-prefix-regexp))
|
||||
(message-point-in-header-p)))
|
||||
;; Avoid forbidden blocks.
|
||||
(org-in-block-p org-footnote-forbidden-blocks)))))
|
||||
|
||||
(defun org-footnote-at-reference-p ()
|
||||
"Is the cursor at a footnote reference?
|
||||
|
||||
If so, return a list containing its label, beginning and ending
|
||||
positions, and the definition, when inlined."
|
||||
(when (and (org-footnote-in-valid-context-p)
|
||||
(or (looking-at org-footnote-re)
|
||||
(org-in-regexp org-footnote-re)
|
||||
(save-excursion (re-search-backward org-footnote-re nil t)))
|
||||
(/= (match-beginning 0) (point-at-bol)))
|
||||
(let* ((beg (match-beginning 0))
|
||||
(label (or (org-match-string-no-properties 2)
|
||||
(org-match-string-no-properties 3)
|
||||
;; Anonymous footnotes don't have labels
|
||||
(and (match-string 1)
|
||||
(concat "fn:" (org-match-string-no-properties 1)))))
|
||||
;; Inline footnotes don't end at (match-end 0) as
|
||||
;; `org-footnote-re' stops just after the second colon.
|
||||
;; Find the real ending with `scan-sexps', so Org doesn't
|
||||
;; get fooled by unrelated closing square brackets.
|
||||
(end (ignore-errors (scan-sexps beg 1))))
|
||||
;; Point is really at a reference if it's located before true
|
||||
;; ending of the footnote.
|
||||
(when (and end (< (point) end)
|
||||
;; Verify match isn't a part of a link.
|
||||
(not (save-excursion
|
||||
(goto-char beg)
|
||||
(let ((linkp
|
||||
(save-match-data
|
||||
(org-in-regexp org-bracket-link-regexp))))
|
||||
(and linkp (< (point) (cdr linkp))))))
|
||||
;; Verify point doesn't belong to a LaTeX macro.
|
||||
(not (org-inside-latex-macro-p)))
|
||||
(list label beg end
|
||||
;; Definition: ensure this is an inline footnote first.
|
||||
(and (or (not label) (match-string 1))
|
||||
(org-trim (buffer-substring-no-properties
|
||||
(match-end 0) (1- end)))))))))
|
||||
|
||||
(defun org-footnote-at-definition-p ()
|
||||
"Is point within a footnote definition?
|
||||
|
||||
This matches only pure definitions like [1] or [fn:name] at the
|
||||
beginning of a line. It does not match references like
|
||||
\[fn:name:definition], where the footnote text is included and
|
||||
defined locally.
|
||||
|
||||
The return value will be nil if not at a footnote definition, and
|
||||
a list with label, start, end and definition of the footnote
|
||||
otherwise."
|
||||
(when (save-excursion (beginning-of-line) (org-footnote-in-valid-context-p))
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
;; Footnotes definitions are separated by new headlines, another
|
||||
;; footnote definition or 2 blank lines.
|
||||
(let ((lim (save-excursion
|
||||
(re-search-backward
|
||||
(concat org-outline-regexp-bol
|
||||
"\\|^\\([ \t]*\n\\)\\{2,\\}") nil t))))
|
||||
(when (re-search-backward org-footnote-definition-re lim t)
|
||||
(let ((label (org-match-string-no-properties 1))
|
||||
(beg (match-beginning 0))
|
||||
(beg-def (match-end 0))
|
||||
;; In message-mode, do not search after signature.
|
||||
(end (let ((bound (and (derived-mode-p 'message-mode)
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(re-search-backward
|
||||
message-signature-separator nil t)))))
|
||||
(if (progn
|
||||
(end-of-line)
|
||||
(re-search-forward
|
||||
(concat org-outline-regexp-bol "\\|"
|
||||
org-footnote-definition-re "\\|"
|
||||
"^\\([ \t]*\n\\)\\{2,\\}") bound 'move))
|
||||
(match-beginning 0)
|
||||
(point)))))
|
||||
(list label beg end
|
||||
(org-trim (buffer-substring-no-properties beg-def end)))))))))
|
||||
|
||||
(defun org-footnote-get-next-reference (&optional label backward limit)
|
||||
"Return complete reference of the next footnote.
|
||||
|
||||
If LABEL is provided, get the next reference of that footnote. If
|
||||
BACKWARD is non-nil, find previous reference instead. LIMIT is
|
||||
the buffer position bounding the search.
|
||||
|
||||
Return value is a list like those provided by `org-footnote-at-reference-p'.
|
||||
If no footnote is found, return nil."
|
||||
(save-excursion
|
||||
(let* ((label-fmt (if label (format "\\[%s[]:]" label) org-footnote-re)))
|
||||
(catch 'exit
|
||||
(while t
|
||||
(unless (funcall (if backward #'re-search-backward #'re-search-forward)
|
||||
label-fmt limit t)
|
||||
(throw 'exit nil))
|
||||
(unless backward (backward-char))
|
||||
(let ((ref (org-footnote-at-reference-p)))
|
||||
(when ref (throw 'exit ref))))))))
|
||||
|
||||
(defun org-footnote-next-reference-or-definition (limit)
|
||||
"Move point to next footnote reference or definition.
|
||||
|
||||
LIMIT is the buffer position bounding the search.
|
||||
|
||||
Return value is a list like those provided by
|
||||
`org-footnote-at-reference-p' or `org-footnote-at-definition-p'.
|
||||
If no footnote is found, return nil."
|
||||
(let* (ref (origin (point)))
|
||||
(catch 'exit
|
||||
(while t
|
||||
(unless (re-search-forward org-footnote-re limit t)
|
||||
(goto-char origin)
|
||||
(throw 'exit nil))
|
||||
;; Beware: with [1]-like footnotes point will be just after
|
||||
;; the closing square bracket.
|
||||
(backward-char)
|
||||
(cond
|
||||
((setq ref (org-footnote-at-reference-p))
|
||||
(throw 'exit ref))
|
||||
;; Definition: also grab the last square bracket, only
|
||||
;; matched in `org-footnote-re' for [1]-like footnotes.
|
||||
((save-match-data (org-footnote-at-definition-p))
|
||||
(let ((end (match-end 0)))
|
||||
(throw 'exit
|
||||
(list nil (match-beginning 0)
|
||||
(if (eq (char-before end) 93) end (1+ end)))))))))))
|
||||
|
||||
(defun org-footnote-get-definition (label)
|
||||
"Return label, boundaries and definition of the footnote LABEL."
|
||||
(let* ((label (regexp-quote (org-footnote-normalize-label label)))
|
||||
(re (format "^\\[%s\\]\\|.\\[%s:" label label)))
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
(catch 'found
|
||||
(while (re-search-forward re nil t)
|
||||
(let* ((datum (progn (backward-char) (org-element-context)))
|
||||
(type (org-element-type datum)))
|
||||
(when (memq type '(footnote-definition footnote-reference))
|
||||
(throw 'found
|
||||
(list
|
||||
label
|
||||
(org-element-property :begin datum)
|
||||
(org-element-property :end datum)
|
||||
(let ((cbeg (org-element-property :contents-begin datum)))
|
||||
(if (not cbeg) ""
|
||||
(replace-regexp-in-string
|
||||
"[ \t\n]*\\'"
|
||||
""
|
||||
(buffer-substring-no-properties
|
||||
cbeg
|
||||
(org-element-property :contents-end datum))))))))))
|
||||
nil))))
|
||||
|
||||
(defun org-footnote-goto-definition (label &optional location)
|
||||
"Move point to the definition of the footnote LABEL.
|
||||
|
||||
LOCATION, when non-nil specifies the buffer position of the
|
||||
definition.
|
||||
|
||||
Throw an error if there is no definition or if it cannot be
|
||||
reached from current narrowed part of buffer. Return a non-nil
|
||||
value if point was successfully moved."
|
||||
(interactive "sLabel: ")
|
||||
(let ((def-start (or location (nth 1 (org-footnote-get-definition label)))))
|
||||
(cond
|
||||
((not def-start)
|
||||
(user-error "Cannot find definition of footnote %s" label))
|
||||
((or (> def-start (point-max)) (< def-start (point-min)))
|
||||
(user-error "Definition is outside narrowed part of buffer")))
|
||||
(org-mark-ring-push)
|
||||
(goto-char def-start)
|
||||
(looking-at (format "\\[%s[]:] ?" label))
|
||||
(goto-char (match-end 0))
|
||||
(org-show-context 'link-search)
|
||||
(when (derived-mode-p 'org-mode)
|
||||
(message "%s" (substitute-command-keys
|
||||
"Edit definition and go back with \
|
||||
`\\[org-mark-ring-goto]' or, if unique, with `\\[org-ctrl-c-ctrl-c]'.")))
|
||||
t))
|
||||
|
||||
(defun org-footnote-goto-previous-reference (label)
|
||||
"Find the first closest (to point) reference of footnote with label LABEL."
|
||||
(interactive "sLabel: ")
|
||||
(org-mark-ring-push)
|
||||
(let* ((label (org-footnote-normalize-label label)) ref)
|
||||
(save-excursion
|
||||
(setq ref (or (org-footnote-get-next-reference label t)
|
||||
(org-footnote-get-next-reference label)
|
||||
(save-restriction
|
||||
(widen)
|
||||
(or
|
||||
(org-footnote-get-next-reference label t)
|
||||
(org-footnote-get-next-reference label))))))
|
||||
(if (not ref)
|
||||
(error "Cannot find reference of footnote %s" label)
|
||||
(goto-char (nth 1 ref))
|
||||
(org-show-context 'link-search))))
|
||||
|
||||
(defun org-footnote-normalize-label (label)
|
||||
"Return LABEL as an appropriate string."
|
||||
(cond
|
||||
((numberp label) (number-to-string label))
|
||||
((equal "" label) nil)
|
||||
((not (string-match "^[0-9]+$\\|^fn:" label))
|
||||
(concat "fn:" label))
|
||||
(t label)))
|
||||
|
||||
(defun org-footnote-all-labels (&optional with-defs)
|
||||
"Return list with all defined foot labels used in the buffer.
|
||||
|
||||
If WITH-DEFS is non-nil, also associate the definition to each
|
||||
label. The function will then return an alist whose key is label
|
||||
and value definition."
|
||||
(let* (rtn
|
||||
(push-to-rtn
|
||||
(function
|
||||
;; Depending on WITH-DEFS, store label or (label . def) of
|
||||
;; footnote reference/definition given as argument in RTN.
|
||||
(lambda (el)
|
||||
(let ((lbl (car el)))
|
||||
(push (if with-defs (cons lbl (nth 3 el)) lbl) rtn))))))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
;; Find all labels found in definitions.
|
||||
(goto-char (point-min))
|
||||
(let (def)
|
||||
(while (re-search-forward org-footnote-definition-re nil t)
|
||||
(when (setq def (org-footnote-at-definition-p))
|
||||
(funcall push-to-rtn def))))
|
||||
;; Find all labels found in references.
|
||||
(goto-char (point-min))
|
||||
(let (ref)
|
||||
(while (setq ref (org-footnote-get-next-reference))
|
||||
(goto-char (nth 2 ref))
|
||||
(and (car ref) ; ignore anonymous footnotes
|
||||
(not (funcall (if with-defs #'assoc #'member) (car ref) rtn))
|
||||
(funcall push-to-rtn ref))))))
|
||||
rtn))
|
||||
|
||||
(defun org-footnote-unique-label (&optional current)
|
||||
"Return a new unique footnote label.
|
||||
|
||||
The function returns the first \"fn:N\" or \"N\" label that is
|
||||
currently not used.
|
||||
|
||||
Optional argument CURRENT is the list of labels active in the
|
||||
buffer."
|
||||
(unless current (setq current (org-footnote-all-labels)))
|
||||
(let ((fmt (if (eq org-footnote-auto-label 'plain) "%d" "fn:%d"))
|
||||
(cnt 1))
|
||||
(while (member (format fmt cnt) current)
|
||||
(incf cnt))
|
||||
(format fmt cnt)))
|
||||
|
||||
(defun org-footnote--allow-reference-p ()
|
||||
"Non-nil when a footnote reference can be inserted at point."
|
||||
;; XXX: This is similar to `org-footnote-in-valid-context-p' but
|
||||
;; more accurate and usually faster, except in some corner cases.
|
||||
;; It may replace it after doing proper benchmarks as it would be
|
||||
;; used in fontification.
|
||||
(unless (bolp)
|
||||
(let* ((context (org-element-context))
|
||||
(type (org-element-type context)))
|
||||
(cond
|
||||
;; No footnote reference in attributes.
|
||||
((let ((post (org-element-property :post-affiliated context)))
|
||||
(and post (< (point) post)))
|
||||
nil)
|
||||
;; Paragraphs and blank lines at top of document are fine.
|
||||
((memq type '(nil paragraph)))
|
||||
;; So are contents of verse blocks.
|
||||
((eq type 'verse-block)
|
||||
(and (>= (point) (org-element-property :contents-begin context))
|
||||
(< (point) (org-element-property :contents-end context))))
|
||||
;; In an headline or inlinetask, point must be either on the
|
||||
;; heading itself or on the blank lines below.
|
||||
((memq type '(headline inlinetask))
|
||||
(or (not (org-at-heading-p))
|
||||
(and (save-excursion (beginning-of-line)
|
||||
(and (let ((case-fold-search t))
|
||||
(not (looking-at "\\*+ END[ \t]*$")))
|
||||
(looking-at org-complex-heading-regexp)))
|
||||
(match-beginning 4)
|
||||
(>= (point) (match-beginning 4))
|
||||
(or (not (match-beginning 5))
|
||||
(< (point) (match-beginning 5))))))
|
||||
;; White spaces after an object or blank lines after an element
|
||||
;; are OK.
|
||||
((>= (point)
|
||||
(save-excursion (goto-char (org-element-property :end context))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(if (memq type org-element-all-objects) (point)
|
||||
(1+ (line-beginning-position 2))))))
|
||||
;; Other elements are invalid.
|
||||
((memq type org-element-all-elements) nil)
|
||||
;; Just before object is fine.
|
||||
((= (point) (org-element-property :begin context)))
|
||||
;; Within recursive object too, but not in a link.
|
||||
((eq type 'link) nil)
|
||||
((let ((cbeg (org-element-property :contents-begin context))
|
||||
(cend (org-element-property :contents-end context)))
|
||||
(and cbeg (>= (point) cbeg) (<= (point) cend))))))))
|
||||
|
||||
(defun org-footnote-new ()
|
||||
"Insert a new footnote.
|
||||
This command prompts for a label. If this is a label referencing an
|
||||
existing label, only insert the label. If the footnote label is empty
|
||||
or new, let the user edit the definition of the footnote."
|
||||
(interactive)
|
||||
(unless (org-footnote--allow-reference-p)
|
||||
(user-error "Cannot insert a footnote here"))
|
||||
(let* ((all (org-footnote-all-labels))
|
||||
(label
|
||||
(org-footnote-normalize-label
|
||||
(if (eq org-footnote-auto-label 'random)
|
||||
(format "fn:%x" (random most-positive-fixnum))
|
||||
(let ((propose (org-footnote-unique-label all)))
|
||||
(if (memq org-footnote-auto-label '(t plain)) propose
|
||||
(org-icompleting-read
|
||||
"Label (leave empty for anonymous): "
|
||||
(mapcar #'list all) nil nil
|
||||
(and (eq org-footnote-auto-label 'confirm) propose))))))))
|
||||
(cond ((not label)
|
||||
(insert "[fn::]")
|
||||
(backward-char 1))
|
||||
((member label all)
|
||||
(insert "[" label "]")
|
||||
(message "New reference to existing note"))
|
||||
(org-footnote-define-inline
|
||||
(insert "[" label ":]")
|
||||
(backward-char 1)
|
||||
(org-footnote-auto-adjust-maybe))
|
||||
(t
|
||||
(insert "[" label "]")
|
||||
(let ((p (org-footnote-create-definition label)))
|
||||
;; `org-footnote-goto-definition' needs to be called
|
||||
;; after `org-footnote-auto-adjust-maybe'. Otherwise
|
||||
;; both label and location of the definition are lost.
|
||||
;; On the contrary, it needs to be called before
|
||||
;; `org-edit-footnote-reference' so that the remote
|
||||
;; editing buffer can display the correct label.
|
||||
(if (ignore-errors (org-footnote-goto-definition label p))
|
||||
(org-footnote-auto-adjust-maybe)
|
||||
;; Definition was created outside current scope: edit
|
||||
;; it remotely.
|
||||
(org-footnote-auto-adjust-maybe)
|
||||
(org-edit-footnote-reference)))))))
|
||||
|
||||
(defvar org-blank-before-new-entry) ; Silence byte-compiler.
|
||||
(defun org-footnote-create-definition (label)
|
||||
"Start the definition of a footnote with label LABEL.
|
||||
Return buffer position at the beginning of the definition. In an
|
||||
Org buffer, this function doesn't move point."
|
||||
(let ((label (org-footnote-normalize-label label))
|
||||
electric-indent-mode) ; Prevent wrong indentation.
|
||||
(cond
|
||||
;; In an Org document.
|
||||
((derived-mode-p 'org-mode)
|
||||
;; If `org-footnote-section' is defined, find it, or create it
|
||||
;; at the end of the buffer.
|
||||
(org-with-wide-buffer
|
||||
(cond
|
||||
((not org-footnote-section)
|
||||
(org-footnote--goto-local-insertion-point))
|
||||
((save-excursion
|
||||
(goto-char (point-min))
|
||||
(re-search-forward
|
||||
(concat "^\\*+[ \t]+" (regexp-quote org-footnote-section) "[ \t]*$")
|
||||
nil t))
|
||||
(goto-char (match-end 0))
|
||||
(forward-line)
|
||||
(unless (bolp) (insert "\n")))
|
||||
(t
|
||||
(goto-char (point-max))
|
||||
(unless (bolp) (insert "\n"))
|
||||
;; Insert new section. Separate it from the previous one
|
||||
;; with a blank line, unless `org-blank-before-new-entry'
|
||||
;; explicitly says no.
|
||||
(when (and (cdr (assq 'heading org-blank-before-new-entry))
|
||||
(zerop (save-excursion (org-back-over-empty-lines))))
|
||||
(insert "\n"))
|
||||
(insert "* " org-footnote-section "\n")))
|
||||
(when (zerop (org-back-over-empty-lines)) (insert "\n"))
|
||||
(insert "[" label "] \n")
|
||||
(line-beginning-position 0)))
|
||||
(t
|
||||
;; In a non-Org file. Search for footnote tag, or create it if
|
||||
;; specified (at the end of buffer, or before signature if in
|
||||
;; Message mode). Set point after any definition already there.
|
||||
(let ((tag (and org-footnote-tag-for-non-org-mode-files
|
||||
(concat "^" (regexp-quote
|
||||
org-footnote-tag-for-non-org-mode-files)
|
||||
"[ \t]*$")))
|
||||
(max (if (and (derived-mode-p 'message-mode)
|
||||
(goto-char (point-max))
|
||||
(re-search-backward
|
||||
message-signature-separator nil t))
|
||||
(progn
|
||||
;; Ensure one blank line separates last
|
||||
;; footnote from signature.
|
||||
(beginning-of-line)
|
||||
(open-line 2)
|
||||
(point-marker))
|
||||
(point-max-marker))))
|
||||
(set-marker-insertion-type max t)
|
||||
(goto-char max)
|
||||
;; Check if the footnote tag is defined but missing. In this
|
||||
;; case, insert it, before any footnote or one blank line
|
||||
;; after any previous text.
|
||||
(when (and tag (not (re-search-backward tag nil t)))
|
||||
(skip-chars-backward " \t\r\n")
|
||||
(while (re-search-backward org-footnote-definition-re nil t))
|
||||
(unless (bolp) (newline 2))
|
||||
(insert org-footnote-tag-for-non-org-mode-files "\n\n"))
|
||||
;; Remove superfluous white space and clear marker.
|
||||
(goto-char max)
|
||||
(skip-chars-backward " \t\r\n")
|
||||
(delete-region (point) max)
|
||||
(unless (bolp) (newline))
|
||||
(set-marker max nil))
|
||||
(when (zerop (org-back-over-empty-lines)) (insert "\n"))
|
||||
(insert "[" label "] \n")
|
||||
(backward-char)
|
||||
(line-beginning-position)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-footnote-action (&optional special)
|
||||
"Do the right thing for footnotes.
|
||||
|
||||
When at a footnote reference, jump to the definition.
|
||||
|
||||
When at a definition, jump to the references if they exist, offer
|
||||
to create them otherwise.
|
||||
|
||||
When neither at definition or reference, create a new footnote,
|
||||
interactively if possible.
|
||||
|
||||
With prefix arg SPECIAL, or when no footnote can be created,
|
||||
offer additional commands in a menu."
|
||||
(interactive "P")
|
||||
(let* ((context (and (not special) (org-element-context)))
|
||||
(type (org-element-type context)))
|
||||
(cond
|
||||
;; On white space after element, insert a new footnote.
|
||||
((and context
|
||||
(> (point)
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :end context))
|
||||
(skip-chars-backward " \t")
|
||||
(point))))
|
||||
(org-footnote-new))
|
||||
((eq type 'footnote-reference)
|
||||
(let ((label (org-element-property :label context)))
|
||||
(cond
|
||||
;; Anonymous footnote: move point at the beginning of its
|
||||
;; definition.
|
||||
((not label)
|
||||
(goto-char (org-element-property :contents-begin context)))
|
||||
;; Check if a definition exists: then move to it.
|
||||
((let ((p (nth 1 (org-footnote-get-definition label))))
|
||||
(when p (org-footnote-goto-definition label p))))
|
||||
;; No definition exists: offer to create it.
|
||||
((yes-or-no-p (format "No definition for %s. Create one? " label))
|
||||
(let ((p (org-footnote-create-definition label)))
|
||||
(or (ignore-errors (org-footnote-goto-definition label p))
|
||||
;; Since definition was created outside current scope,
|
||||
;; edit it remotely.
|
||||
(org-edit-footnote-reference)))))))
|
||||
((eq type 'footnote-definition)
|
||||
(org-footnote-goto-previous-reference
|
||||
(org-element-property :label context)))
|
||||
((or special (not (org-footnote--allow-reference-p)))
|
||||
(message "Footnotes: [s]ort | [r]enumber fn:N | [S]=r+s | \
|
||||
->[n]umeric | [d]elete")
|
||||
(let ((c (read-char-exclusive)))
|
||||
(cond
|
||||
((eq c ?s) (org-footnote-normalize 'sort))
|
||||
((eq c ?r) (org-footnote-renumber-fn:N))
|
||||
((eq c ?S)
|
||||
(org-footnote-renumber-fn:N)
|
||||
(org-footnote-normalize 'sort))
|
||||
((eq c ?n) (org-footnote-normalize))
|
||||
((eq c ?d) (org-footnote-delete))
|
||||
(t (error "No such footnote command %c" c)))))
|
||||
(t (org-footnote-new)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-footnote-normalize (&optional sort-only)
|
||||
"Collect the footnotes in various formats and normalize them.
|
||||
|
||||
This finds the different sorts of footnotes allowed in Org, and
|
||||
normalizes them to the usual [N] format.
|
||||
|
||||
When SORT-ONLY is set, only sort the footnote definitions into the
|
||||
referenced sequence."
|
||||
;; This is based on Paul's function, but rewritten.
|
||||
;;
|
||||
;; Re-create `org-with-limited-levels', but not limited to Org
|
||||
;; buffers.
|
||||
(let* ((limit-level
|
||||
(and (boundp 'org-inlinetask-min-level)
|
||||
org-inlinetask-min-level
|
||||
(1- org-inlinetask-min-level)))
|
||||
(nstars (and limit-level
|
||||
(if org-odd-levels-only (1- (* limit-level 2))
|
||||
limit-level)))
|
||||
(org-outline-regexp
|
||||
(concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ ")))
|
||||
(count 0)
|
||||
ins-point ref ref-table)
|
||||
(org-with-wide-buffer
|
||||
;; 1. Find every footnote reference, extract the definition, and
|
||||
;; collect that data in REF-TABLE. If SORT-ONLY is nil, also
|
||||
;; normalize references.
|
||||
(goto-char (point-min))
|
||||
(while (setq ref (org-footnote-get-next-reference))
|
||||
(let* ((lbl (car ref))
|
||||
(pos (nth 1 ref))
|
||||
;; When footnote isn't anonymous, check if it's label
|
||||
;; (REF) is already stored in REF-TABLE. In that case,
|
||||
;; extract number used to identify it (MARKER). If
|
||||
;; footnote is unknown, increment the global counter
|
||||
;; (COUNT) to create an unused identifier.
|
||||
(a (and lbl (assoc lbl ref-table)))
|
||||
(marker (or (nth 1 a) (incf count)))
|
||||
;; Is the reference inline or pointing to an inline
|
||||
;; footnote?
|
||||
(inlinep (or (stringp (nth 3 ref)) (nth 3 a))))
|
||||
;; Replace footnote reference with [MARKER]. Maybe fill
|
||||
;; paragraph once done. If SORT-ONLY is non-nil, only move
|
||||
;; to the end of reference found to avoid matching it twice.
|
||||
(if sort-only (goto-char (nth 2 ref))
|
||||
(delete-region (nth 1 ref) (nth 2 ref))
|
||||
(goto-char (nth 1 ref))
|
||||
(insert (format "[%d]" marker))
|
||||
(and inlinep
|
||||
org-footnote-fill-after-inline-note-extraction
|
||||
(org-fill-paragraph)))
|
||||
;; Add label (REF), identifier (MARKER), definition (DEF)
|
||||
;; type (INLINEP) and position (POS) to REF-TABLE if data was
|
||||
;; unknown.
|
||||
(unless a
|
||||
(let ((def (or (nth 3 ref) ; Inline definition.
|
||||
(nth 3 (org-footnote-get-definition lbl)))))
|
||||
(push (list lbl marker def
|
||||
;; Reference beginning position is a marker
|
||||
;; to preserve it during further buffer
|
||||
;; modifications.
|
||||
inlinep (copy-marker pos)) ref-table)))))
|
||||
;; 2. Find and remove the footnote section, if any. Also
|
||||
;; determine where footnotes shall be inserted (INS-POINT).
|
||||
(cond
|
||||
((and org-footnote-section (derived-mode-p 'org-mode))
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward
|
||||
(concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
|
||||
"[ \t]*$") nil t)
|
||||
(delete-region (match-beginning 0) (org-end-of-subtree t t)))
|
||||
;; A new footnote section is inserted by default at the end of
|
||||
;; the buffer.
|
||||
(goto-char (point-max))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(forward-line)
|
||||
(unless (bolp) (newline)))
|
||||
;; No footnote section set: Footnotes will be added at the end
|
||||
;; of the section containing their first reference.
|
||||
((derived-mode-p 'org-mode))
|
||||
(t
|
||||
;; Remove any left-over tag in the buffer, if one is set up.
|
||||
(when org-footnote-tag-for-non-org-mode-files
|
||||
(let ((tag (concat "^" (regexp-quote
|
||||
org-footnote-tag-for-non-org-mode-files)
|
||||
"[ \t]*$")))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward tag nil t)
|
||||
(replace-match "")
|
||||
(delete-region (point) (progn (forward-line) (point))))))
|
||||
;; In Message mode, ensure footnotes are inserted before the
|
||||
;; signature.
|
||||
(if (and (derived-mode-p 'message-mode)
|
||||
(goto-char (point-max))
|
||||
(re-search-backward message-signature-separator nil t))
|
||||
(beginning-of-line)
|
||||
(goto-char (point-max)))))
|
||||
(setq ins-point (point-marker))
|
||||
;; 3. Clean-up REF-TABLE.
|
||||
(setq ref-table
|
||||
(delq nil
|
||||
(mapcar
|
||||
(lambda (x)
|
||||
(cond
|
||||
;; When only sorting, ignore inline footnotes.
|
||||
;; Also clear position marker.
|
||||
((and sort-only (nth 3 x))
|
||||
(set-marker (nth 4 x) nil) nil)
|
||||
;; No definition available: provide one.
|
||||
((not (nth 2 x))
|
||||
(append
|
||||
(list (car x) (nth 1 x)
|
||||
(format "DEFINITION NOT FOUND: %s" (car x)))
|
||||
(nthcdr 3 x)))
|
||||
(t x)))
|
||||
ref-table)))
|
||||
(setq ref-table (nreverse ref-table))
|
||||
;; 4. Remove left-over definitions in the buffer.
|
||||
(dolist (x ref-table)
|
||||
(unless (nth 3 x) (org-footnote-delete-definitions (car x))))
|
||||
;; 5. Insert the footnotes again in the buffer, at the
|
||||
;; appropriate spot.
|
||||
(goto-char ins-point)
|
||||
(cond
|
||||
;; No footnote: exit.
|
||||
((not ref-table))
|
||||
;; Cases when footnotes should be inserted in one place.
|
||||
((or (not (derived-mode-p 'org-mode)) org-footnote-section)
|
||||
;; Insert again the section title, if any. Ensure that title,
|
||||
;; or the subsequent footnotes, will be separated by a blank
|
||||
;; lines from the rest of the document. In an Org buffer,
|
||||
;; separate section with a blank line, unless explicitly stated
|
||||
;; in `org-blank-before-new-entry'.
|
||||
(if (not (derived-mode-p 'org-mode))
|
||||
(progn (skip-chars-backward " \t\n\r")
|
||||
(delete-region (point) ins-point)
|
||||
(unless (bolp) (newline))
|
||||
(when org-footnote-tag-for-non-org-mode-files
|
||||
(insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
|
||||
(when (and (cdr (assq 'heading org-blank-before-new-entry))
|
||||
(zerop (save-excursion (org-back-over-empty-lines))))
|
||||
(insert "\n"))
|
||||
(insert "* " org-footnote-section "\n"))
|
||||
(set-marker ins-point nil)
|
||||
;; Insert the footnotes, separated by a blank line.
|
||||
(insert
|
||||
(mapconcat
|
||||
(lambda (x)
|
||||
;; Clean markers.
|
||||
(set-marker (nth 4 x) nil)
|
||||
(format "\n[%s] %s" (nth (if sort-only 0 1) x) (nth 2 x)))
|
||||
ref-table "\n"))
|
||||
(unless (eobp) (insert "\n\n")))
|
||||
;; Each footnote definition has to be inserted at the end of the
|
||||
;; section where its first reference belongs.
|
||||
(t
|
||||
(dolist (x ref-table)
|
||||
(let ((pos (nth 4 x)))
|
||||
(goto-char pos)
|
||||
;; Clean marker.
|
||||
(set-marker pos nil))
|
||||
(org-footnote--goto-local-insertion-point)
|
||||
(insert (format "\n[%s] %s\n"
|
||||
(nth (if sort-only 0 1) x)
|
||||
(nth 2 x)))))))))
|
||||
|
||||
(defun org-footnote--goto-local-insertion-point ()
|
||||
"Find insertion point for footnote, just before next outline heading.
|
||||
Assume insertion point is within currently accessible part of the buffer."
|
||||
(org-with-limited-levels (outline-next-heading))
|
||||
;; Skip file local variables. See `modify-file-local-variable'.
|
||||
(when (eobp)
|
||||
(let ((case-fold-search t))
|
||||
(re-search-backward "^[ \t]*# +Local Variables:"
|
||||
(max (- (point-max) 3000) (point-min))
|
||||
t)))
|
||||
(skip-chars-backward " \t\n")
|
||||
(forward-line)
|
||||
(unless (bolp) (insert "\n")))
|
||||
|
||||
(defun org-footnote-delete-references (label)
|
||||
"Delete every reference to footnote LABEL.
|
||||
Return the number of footnotes removed."
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let (ref (nref 0))
|
||||
(while (setq ref (org-footnote-get-next-reference label))
|
||||
(goto-char (nth 1 ref))
|
||||
(delete-region (nth 1 ref) (nth 2 ref))
|
||||
(incf nref))
|
||||
nref)))
|
||||
|
||||
(defun org-footnote-delete-definitions (label)
|
||||
"Delete every definition of the footnote LABEL.
|
||||
Return the number of footnotes removed."
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let ((def-re (concat "^\\[" (regexp-quote label) "\\]"))
|
||||
(ndef 0))
|
||||
(while (re-search-forward def-re nil t)
|
||||
(let ((full-def (org-footnote-at-definition-p)))
|
||||
(when full-def
|
||||
;; Remove the footnote, and all blank lines before it.
|
||||
(goto-char (nth 1 full-def))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(unless (bolp) (forward-line))
|
||||
(delete-region (point) (nth 2 full-def))
|
||||
(incf ndef))))
|
||||
ndef)))
|
||||
|
||||
(defun org-footnote-delete (&optional label)
|
||||
"Delete the footnote at point.
|
||||
This will remove the definition (even multiple definitions if they exist)
|
||||
and all references of a footnote label.
|
||||
|
||||
If LABEL is non-nil, delete that footnote instead."
|
||||
(catch 'done
|
||||
(let* ((nref 0) (ndef 0) x
|
||||
;; 1. Determine LABEL of footnote at point.
|
||||
(label (cond
|
||||
;; LABEL is provided as argument.
|
||||
(label)
|
||||
;; Footnote reference at point. If the footnote is
|
||||
;; anonymous, delete it and exit instead.
|
||||
((setq x (org-footnote-at-reference-p))
|
||||
(or (car x)
|
||||
(progn
|
||||
(delete-region (nth 1 x) (nth 2 x))
|
||||
(message "Anonymous footnote removed")
|
||||
(throw 'done t))))
|
||||
;; Footnote definition at point.
|
||||
((setq x (org-footnote-at-definition-p))
|
||||
(car x))
|
||||
(t (error "Don't know which footnote to remove")))))
|
||||
;; 2. Now that LABEL is non-nil, find every reference and every
|
||||
;; definition, and delete them.
|
||||
(setq nref (org-footnote-delete-references label)
|
||||
ndef (org-footnote-delete-definitions label))
|
||||
;; 3. Verify consistency of footnotes and notify user.
|
||||
(org-footnote-auto-adjust-maybe)
|
||||
(message "%d definition(s) of and %d reference(s) of footnote %s removed"
|
||||
ndef nref label))))
|
||||
|
||||
(defun org-footnote-renumber-fn:N ()
|
||||
"Renumber the simple footnotes like fn:17 into a sequence in the document."
|
||||
(interactive)
|
||||
(let (map (n 0))
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "\\[fn:\\([0-9]+\\)[]:]" nil t)
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 0))
|
||||
;; Ensure match is a footnote reference or definition.
|
||||
(when (save-match-data (if (bolp)
|
||||
(org-footnote-at-definition-p)
|
||||
(org-footnote-at-reference-p)))
|
||||
(let ((new-val (or (cdr (assoc (match-string 1) map))
|
||||
(number-to-string (incf n)))))
|
||||
(unless (assoc (match-string 1) map)
|
||||
(push (cons (match-string 1) new-val) map))
|
||||
(replace-match new-val nil nil nil 1))))))))
|
||||
|
||||
(defun org-footnote-auto-adjust-maybe ()
|
||||
"Renumber and/or sort footnotes according to user settings."
|
||||
(when (memq org-footnote-auto-adjust '(t renumber))
|
||||
(org-footnote-renumber-fn:N))
|
||||
(when (memq org-footnote-auto-adjust '(t sort))
|
||||
(let ((label (car (org-footnote-at-definition-p))))
|
||||
(org-footnote-normalize 'sort)
|
||||
(when label
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward (concat "^\\[" (regexp-quote label) "\\]")
|
||||
nil t)
|
||||
(progn (insert " ")
|
||||
(just-one-space)))))))
|
||||
|
||||
(provide 'org-footnote)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-footnote.el ends here
|
307
elpa/org-20160919/org-gnus.el
Normal file
307
elpa/org-20160919/org-gnus.el
Normal file
@ -0,0 +1,307 @@
|
||||
;;; org-gnus.el --- Support for links to Gnus groups and messages from within Org-mode
|
||||
|
||||
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Tassilo Horn <tassilo at member dot fsf dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file implements links to Gnus groups and messages from within Org-mode.
|
||||
;; Org-mode loads this module by default - if this is not what you want,
|
||||
;; configure the variable `org-modules'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'gnus-util)
|
||||
(eval-when-compile (require 'gnus-sum))
|
||||
|
||||
;; Declare external functions and variables
|
||||
|
||||
(declare-function message-fetch-field "message" (header &optional not-all))
|
||||
(declare-function message-narrow-to-head-1 "message" nil)
|
||||
(declare-function gnus-summary-last-subject "gnus-sum" nil)
|
||||
(declare-function nnvirtual-map-article "nnvirtual" (article))
|
||||
|
||||
;; Customization variables
|
||||
|
||||
(org-defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links)
|
||||
|
||||
(defcustom org-gnus-prefer-web-links nil
|
||||
"If non-nil, `org-store-link' creates web links to Google groups or Gmane.
|
||||
When nil, Gnus will be used for such links.
|
||||
Using a prefix arg to the command \\[org-store-link] (`org-store-link')
|
||||
negates this setting for the duration of the command."
|
||||
:group 'org-link-store
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-gnus-nnimap-query-article-no-from-file nil
|
||||
"If non-nil, `org-gnus-follow-link' will try to translate
|
||||
Message-Ids to article numbers by querying the .overview file.
|
||||
Normally, this translation is done by querying the IMAP server,
|
||||
which is usually very fast. Unfortunately, some (maybe badly
|
||||
configured) IMAP servers don't support this operation quickly.
|
||||
So if following a link to a Gnus article takes ages, try setting
|
||||
this variable to t."
|
||||
:group 'org-link-store
|
||||
:version "24.1"
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-gnus-no-server nil
|
||||
"Should Gnus be started using `gnus-no-server'?"
|
||||
:group 'org-gnus
|
||||
:version "24.4"
|
||||
:package-version '(Org . "8.0")
|
||||
:type 'boolean)
|
||||
|
||||
;; Install the link type
|
||||
(org-add-link-type "gnus" 'org-gnus-open)
|
||||
(add-hook 'org-store-link-functions 'org-gnus-store-link)
|
||||
|
||||
;; Implementation
|
||||
|
||||
(defun org-gnus-nnimap-cached-article-number (group server message-id)
|
||||
"Return cached article number (uid) of message in GROUP on SERVER.
|
||||
MESSAGE-ID is the message-id header field that identifies the
|
||||
message. If the uid is not cached, return nil."
|
||||
(with-temp-buffer
|
||||
(let ((nov (and (fboundp 'nnimap-group-overview-filename)
|
||||
;; nnimap-group-overview-filename was removed from
|
||||
;; Gnus in September 2010, and therefore should
|
||||
;; only be present in Emacs 23.1.
|
||||
(nnimap-group-overview-filename group server))))
|
||||
(when (and nov (file-exists-p nov))
|
||||
(mm-insert-file-contents nov)
|
||||
(set-buffer-modified-p nil)
|
||||
(goto-char (point-min))
|
||||
(catch 'found
|
||||
(while (search-forward message-id nil t)
|
||||
(let ((hdr (split-string (thing-at-point 'line) "\t")))
|
||||
(if (string= (nth 4 hdr) message-id)
|
||||
(throw 'found (nth 0 hdr))))))))))
|
||||
|
||||
(defun org-gnus-group-link (group)
|
||||
"Create a link to the Gnus group GROUP.
|
||||
If GROUP is a newsgroup and `org-gnus-prefer-web-links' is
|
||||
non-nil, create a link to groups.google.com or gmane.org.
|
||||
Otherwise create a link to the group inside Gnus.
|
||||
|
||||
If `org-store-link' was called with a prefix arg the meaning of
|
||||
`org-gnus-prefer-web-links' is reversed."
|
||||
(let ((unprefixed-group (replace-regexp-in-string "^[^:]+:" "" group)))
|
||||
(if (and (string-match "^nntp" group) ;; Only for nntp groups
|
||||
(org-xor current-prefix-arg
|
||||
org-gnus-prefer-web-links))
|
||||
(concat (if (string-match "gmane" unprefixed-group)
|
||||
"http://news.gmane.org/"
|
||||
"http://groups.google.com/group/")
|
||||
unprefixed-group)
|
||||
(concat "gnus:" group))))
|
||||
|
||||
(defun org-gnus-article-link (group newsgroups message-id x-no-archive)
|
||||
"Create a link to a Gnus article.
|
||||
The article is specified by its MESSAGE-ID. Additional
|
||||
parameters are the Gnus GROUP, the NEWSGROUPS the article was
|
||||
posted to and the X-NO-ARCHIVE header value of that article.
|
||||
|
||||
If GROUP is a newsgroup and `org-gnus-prefer-web-links' is
|
||||
non-nil, create a link to groups.google.com or gmane.org.
|
||||
Otherwise create a link to the article inside Gnus.
|
||||
|
||||
If `org-store-link' was called with a prefix arg the meaning of
|
||||
`org-gnus-prefer-web-links' is reversed."
|
||||
(if (and (org-xor current-prefix-arg org-gnus-prefer-web-links)
|
||||
newsgroups ;; Make web links only for nntp groups
|
||||
(not x-no-archive)) ;; and if X-No-Archive isn't set.
|
||||
(format (if (string-match "gmane\\." newsgroups)
|
||||
"http://mid.gmane.org/%s"
|
||||
"http://groups.google.com/groups/search?as_umsgid=%s")
|
||||
(org-fixup-message-id-for-http message-id))
|
||||
(concat "gnus:" group "#" message-id)))
|
||||
|
||||
(defun org-gnus-store-link ()
|
||||
"Store a link to a Gnus folder or message."
|
||||
(cond
|
||||
((eq major-mode 'gnus-group-mode)
|
||||
(let* ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
|
||||
(gnus-group-group-name)) ; version
|
||||
((fboundp 'gnus-group-name)
|
||||
(gnus-group-name))
|
||||
(t "???")))
|
||||
desc link)
|
||||
(when group
|
||||
(org-store-link-props :type "gnus" :group group)
|
||||
(setq desc (org-gnus-group-link group)
|
||||
link desc)
|
||||
(org-add-link-props :link link :description desc)
|
||||
link)))
|
||||
|
||||
((memq major-mode '(gnus-summary-mode gnus-article-mode))
|
||||
(let* ((group gnus-newsgroup-name)
|
||||
(header (with-current-buffer gnus-summary-buffer
|
||||
(gnus-summary-article-header)))
|
||||
(from (mail-header-from header))
|
||||
(message-id (org-remove-angle-brackets (mail-header-id header)))
|
||||
(date (org-trim (mail-header-date header)))
|
||||
(date-ts (and date
|
||||
(ignore-errors
|
||||
(format-time-string
|
||||
(org-time-stamp-format t)
|
||||
(date-to-time date)))))
|
||||
(date-ts-ia (and date
|
||||
(ignore-errors
|
||||
(format-time-string
|
||||
(org-time-stamp-format t t)
|
||||
(date-to-time date)))))
|
||||
(subject (copy-sequence (mail-header-subject header)))
|
||||
(to (cdr (assq 'To (mail-header-extra header))))
|
||||
newsgroups x-no-archive desc link)
|
||||
(when (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
|
||||
'nnvirtual)
|
||||
(setq group (car (nnvirtual-map-article
|
||||
(gnus-summary-article-number)))))
|
||||
;; Remove text properties of subject string to avoid Emacs bug
|
||||
;; #3506
|
||||
(set-text-properties 0 (length subject) nil subject)
|
||||
|
||||
;; Fetching an article is an expensive operation; newsgroup and
|
||||
;; x-no-archive are only needed for web links.
|
||||
(when (org-xor current-prefix-arg org-gnus-prefer-web-links)
|
||||
;; Make sure the original article buffer is up-to-date
|
||||
(save-window-excursion (gnus-summary-select-article))
|
||||
(setq to (or to (gnus-fetch-original-field "To"))
|
||||
newsgroups (gnus-fetch-original-field "Newsgroups")
|
||||
x-no-archive (gnus-fetch-original-field "x-no-archive")))
|
||||
(org-store-link-props :type "gnus" :from from :subject subject
|
||||
:message-id message-id :group group :to to)
|
||||
(when date
|
||||
(org-add-link-props :date date :date-timestamp date-ts
|
||||
:date-timestamp-inactive date-ts-ia))
|
||||
(setq desc (org-email-link-description)
|
||||
link (org-gnus-article-link
|
||||
group newsgroups message-id x-no-archive))
|
||||
(org-add-link-props :link link :description desc)
|
||||
link))
|
||||
((eq major-mode 'message-mode)
|
||||
(setq org-store-link-plist nil) ; reset
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(message-narrow-to-headers)
|
||||
(and (not (message-fetch-field "Message-ID"))
|
||||
(message-generate-headers '(Message-ID)))
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "^Message-ID: *.*$" nil t)
|
||||
(put-text-property (match-beginning 0) (match-end 0) 'message-deletable nil)
|
||||
(let ((gcc (car (last
|
||||
(message-unquote-tokens
|
||||
(message-tokenize-header (mail-fetch-field "gcc" nil t) " ,")))))
|
||||
(id (org-remove-angle-brackets (mail-fetch-field "Message-ID")))
|
||||
(to (mail-fetch-field "To"))
|
||||
(from (mail-fetch-field "From"))
|
||||
(subject (mail-fetch-field "Subject"))
|
||||
desc link
|
||||
newsgroup xarchive) ; those are always nil for gcc
|
||||
(and (not gcc)
|
||||
(error "Can not create link: No Gcc header found"))
|
||||
(org-store-link-props :type "gnus" :from from :subject subject
|
||||
:message-id id :group gcc :to to)
|
||||
(setq desc (org-email-link-description)
|
||||
link (org-gnus-article-link
|
||||
gcc newsgroup id xarchive))
|
||||
(org-add-link-props :link link :description desc)
|
||||
link))))))
|
||||
|
||||
(defun org-gnus-open-nntp (path)
|
||||
"Follow the nntp: link specified by PATH."
|
||||
(let* ((spec (split-string path "/"))
|
||||
(server (split-string (nth 2 spec) "@"))
|
||||
(group (nth 3 spec))
|
||||
(article (nth 4 spec)))
|
||||
(org-gnus-follow-link
|
||||
(format "nntp+%s:%s" (or (cdr server) (car server)) group)
|
||||
article)))
|
||||
|
||||
(defun org-gnus-open (path)
|
||||
"Follow the Gnus message or folder link specified by PATH."
|
||||
(let (group article)
|
||||
(if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
|
||||
(error "Error in Gnus link"))
|
||||
(setq group (match-string 1 path)
|
||||
article (match-string 3 path))
|
||||
(when group
|
||||
(setq group (org-no-properties group)))
|
||||
(when article
|
||||
(setq article (org-no-properties article)))
|
||||
(org-gnus-follow-link group article)))
|
||||
|
||||
(defun org-gnus-follow-link (&optional group article)
|
||||
"Follow a Gnus link to GROUP and ARTICLE."
|
||||
(require 'gnus)
|
||||
(funcall (cdr (assq 'gnus org-link-frame-setup)))
|
||||
(if gnus-other-frame-object (select-frame gnus-other-frame-object))
|
||||
(setq group (org-no-properties group))
|
||||
(setq article (org-no-properties article))
|
||||
(cond ((and group article)
|
||||
(gnus-activate-group group)
|
||||
(condition-case nil
|
||||
(let* ((method (gnus-find-method-for-group group))
|
||||
(backend (car method))
|
||||
(server (cadr method)))
|
||||
(cond
|
||||
((eq backend 'nndoc)
|
||||
(if (gnus-group-read-group t nil group)
|
||||
(gnus-summary-goto-article article nil t)
|
||||
(message "Couldn't follow gnus link. %s"
|
||||
"The summary couldn't be opened.")))
|
||||
(t
|
||||
(let ((articles 1)
|
||||
group-opened)
|
||||
(when (and (eq backend 'nnimap)
|
||||
org-gnus-nnimap-query-article-no-from-file)
|
||||
(setq article
|
||||
(or (org-gnus-nnimap-cached-article-number
|
||||
(nth 1 (split-string group ":"))
|
||||
server (concat "<" article ">")) article)))
|
||||
(while (and (not group-opened)
|
||||
;; stop on integer overflows
|
||||
(> articles 0))
|
||||
(setq group-opened (gnus-group-read-group
|
||||
articles t group)
|
||||
articles (if (< articles 16)
|
||||
(1+ articles)
|
||||
(* articles 2))))
|
||||
(if group-opened
|
||||
(gnus-summary-goto-article article nil t)
|
||||
(message "Couldn't follow gnus link. %s"
|
||||
"The summary couldn't be opened."))))))
|
||||
(quit (message "Couldn't follow gnus link. %s"
|
||||
"The linked group is empty."))))
|
||||
(group (gnus-group-jump-to-group group))))
|
||||
|
||||
(defun org-gnus-no-new-news ()
|
||||
"Like `\\[gnus]' but doesn't check for new news."
|
||||
(if (not (gnus-alive-p)) (if org-gnus-no-server (gnus-no-server) (gnus))))
|
||||
|
||||
(provide 'org-gnus)
|
||||
|
||||
|
||||
;;; org-gnus.el ends here
|
424
elpa/org-20160919/org-habit.el
Normal file
424
elpa/org-20160919/org-habit.el
Normal file
@ -0,0 +1,424 @@
|
||||
;;; org-habit.el --- The habit tracking code for Org-mode
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: John Wiegley <johnw at gnu dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file contains the habit tracking code for Org-mode
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'org-agenda)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defgroup org-habit nil
|
||||
"Options concerning habit tracking in Org-mode."
|
||||
:tag "Org Habit"
|
||||
:group 'org-progress)
|
||||
|
||||
(defcustom org-habit-graph-column 40
|
||||
"The absolute column at which to insert habit consistency graphs.
|
||||
Note that consistency graphs will overwrite anything else in the buffer."
|
||||
:group 'org-habit
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-habit-preceding-days 21
|
||||
"Number of days before today to appear in consistency graphs."
|
||||
:group 'org-habit
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-habit-following-days 7
|
||||
"Number of days after today to appear in consistency graphs."
|
||||
:group 'org-habit
|
||||
:type 'integer)
|
||||
|
||||
(defcustom org-habit-show-habits t
|
||||
"If non-nil, show habits in agenda buffers."
|
||||
:group 'org-habit
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-habit-show-habits-only-for-today t
|
||||
"If non-nil, only show habits on today's agenda, and not for future days.
|
||||
Note that even when shown for future days, the graph is always
|
||||
relative to the current effective date."
|
||||
:group 'org-habit
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-habit-show-all-today nil
|
||||
"If non-nil, will show the consistency graph of all habits on
|
||||
today's agenda, even if they are not scheduled."
|
||||
:group 'org-habit
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-habit-today-glyph ?!
|
||||
"Glyph character used to identify today."
|
||||
:group 'org-habit
|
||||
:version "24.1"
|
||||
:type 'character)
|
||||
|
||||
(defcustom org-habit-completed-glyph ?*
|
||||
"Glyph character used to show completed days on which a task was done."
|
||||
:group 'org-habit
|
||||
:version "24.1"
|
||||
:type 'character)
|
||||
|
||||
(defcustom org-habit-show-done-always-green nil
|
||||
"Non-nil means DONE days will always be green in the consistency graph.
|
||||
It will be green even if it was done after the deadline."
|
||||
:group 'org-habit
|
||||
:type 'boolean)
|
||||
|
||||
(defface org-habit-clear-face
|
||||
'((((background light)) (:background "#8270f9"))
|
||||
(((background dark)) (:background "blue")))
|
||||
"Face for days on which a task shouldn't be done yet."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
(defface org-habit-clear-future-face
|
||||
'((((background light)) (:background "#d6e4fc"))
|
||||
(((background dark)) (:background "midnightblue")))
|
||||
"Face for future days on which a task shouldn't be done yet."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-habit-ready-face
|
||||
'((((background light)) (:background "#4df946"))
|
||||
(((background dark)) (:background "forestgreen")))
|
||||
"Face for days on which a task should start to be done."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
(defface org-habit-ready-future-face
|
||||
'((((background light)) (:background "#acfca9"))
|
||||
(((background dark)) (:background "darkgreen")))
|
||||
"Face for days on which a task should start to be done."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-habit-alert-face
|
||||
'((((background light)) (:background "#f5f946"))
|
||||
(((background dark)) (:background "gold")))
|
||||
"Face for days on which a task is due."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
(defface org-habit-alert-future-face
|
||||
'((((background light)) (:background "#fafca9"))
|
||||
(((background dark)) (:background "darkgoldenrod")))
|
||||
"Face for days on which a task is due."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
|
||||
(defface org-habit-overdue-face
|
||||
'((((background light)) (:background "#f9372d"))
|
||||
(((background dark)) (:background "firebrick")))
|
||||
"Face for days on which a task is overdue."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
(defface org-habit-overdue-future-face
|
||||
'((((background light)) (:background "#fc9590"))
|
||||
(((background dark)) (:background "darkred")))
|
||||
"Face for days on which a task is overdue."
|
||||
:group 'org-habit
|
||||
:group 'org-faces)
|
||||
|
||||
(defun org-habit-duration-to-days (ts)
|
||||
(if (string-match "\\([0-9]+\\)\\([dwmy]\\)" ts)
|
||||
;; lead time is specified.
|
||||
(floor (* (string-to-number (match-string 1 ts))
|
||||
(cdr (assoc (match-string 2 ts)
|
||||
'(("d" . 1) ("w" . 7)
|
||||
("m" . 30.4) ("y" . 365.25))))))
|
||||
(error "Invalid duration string: %s" ts)))
|
||||
|
||||
(defun org-is-habit-p (&optional pom)
|
||||
"Is the task at POM or point a habit?"
|
||||
(string= "habit" (org-entry-get (or pom (point)) "STYLE")))
|
||||
|
||||
(defun org-habit-parse-todo (&optional pom)
|
||||
"Parse the TODO surrounding point for its habit-related data.
|
||||
Returns a list with the following elements:
|
||||
|
||||
0: Scheduled date for the habit (may be in the past)
|
||||
1: \".+\"-style repeater for the schedule, in days
|
||||
2: Optional deadline (nil if not present)
|
||||
3: If deadline, the repeater for the deadline, otherwise nil
|
||||
4: A list of all the past dates this todo was mark closed
|
||||
5: Repeater type as a string
|
||||
|
||||
This list represents a \"habit\" for the rest of this module."
|
||||
(save-excursion
|
||||
(if pom (goto-char pom))
|
||||
(assert (org-is-habit-p (point)))
|
||||
(let* ((scheduled (org-get-scheduled-time (point)))
|
||||
(scheduled-repeat (org-get-repeat org-scheduled-string))
|
||||
(end (org-entry-end-position))
|
||||
(habit-entry (org-no-properties (nth 4 (org-heading-components))))
|
||||
closed-dates deadline dr-days sr-days sr-type)
|
||||
(if scheduled
|
||||
(setq scheduled (time-to-days scheduled))
|
||||
(error "Habit %s has no scheduled date" habit-entry))
|
||||
(unless scheduled-repeat
|
||||
(error
|
||||
"Habit `%s' has no scheduled repeat period or has an incorrect one"
|
||||
habit-entry))
|
||||
(setq sr-days (org-habit-duration-to-days scheduled-repeat)
|
||||
sr-type (progn (string-match "[\\.+]?\\+" scheduled-repeat)
|
||||
(org-match-string-no-properties 0 scheduled-repeat)))
|
||||
(unless (> sr-days 0)
|
||||
(error "Habit %s scheduled repeat period is less than 1d" habit-entry))
|
||||
(when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat)
|
||||
(setq dr-days (org-habit-duration-to-days
|
||||
(match-string-no-properties 1 scheduled-repeat)))
|
||||
(if (<= dr-days sr-days)
|
||||
(error "Habit %s deadline repeat period is less than or equal to scheduled (%s)"
|
||||
habit-entry scheduled-repeat))
|
||||
(setq deadline (+ scheduled (- dr-days sr-days))))
|
||||
(org-back-to-heading t)
|
||||
(let* ((maxdays (+ org-habit-preceding-days org-habit-following-days))
|
||||
(reversed org-log-states-order-reversed)
|
||||
(search (if reversed 're-search-forward 're-search-backward))
|
||||
(limit (if reversed end (point)))
|
||||
(count 0)
|
||||
(re (format
|
||||
"^[ \t]*-[ \t]+\\(?:State \"%s\".*%s%s\\)"
|
||||
(regexp-opt org-done-keywords)
|
||||
org-ts-regexp-inactive
|
||||
(let ((value (cdr (assq 'done org-log-note-headings))))
|
||||
(if (not value) ""
|
||||
(concat "\\|"
|
||||
(org-replace-escapes
|
||||
(regexp-quote value)
|
||||
`(("%d" . ,org-ts-regexp-inactive)
|
||||
("%D" . ,org-ts-regexp)
|
||||
("%s" . "\"\\S-+\"")
|
||||
("%S" . "\"\\S-+\"")
|
||||
("%t" . ,org-ts-regexp-inactive)
|
||||
("%T" . ,org-ts-regexp)
|
||||
("%u" . ".*?")
|
||||
("%U" . ".*?")))))))))
|
||||
(unless reversed (goto-char end))
|
||||
(while (and (< count maxdays) (funcall search re limit t))
|
||||
(push (time-to-days
|
||||
(org-time-string-to-time
|
||||
(or (org-match-string-no-properties 1)
|
||||
(org-match-string-no-properties 2))))
|
||||
closed-dates)
|
||||
(setq count (1+ count))))
|
||||
(list scheduled sr-days deadline dr-days closed-dates sr-type))))
|
||||
|
||||
(defsubst org-habit-scheduled (habit)
|
||||
(nth 0 habit))
|
||||
(defsubst org-habit-scheduled-repeat (habit)
|
||||
(nth 1 habit))
|
||||
(defsubst org-habit-deadline (habit)
|
||||
(let ((deadline (nth 2 habit)))
|
||||
(or deadline
|
||||
(if (nth 3 habit)
|
||||
(+ (org-habit-scheduled habit)
|
||||
(1- (org-habit-scheduled-repeat habit)))
|
||||
(org-habit-scheduled habit)))))
|
||||
(defsubst org-habit-deadline-repeat (habit)
|
||||
(or (nth 3 habit)
|
||||
(org-habit-scheduled-repeat habit)))
|
||||
(defsubst org-habit-done-dates (habit)
|
||||
(nth 4 habit))
|
||||
(defsubst org-habit-repeat-type (habit)
|
||||
(nth 5 habit))
|
||||
|
||||
(defsubst org-habit-get-priority (habit &optional moment)
|
||||
"Determine the relative priority of a habit.
|
||||
This must take into account not just urgency, but consistency as well."
|
||||
(let ((pri 1000)
|
||||
(now (if moment (time-to-days moment) (org-today)))
|
||||
(scheduled (org-habit-scheduled habit))
|
||||
(deadline (org-habit-deadline habit)))
|
||||
;; add 10 for every day past the scheduled date, and subtract for every
|
||||
;; day before it
|
||||
(setq pri (+ pri (* (- now scheduled) 10)))
|
||||
;; add 50 if the deadline is today
|
||||
(if (and (/= scheduled deadline)
|
||||
(= now deadline))
|
||||
(setq pri (+ pri 50)))
|
||||
;; add 100 for every day beyond the deadline date, and subtract 10 for
|
||||
;; every day before it
|
||||
(let ((slip (- now (1- deadline))))
|
||||
(if (> slip 0)
|
||||
(setq pri (+ pri (* slip 100)))
|
||||
(setq pri (+ pri (* slip 10)))))
|
||||
pri))
|
||||
|
||||
(defun org-habit-get-faces (habit &optional now-days scheduled-days donep)
|
||||
"Return faces for HABIT relative to NOW-DAYS and SCHEDULED-DAYS.
|
||||
NOW-DAYS defaults to the current time's days-past-the-epoch if nil.
|
||||
SCHEDULED-DAYS defaults to the habit's actual scheduled days if nil.
|
||||
|
||||
Habits are assigned colors on the following basis:
|
||||
Blue Task is before the scheduled date.
|
||||
Green Task is on or after scheduled date, but before the
|
||||
end of the schedule's repeat period.
|
||||
Yellow If the task has a deadline, then it is after schedule's
|
||||
repeat period, but before the deadline.
|
||||
Orange The task has reached the deadline day, or if there is
|
||||
no deadline, the end of the schedule's repeat period.
|
||||
Red The task has gone beyond the deadline day or the
|
||||
schedule's repeat period."
|
||||
(let* ((scheduled (or scheduled-days (org-habit-scheduled habit)))
|
||||
(s-repeat (org-habit-scheduled-repeat habit))
|
||||
(scheduled-end (+ scheduled (1- s-repeat)))
|
||||
(d-repeat (org-habit-deadline-repeat habit))
|
||||
(deadline (if scheduled-days
|
||||
(+ scheduled-days (- d-repeat s-repeat))
|
||||
(org-habit-deadline habit)))
|
||||
(m-days (or now-days (time-to-days (current-time)))))
|
||||
(cond
|
||||
((< m-days scheduled)
|
||||
'(org-habit-clear-face . org-habit-clear-future-face))
|
||||
((< m-days deadline)
|
||||
'(org-habit-ready-face . org-habit-ready-future-face))
|
||||
((= m-days deadline)
|
||||
(if donep
|
||||
'(org-habit-ready-face . org-habit-ready-future-face)
|
||||
'(org-habit-alert-face . org-habit-alert-future-face)))
|
||||
((and org-habit-show-done-always-green donep)
|
||||
'(org-habit-ready-face . org-habit-ready-future-face))
|
||||
(t '(org-habit-overdue-face . org-habit-overdue-future-face)))))
|
||||
|
||||
(defun org-habit-build-graph (habit starting current ending)
|
||||
"Build a graph for the given HABIT, from STARTING to ENDING.
|
||||
CURRENT gives the current time between STARTING and ENDING, for
|
||||
the purpose of drawing the graph. It need not be the actual
|
||||
current time."
|
||||
(let* ((done-dates (sort (org-habit-done-dates habit) '<))
|
||||
(scheduled (org-habit-scheduled habit))
|
||||
(s-repeat (org-habit-scheduled-repeat habit))
|
||||
(start (time-to-days starting))
|
||||
(now (time-to-days current))
|
||||
(end (time-to-days ending))
|
||||
(graph (make-string (1+ (- end start)) ?\ ))
|
||||
(index 0)
|
||||
last-done-date)
|
||||
(while (and done-dates (< (car done-dates) start))
|
||||
(setq last-done-date (car done-dates)
|
||||
done-dates (cdr done-dates)))
|
||||
(while (< start end)
|
||||
(let* ((in-the-past-p (< start now))
|
||||
(todayp (= start now))
|
||||
(donep (and done-dates
|
||||
(= start (car done-dates))))
|
||||
(faces (if (and in-the-past-p
|
||||
(not last-done-date)
|
||||
(not (< scheduled now)))
|
||||
'(org-habit-clear-face . org-habit-clear-future-face)
|
||||
(org-habit-get-faces
|
||||
habit start
|
||||
(and in-the-past-p last-done-date
|
||||
;; Compute scheduled time for habit at the
|
||||
;; time START was current.
|
||||
(let ((type (org-habit-repeat-type habit)))
|
||||
(cond
|
||||
((equal type ".+")
|
||||
(+ last-done-date s-repeat))
|
||||
((equal type "+")
|
||||
;; Since LAST-DONE-DATE, each done
|
||||
;; mark shifted scheduled date by
|
||||
;; S-REPEAT.
|
||||
(- scheduled (* (length done-dates) s-repeat)))
|
||||
(t
|
||||
;; Scheduled time was the first time
|
||||
;; past LAST-DONE-STATE which can jump
|
||||
;; to current SCHEDULED time by
|
||||
;; S-REPEAT hops.
|
||||
(- scheduled
|
||||
(* (/ (- scheduled last-done-date) s-repeat)
|
||||
s-repeat))))))
|
||||
donep)))
|
||||
markedp face)
|
||||
(if donep
|
||||
(let ((done-time (time-add
|
||||
starting
|
||||
(days-to-time
|
||||
(- start (time-to-days starting))))))
|
||||
|
||||
(aset graph index org-habit-completed-glyph)
|
||||
(setq markedp t)
|
||||
(put-text-property
|
||||
index (1+ index) 'help-echo
|
||||
(format-time-string (org-time-stamp-format) done-time) graph)
|
||||
(while (and done-dates
|
||||
(= start (car done-dates)))
|
||||
(setq last-done-date (car done-dates)
|
||||
done-dates (cdr done-dates))))
|
||||
(if todayp
|
||||
(aset graph index org-habit-today-glyph)))
|
||||
(setq face (if (or in-the-past-p todayp)
|
||||
(car faces)
|
||||
(cdr faces)))
|
||||
(if (and in-the-past-p
|
||||
(not (eq face 'org-habit-overdue-face))
|
||||
(not markedp))
|
||||
(setq face (cdr faces)))
|
||||
(put-text-property index (1+ index) 'face face graph))
|
||||
(setq start (1+ start)
|
||||
index (1+ index)))
|
||||
graph))
|
||||
|
||||
(defun org-habit-insert-consistency-graphs (&optional line)
|
||||
"Insert consistency graph for any habitual tasks."
|
||||
(let ((inhibit-read-only t) l c
|
||||
(buffer-invisibility-spec '(org-link))
|
||||
(moment (time-subtract (current-time)
|
||||
(list 0 (* 3600 org-extend-today-until) 0))))
|
||||
(save-excursion
|
||||
(goto-char (if line (point-at-bol) (point-min)))
|
||||
(while (not (eobp))
|
||||
(let ((habit (get-text-property (point) 'org-habit-p)))
|
||||
(when habit
|
||||
(move-to-column org-habit-graph-column t)
|
||||
(delete-char (min (+ 1 org-habit-preceding-days
|
||||
org-habit-following-days)
|
||||
(- (line-end-position) (point))))
|
||||
(insert-before-markers
|
||||
(org-habit-build-graph
|
||||
habit
|
||||
(time-subtract moment (days-to-time org-habit-preceding-days))
|
||||
moment
|
||||
(time-add moment (days-to-time org-habit-following-days))))))
|
||||
(forward-line)))))
|
||||
|
||||
(defun org-habit-toggle-habits ()
|
||||
"Toggle display of habits in an agenda buffer."
|
||||
(interactive)
|
||||
(org-agenda-check-type t 'agenda)
|
||||
(setq org-habit-show-habits (not org-habit-show-habits))
|
||||
(org-agenda-redo)
|
||||
(org-agenda-set-mode-name)
|
||||
(message "Habits turned %s"
|
||||
(if org-habit-show-habits "on" "off")))
|
||||
|
||||
(org-defkey org-agenda-mode-map "K" 'org-habit-toggle-habits)
|
||||
|
||||
(provide 'org-habit)
|
||||
|
||||
;;; org-habit.el ends here
|
690
elpa/org-20160919/org-id.el
Normal file
690
elpa/org-20160919/org-id.el
Normal file
@ -0,0 +1,690 @@
|
||||
;;; org-id.el --- Global identifiers for Org-mode entries
|
||||
;;
|
||||
;; Copyright (C) 2008-2016 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file implements globally unique identifiers for Org-mode entries.
|
||||
;; Identifiers are stored in the entry as an :ID: property. Functions
|
||||
;; are provided that create and retrieve such identifiers, and that find
|
||||
;; entries based on the identifier.
|
||||
|
||||
;; Identifiers consist of a prefix (default "Org" given by the variable
|
||||
;; `org-id-prefix') and a unique part that can be created by a number
|
||||
;; of different methods, see the variable `org-id-method'.
|
||||
;; Org has a builtin method that uses a compact encoding of the creation
|
||||
;; time of the ID, with microsecond accuracy. This virtually
|
||||
;; guarantees globally unique identifiers, even if several people are
|
||||
;; creating IDs at the same time in files that will eventually be used
|
||||
;; together.
|
||||
;;
|
||||
;; By default Org uses UUIDs as global unique identifiers.
|
||||
;;
|
||||
;; This file defines the following API:
|
||||
;;
|
||||
;; org-id-get-create
|
||||
;; Create an ID for the entry at point if it does not yet have one.
|
||||
;; Returns the ID (old or new). This function can be used
|
||||
;; interactively, with prefix argument the creation of a new ID is
|
||||
;; forced, even if there was an old one.
|
||||
;;
|
||||
;; org-id-get
|
||||
;; Get the ID property of an entry. Using appropriate arguments
|
||||
;; to the function, it can also create the ID for this entry.
|
||||
;;
|
||||
;; org-id-goto
|
||||
;; Command to go to a specific ID, this command can be used
|
||||
;; interactively.
|
||||
;;
|
||||
;; org-id-get-with-outline-path-completion
|
||||
;; Retrieve the ID of an entry, using outline path completion.
|
||||
;; This function can work for multiple files.
|
||||
;;
|
||||
;; org-id-get-with-outline-drilling
|
||||
;; Retrieve the ID of an entry, using outline path completion.
|
||||
;; This function only works for the current file.
|
||||
;;
|
||||
;; org-id-find
|
||||
;; Find the location of an entry with specific id.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
(declare-function message-make-fqdn "message" ())
|
||||
(declare-function org-pop-to-buffer-same-window
|
||||
"org-compat" (&optional buffer-or-name norecord label))
|
||||
|
||||
;;; Customization
|
||||
|
||||
(defgroup org-id nil
|
||||
"Options concerning global entry identifiers in Org-mode."
|
||||
:tag "Org ID"
|
||||
:group 'org)
|
||||
|
||||
(define-obsolete-variable-alias
|
||||
'org-link-to-org-use-id 'org-id-link-to-org-use-id "24.3")
|
||||
(defcustom org-id-link-to-org-use-id nil
|
||||
"Non-nil means storing a link to an Org file will use entry IDs.
|
||||
\\<org-mode-map>\
|
||||
|
||||
The variable can have the following values:
|
||||
|
||||
t Create an ID if needed to make a link to the current entry.
|
||||
|
||||
create-if-interactive
|
||||
If `org-store-link' is called directly (interactively, as a user
|
||||
command), do create an ID to support the link. But when doing the
|
||||
job for capture, only use the ID if it already exists. The
|
||||
purpose of this setting is to avoid proliferation of unwanted
|
||||
IDs, just because you happen to be in an Org file when you
|
||||
call `org-capture' that automatically and preemptively creates a
|
||||
link. If you do want to get an ID link in a capture template to
|
||||
an entry not having an ID, create it first by explicitly creating
|
||||
a link to it, using `\\[org-insert-link]' first.
|
||||
|
||||
create-if-interactive-and-no-custom-id
|
||||
Like create-if-interactive, but do not create an ID if there is
|
||||
a CUSTOM_ID property defined in the entry.
|
||||
|
||||
use-existing
|
||||
Use existing ID, do not create one.
|
||||
|
||||
nil Never use an ID to make a link, instead link using a text search for
|
||||
the headline text."
|
||||
:group 'org-link-store
|
||||
:group 'org-id
|
||||
:version "24.3"
|
||||
:type '(choice
|
||||
(const :tag "Create ID to make link" t)
|
||||
(const :tag "Create if storing link interactively"
|
||||
create-if-interactive)
|
||||
(const :tag "Create if storing link interactively and no CUSTOM_ID is present"
|
||||
create-if-interactive-and-no-custom-id)
|
||||
(const :tag "Only use existing" use-existing)
|
||||
(const :tag "Do not use ID to create link" nil)))
|
||||
|
||||
(defcustom org-id-uuid-program "uuidgen"
|
||||
"The uuidgen program."
|
||||
:group 'org-id
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-id-method 'uuid
|
||||
"The method that should be used to create new IDs.
|
||||
|
||||
An ID will consist of the optional prefix specified in `org-id-prefix',
|
||||
and a unique part created by the method this variable specifies.
|
||||
|
||||
Allowed values are:
|
||||
|
||||
org Org's own internal method, using an encoding of the current time to
|
||||
microsecond accuracy, and optionally the current domain of the
|
||||
computer. See the variable `org-id-include-domain'.
|
||||
|
||||
uuid Create random (version 4) UUIDs. If the program defined in
|
||||
`org-id-uuid-program' is available it is used to create the ID.
|
||||
Otherwise an internal functions is used."
|
||||
:group 'org-id
|
||||
:type '(choice
|
||||
(const :tag "Org's internal method" org)
|
||||
(const :tag "external: uuidgen" uuid)))
|
||||
|
||||
(defcustom org-id-prefix nil
|
||||
"The prefix for IDs.
|
||||
|
||||
This may be a string, or it can be nil to indicate that no prefix is required.
|
||||
When a string, the string should have no space characters as IDs are expected
|
||||
to have no space characters in them."
|
||||
:group 'org-id
|
||||
:type '(choice
|
||||
(const :tag "No prefix")
|
||||
(string :tag "Prefix")))
|
||||
|
||||
(defcustom org-id-include-domain nil
|
||||
"Non-nil means add the domain name to new IDs.
|
||||
This ensures global uniqueness of IDs, and is also suggested by
|
||||
RFC 2445 in combination with RFC 822. This is only relevant if
|
||||
`org-id-method' is `org'. When uuidgen is used, the domain will never
|
||||
be added.
|
||||
The default is to not use this because we have no really good way to get
|
||||
the true domain, and Org entries will normally not be shared with enough
|
||||
people to make this necessary."
|
||||
:group 'org-id
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-id-track-globally t
|
||||
"Non-nil means track IDs through files, so that links work globally.
|
||||
This work by maintaining a hash table for IDs and writing this table
|
||||
to disk when exiting Emacs. Because of this, it works best if you use
|
||||
a single Emacs process, not many.
|
||||
|
||||
When nil, IDs are not tracked. Links to IDs will still work within
|
||||
a buffer, but not if the entry is located in another file.
|
||||
IDs can still be used if the entry with the id is in the same file as
|
||||
the link."
|
||||
:group 'org-id
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-id-locations-file (convert-standard-filename
|
||||
(concat user-emacs-directory ".org-id-locations"))
|
||||
"The file for remembering in which file an ID was defined.
|
||||
This variable is only relevant when `org-id-track-globally' is set."
|
||||
:group 'org-id
|
||||
:type 'file)
|
||||
|
||||
(defvar org-id-locations nil
|
||||
"List of files with IDs in those files.")
|
||||
|
||||
(defvar org-id-files nil
|
||||
"List of files that contain IDs.")
|
||||
|
||||
(defcustom org-id-extra-files 'org-agenda-text-search-extra-files
|
||||
"Files to be searched for IDs, besides the agenda files.
|
||||
When Org reparses files to remake the list of files and IDs it is tracking,
|
||||
it will normally scan the agenda files, the archives related to agenda files,
|
||||
any files that are listed as ID containing in the current register, and
|
||||
any Org-mode files currently visited by Emacs.
|
||||
You can list additional files here.
|
||||
This variable is only relevant when `org-id-track-globally' is set."
|
||||
:group 'org-id
|
||||
:type
|
||||
'(choice
|
||||
(symbol :tag "Variable")
|
||||
(repeat :tag "List of files"
|
||||
(file))))
|
||||
|
||||
(defcustom org-id-search-archives t
|
||||
"Non-nil means search also the archive files of agenda files for entries.
|
||||
This is a possibility to reduce overhead, but it means that entries moved
|
||||
to the archives can no longer be found by ID.
|
||||
This variable is only relevant when `org-id-track-globally' is set."
|
||||
:group 'org-id
|
||||
:type 'boolean)
|
||||
|
||||
;;; The API functions
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-get-create (&optional force)
|
||||
"Create an ID for the current entry and return it.
|
||||
If the entry already has an ID, just return it.
|
||||
With optional argument FORCE, force the creation of a new ID."
|
||||
(interactive "P")
|
||||
(when force
|
||||
(org-entry-put (point) "ID" nil))
|
||||
(org-id-get (point) 'create))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-copy ()
|
||||
"Copy the ID of the entry at point to the kill ring.
|
||||
Create an ID if necessary."
|
||||
(interactive)
|
||||
(org-kill-new (org-id-get nil 'create)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-get (&optional pom create prefix)
|
||||
"Get the ID property of the entry at point-or-marker POM.
|
||||
If POM is nil, refer to the entry at point.
|
||||
If the entry does not have an ID, the function returns nil.
|
||||
However, when CREATE is non nil, create an ID if none is present already.
|
||||
PREFIX will be passed through to `org-id-new'.
|
||||
In any case, the ID of the entry is returned."
|
||||
(org-with-point-at pom
|
||||
(let ((id (org-entry-get nil "ID")))
|
||||
(cond
|
||||
((and id (stringp id) (string-match "\\S-" id))
|
||||
id)
|
||||
(create
|
||||
(setq id (org-id-new prefix))
|
||||
(org-entry-put pom "ID" id)
|
||||
(org-id-add-location id (buffer-file-name (buffer-base-buffer)))
|
||||
id)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-get-with-outline-path-completion (&optional targets)
|
||||
"Use `outline-path-completion' to retrieve the ID of an entry.
|
||||
TARGETS may be a setting for `org-refile-targets' to define
|
||||
eligible headlines. When omitted, all headlines in the current
|
||||
file are eligible. This function returns the ID of the entry.
|
||||
If necessary, the ID is created."
|
||||
(let* ((org-refile-targets (or targets '((nil . (:maxlevel . 10)))))
|
||||
(org-refile-use-outline-path
|
||||
(if (caar org-refile-targets) 'file t))
|
||||
(org-refile-target-verify-function nil)
|
||||
(spos (org-refile-get-location "Entry"))
|
||||
(pom (and spos (move-marker (make-marker) (nth 3 spos)
|
||||
(get-file-buffer (nth 1 spos))))))
|
||||
(prog1 (org-id-get pom 'create)
|
||||
(move-marker pom nil))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-get-with-outline-drilling (&optional targets)
|
||||
"Use an outline-cycling interface to retrieve the ID of an entry.
|
||||
This only finds entries in the current buffer, using `org-get-location'.
|
||||
It returns the ID of the entry. If necessary, the ID is created."
|
||||
(let* ((spos (org-get-location (current-buffer) org-goto-help))
|
||||
(pom (and spos (move-marker (make-marker) (car spos)))))
|
||||
(prog1 (org-id-get pom 'create)
|
||||
(move-marker pom nil))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-goto (id)
|
||||
"Switch to the buffer containing the entry with id ID.
|
||||
Move the cursor to that entry in that buffer."
|
||||
(interactive "sID: ")
|
||||
(let ((m (org-id-find id 'marker)))
|
||||
(unless m
|
||||
(error "Cannot find entry with ID \"%s\"" id))
|
||||
(org-pop-to-buffer-same-window (marker-buffer m))
|
||||
(goto-char m)
|
||||
(move-marker m nil)
|
||||
(org-show-context)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-find (id &optional markerp)
|
||||
"Return the location of the entry with the id ID.
|
||||
The return value is a cons cell (file-name . position), or nil
|
||||
if there is no entry with that ID.
|
||||
With optional argument MARKERP, return the position as a new marker."
|
||||
(cond
|
||||
((symbolp id) (setq id (symbol-name id)))
|
||||
((numberp id) (setq id (number-to-string id))))
|
||||
(let ((file (org-id-find-id-file id))
|
||||
org-agenda-new-buffers where)
|
||||
(when file
|
||||
(setq where (org-id-find-id-in-file id file markerp)))
|
||||
(unless where
|
||||
(org-id-update-id-locations nil t)
|
||||
(setq file (org-id-find-id-file id))
|
||||
(when file
|
||||
(setq where (org-id-find-id-in-file id file markerp))))
|
||||
where))
|
||||
|
||||
;;; Internal functions
|
||||
|
||||
;; Creating new IDs
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-new (&optional prefix)
|
||||
"Create a new globally unique ID.
|
||||
|
||||
An ID consists of two parts separated by a colon:
|
||||
- a prefix
|
||||
- a unique part that will be created according to `org-id-method'.
|
||||
|
||||
PREFIX can specify the prefix, the default is given by the variable
|
||||
`org-id-prefix'. However, if PREFIX is the symbol `none', don't use any
|
||||
prefix even if `org-id-prefix' specifies one.
|
||||
|
||||
So a typical ID could look like \"Org:4nd91V40HI\"."
|
||||
(let* ((prefix (if (eq prefix 'none)
|
||||
""
|
||||
(concat (or prefix org-id-prefix) ":")))
|
||||
unique)
|
||||
(if (equal prefix ":") (setq prefix ""))
|
||||
(cond
|
||||
((memq org-id-method '(uuidgen uuid))
|
||||
(setq unique (org-trim (shell-command-to-string org-id-uuid-program)))
|
||||
(unless (org-uuidgen-p unique)
|
||||
(setq unique (org-id-uuid))))
|
||||
((eq org-id-method 'org)
|
||||
(let* ((etime (org-reverse-string (org-id-time-to-b36)))
|
||||
(postfix (if org-id-include-domain
|
||||
(progn
|
||||
(require 'message)
|
||||
(concat "@" (message-make-fqdn))))))
|
||||
(setq unique (concat etime postfix))))
|
||||
(t (error "Invalid `org-id-method'")))
|
||||
(concat prefix unique)))
|
||||
|
||||
(defun org-id-uuid ()
|
||||
"Return string with random (version 4) UUID."
|
||||
(let ((rnd (md5 (format "%s%s%s%s%s%s%s"
|
||||
(random)
|
||||
(current-time)
|
||||
(user-uid)
|
||||
(emacs-pid)
|
||||
(user-full-name)
|
||||
user-mail-address
|
||||
(recent-keys)))))
|
||||
(format "%s-%s-4%s-%s%s-%s"
|
||||
(substring rnd 0 8)
|
||||
(substring rnd 8 12)
|
||||
(substring rnd 13 16)
|
||||
(format "%x"
|
||||
(logior
|
||||
#b10000000
|
||||
(logand
|
||||
#b10111111
|
||||
(string-to-number
|
||||
(substring rnd 16 18) 16))))
|
||||
(substring rnd 18 20)
|
||||
(substring rnd 20 32))))
|
||||
|
||||
(defun org-id-int-to-b36-one-digit (i)
|
||||
"Turn an integer between 0 and 61 into a single character 0..9, A..Z, a..z."
|
||||
(cond
|
||||
((< i 10) (+ ?0 i))
|
||||
((< i 36) (+ ?a i -10))
|
||||
(t (error "Larger that 35"))))
|
||||
|
||||
(defun org-id-b36-to-int-one-digit (i)
|
||||
"Turn a character 0..9, A..Z, a..z into a number 0..61.
|
||||
The input I may be a character, or a single-letter string."
|
||||
(and (stringp i) (setq i (string-to-char i)))
|
||||
(cond
|
||||
((and (>= i ?0) (<= i ?9)) (- i ?0))
|
||||
((and (>= i ?a) (<= i ?z)) (+ (- i ?a) 10))
|
||||
(t (error "Invalid b36 letter"))))
|
||||
|
||||
(defun org-id-int-to-b36 (i &optional length)
|
||||
"Convert an integer to a base-36 number represented as a string."
|
||||
(let ((s ""))
|
||||
(while (> i 0)
|
||||
(setq s (concat (char-to-string
|
||||
(org-id-int-to-b36-one-digit (mod i 36))) s)
|
||||
i (/ i 36)))
|
||||
(setq length (max 1 (or length 1)))
|
||||
(if (< (length s) length)
|
||||
(setq s (concat (make-string (- length (length s)) ?0) s)))
|
||||
s))
|
||||
|
||||
(defun org-id-b36-to-int (s)
|
||||
"Convert a base-36 string into the corresponding integer."
|
||||
(let ((r 0))
|
||||
(mapc (lambda (i) (setq r (+ (* r 36) (org-id-b36-to-int-one-digit i))))
|
||||
s)
|
||||
r))
|
||||
|
||||
(defun org-id-time-to-b36 (&optional time)
|
||||
"Encode TIME as a 10-digit string.
|
||||
This string holds the time to micro-second accuracy, and can be decoded
|
||||
using `org-id-decode'."
|
||||
(setq time (or time (current-time)))
|
||||
(concat (org-id-int-to-b36 (nth 0 time) 4)
|
||||
(org-id-int-to-b36 (nth 1 time) 4)
|
||||
(org-id-int-to-b36 (or (nth 2 time) 0) 4)))
|
||||
|
||||
(defun org-id-decode (id)
|
||||
"Split ID into the prefix and the time value that was used to create it.
|
||||
The return value is (prefix . time) where PREFIX is nil or a string,
|
||||
and time is the usual three-integer representation of time."
|
||||
(let (prefix time parts)
|
||||
(setq parts (org-split-string id ":"))
|
||||
(if (= 2 (length parts))
|
||||
(setq prefix (car parts) time (nth 1 parts))
|
||||
(setq prefix nil time (nth 0 parts)))
|
||||
(setq time (org-reverse-string time))
|
||||
(setq time (list (org-id-b36-to-int (substring time 0 4))
|
||||
(org-id-b36-to-int (substring time 4 8))
|
||||
(org-id-b36-to-int (substring time 8 12))))
|
||||
(cons prefix time)))
|
||||
|
||||
;; Storing ID locations (files)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-update-id-locations (&optional files silent)
|
||||
"Scan relevant files for IDs.
|
||||
Store the relation between files and corresponding IDs.
|
||||
This will scan all agenda files, all associated archives, and all
|
||||
files currently mentioned in `org-id-locations'.
|
||||
When FILES is given, scan these files instead.
|
||||
When CHECK is given, prepare detailed information about duplicate IDs."
|
||||
(interactive)
|
||||
(if (not org-id-track-globally)
|
||||
(error "Please turn on `org-id-track-globally' if you want to track IDs")
|
||||
(let* ((org-id-search-archives
|
||||
(or org-id-search-archives
|
||||
(and (symbolp org-id-extra-files)
|
||||
(symbol-value org-id-extra-files)
|
||||
(member 'agenda-archives org-id-extra-files))))
|
||||
(files
|
||||
(or files
|
||||
(append
|
||||
;; Agenda files and all associated archives
|
||||
(org-agenda-files t org-id-search-archives)
|
||||
;; Explicit extra files
|
||||
(if (symbolp org-id-extra-files)
|
||||
(symbol-value org-id-extra-files)
|
||||
org-id-extra-files)
|
||||
;; Files associated with live org-mode buffers
|
||||
(delq nil
|
||||
(mapcar (lambda (b)
|
||||
(with-current-buffer b
|
||||
(and (derived-mode-p 'org-mode) (buffer-file-name))))
|
||||
(buffer-list)))
|
||||
;; All files known to have IDs
|
||||
org-id-files)))
|
||||
org-agenda-new-buffers
|
||||
file nfiles tfile ids reg found id seen (ndup 0))
|
||||
(when (member 'agenda-archives files)
|
||||
(setq files (delq 'agenda-archives (copy-sequence files))))
|
||||
(setq nfiles (length files))
|
||||
(while (setq file (pop files))
|
||||
(unless silent
|
||||
(message "Finding ID locations (%d/%d files): %s"
|
||||
(- nfiles (length files)) nfiles file))
|
||||
(setq tfile (file-truename file))
|
||||
(when (and (file-exists-p file) (not (member tfile seen)))
|
||||
(push tfile seen)
|
||||
(setq ids nil)
|
||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^[ \t]*:ID:[ \t]+\\(\\S-+\\)[ \t]*$"
|
||||
nil t)
|
||||
(setq id (org-match-string-no-properties 1))
|
||||
(if (member id found)
|
||||
(progn
|
||||
(message "Duplicate ID \"%s\", also in file %s"
|
||||
id (or (car (delq
|
||||
nil
|
||||
(mapcar
|
||||
(lambda (x)
|
||||
(if (member id (cdr x))
|
||||
(car x)))
|
||||
reg)))
|
||||
(buffer-file-name)))
|
||||
(when (= ndup 0)
|
||||
(ding)
|
||||
(sit-for 2))
|
||||
(setq ndup (1+ ndup)))
|
||||
(push id found)
|
||||
(push id ids)))
|
||||
(push (cons (abbreviate-file-name file) ids) reg))))))
|
||||
(org-release-buffers org-agenda-new-buffers)
|
||||
(setq org-agenda-new-buffers nil)
|
||||
(setq org-id-locations reg)
|
||||
(setq org-id-files (mapcar 'car org-id-locations))
|
||||
(org-id-locations-save) ;; this function can also handle the alist form
|
||||
;; now convert to a hash
|
||||
(setq org-id-locations (org-id-alist-to-hash org-id-locations))
|
||||
(if (> ndup 0)
|
||||
(message "WARNING: %d duplicate IDs found, check *Messages* buffer" ndup)
|
||||
(message "%d unique files scanned for IDs" (length org-id-files)))
|
||||
org-id-locations)))
|
||||
|
||||
(defun org-id-locations-save ()
|
||||
"Save `org-id-locations' in `org-id-locations-file'."
|
||||
(when (and org-id-track-globally org-id-locations)
|
||||
(let ((out (if (hash-table-p org-id-locations)
|
||||
(org-id-hash-to-alist org-id-locations)
|
||||
org-id-locations)))
|
||||
(with-temp-file org-id-locations-file
|
||||
(let ((print-level nil)
|
||||
(print-length nil))
|
||||
(print out (current-buffer)))))))
|
||||
|
||||
(defun org-id-locations-load ()
|
||||
"Read the data from `org-id-locations-file'."
|
||||
(setq org-id-locations nil)
|
||||
(when org-id-track-globally
|
||||
(with-temp-buffer
|
||||
(condition-case nil
|
||||
(progn
|
||||
(insert-file-contents-literally org-id-locations-file)
|
||||
(goto-char (point-min))
|
||||
(setq org-id-locations (read (current-buffer))))
|
||||
(error
|
||||
(message "Could not read org-id-values from %s. Setting it to nil."
|
||||
org-id-locations-file))))
|
||||
(setq org-id-files (mapcar 'car org-id-locations))
|
||||
(setq org-id-locations (org-id-alist-to-hash org-id-locations))))
|
||||
|
||||
(defun org-id-add-location (id file)
|
||||
"Add the ID with location FILE to the database of ID locations."
|
||||
;; Only if global tracking is on, and when the buffer has a file
|
||||
(when (and org-id-track-globally id file)
|
||||
(unless org-id-locations (org-id-locations-load))
|
||||
(puthash id (abbreviate-file-name file) org-id-locations)
|
||||
(add-to-list 'org-id-files (abbreviate-file-name file))))
|
||||
|
||||
(unless noninteractive
|
||||
(add-hook 'kill-emacs-hook 'org-id-locations-save))
|
||||
|
||||
(defun org-id-hash-to-alist (hash)
|
||||
"Turn an org-id hash into an alist, so that it can be written to a file."
|
||||
(let (res x)
|
||||
(maphash
|
||||
(lambda (k v)
|
||||
(if (setq x (member v res))
|
||||
(setcdr x (cons k (cdr x)))
|
||||
(push (list v k) res)))
|
||||
hash)
|
||||
res))
|
||||
|
||||
(defun org-id-alist-to-hash (list)
|
||||
"Turn an org-id location list into a hash table."
|
||||
(let ((res (make-hash-table
|
||||
:test 'equal
|
||||
:size (apply '+ (mapcar 'length list))))
|
||||
f)
|
||||
(mapc
|
||||
(lambda (x)
|
||||
(setq f (car x))
|
||||
(mapc (lambda (i) (puthash i f res)) (cdr x)))
|
||||
list)
|
||||
res))
|
||||
|
||||
(defun org-id-paste-tracker (txt &optional buffer-or-file)
|
||||
"Update any IDs in TXT and assign BUFFER-OR-FILE to them."
|
||||
(when org-id-track-globally
|
||||
(save-match-data
|
||||
(setq buffer-or-file (or buffer-or-file (current-buffer)))
|
||||
(when (bufferp buffer-or-file)
|
||||
(setq buffer-or-file (or (buffer-base-buffer buffer-or-file)
|
||||
buffer-or-file))
|
||||
(setq buffer-or-file (buffer-file-name buffer-or-file)))
|
||||
(when buffer-or-file
|
||||
(let ((fname (abbreviate-file-name buffer-or-file))
|
||||
(s 0))
|
||||
(while (string-match "^[ \t]*:ID:[ \t]+\\([^ \t\n\r]+\\)" txt s)
|
||||
(setq s (match-end 0))
|
||||
(org-id-add-location (match-string 1 txt) fname)))))))
|
||||
|
||||
;; Finding entries with specified id
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-find-id-file (id)
|
||||
"Query the id database for the file in which this ID is located."
|
||||
(unless org-id-locations (org-id-locations-load))
|
||||
(or (and org-id-locations
|
||||
(hash-table-p org-id-locations)
|
||||
(gethash id org-id-locations))
|
||||
;; ball back on current buffer
|
||||
(buffer-file-name (or (buffer-base-buffer (current-buffer))
|
||||
(current-buffer)))))
|
||||
|
||||
(defun org-id-find-id-in-file (id file &optional markerp)
|
||||
"Return the position of the entry ID in FILE.
|
||||
If that files does not exist, or if it does not contain this ID,
|
||||
return nil.
|
||||
The position is returned as a cons cell (file-name . position). With
|
||||
optional argument MARKERP, return the position as a new marker."
|
||||
(let (org-agenda-new-buffers buf pos)
|
||||
(cond
|
||||
((not file) nil)
|
||||
((not (file-exists-p file)) nil)
|
||||
(t (with-current-buffer (setq buf (org-get-agenda-file-buffer file))
|
||||
(setq pos (org-find-entry-with-id id))
|
||||
(when pos
|
||||
(if markerp
|
||||
(move-marker (make-marker) pos buf)
|
||||
(cons file pos))))))))
|
||||
|
||||
;; id link type
|
||||
|
||||
;; Calling the following function is hard-coded into `org-store-link',
|
||||
;; so we do have to add it to `org-store-link-functions'.
|
||||
|
||||
;;;###autoload
|
||||
(defun org-id-store-link ()
|
||||
"Store a link to the current entry, using its ID."
|
||||
(interactive)
|
||||
(when (and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 'org-mode))
|
||||
(let* ((link (concat "id:" (org-id-get-create)))
|
||||
(case-fold-search nil)
|
||||
(desc (save-excursion
|
||||
(org-back-to-heading t)
|
||||
(or (and (looking-at org-complex-heading-regexp)
|
||||
(if (match-end 4)
|
||||
(match-string 4)
|
||||
(match-string 0)))
|
||||
link))))
|
||||
(org-store-link-props :link link :description desc :type "id")
|
||||
link)))
|
||||
|
||||
(defun org-id-open (id)
|
||||
"Go to the entry with id ID."
|
||||
(org-mark-ring-push)
|
||||
(let ((m (org-id-find id 'marker))
|
||||
cmd)
|
||||
(unless m
|
||||
(error "Cannot find entry with ID \"%s\"" id))
|
||||
;; Use a buffer-switching command in analogy to finding files
|
||||
(setq cmd
|
||||
(or
|
||||
(cdr
|
||||
(assq
|
||||
(cdr (assq 'file org-link-frame-setup))
|
||||
'((find-file . switch-to-buffer)
|
||||
(find-file-other-window . switch-to-buffer-other-window)
|
||||
(find-file-other-frame . switch-to-buffer-other-frame))))
|
||||
'switch-to-buffer-other-window))
|
||||
(if (not (equal (current-buffer) (marker-buffer m)))
|
||||
(funcall cmd (marker-buffer m)))
|
||||
(goto-char m)
|
||||
(move-marker m nil)
|
||||
(org-show-context)))
|
||||
|
||||
(org-add-link-type "id" 'org-id-open)
|
||||
|
||||
(provide 'org-id)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-id.el ends here
|
384
elpa/org-20160919/org-indent.el
Normal file
384
elpa/org-20160919/org-indent.el
Normal file
@ -0,0 +1,384 @@
|
||||
;;; org-indent.el --- Dynamic indentation for Org-mode
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This is an implementation of dynamic virtual indentation. It works
|
||||
;; by adding text properties to a buffer to make sure lines are
|
||||
;; indented according to outline structure.
|
||||
;;
|
||||
;; The process is synchronous, toggled at every buffer modification.
|
||||
;; Though, the initialization (indentation of text already in the
|
||||
;; buffer), which can take a few seconds in large buffers, happens on
|
||||
;; idle time.
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(require 'org-macs)
|
||||
(require 'org-compat)
|
||||
(require 'org)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(declare-function org-inlinetask-get-task-level "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
|
||||
(declare-function org-list-item-body-column "org-list" (item))
|
||||
(defvar org-inlinetask-show-first-star)
|
||||
|
||||
(defgroup org-indent nil
|
||||
"Options concerning dynamic virtual outline indentation."
|
||||
:tag "Org Indent"
|
||||
:group 'org)
|
||||
|
||||
(defvar org-indent-inlinetask-first-star (org-add-props "*" '(face org-warning))
|
||||
"First star of inline tasks, with correct face.")
|
||||
(defvar org-indent-agent-timer nil
|
||||
"Timer running the initialize agent.")
|
||||
(defvar org-indent-agentized-buffers nil
|
||||
"List of buffers watched by the initialize agent.")
|
||||
(defvar org-indent-agent-resume-timer nil
|
||||
"Timer to reschedule agent after switching to other idle processes.")
|
||||
(defvar org-indent-agent-active-delay '(0 2 0)
|
||||
"Time to run agent before switching to other idle processes.
|
||||
Delay used when the buffer to initialize is current.")
|
||||
(defvar org-indent-agent-passive-delay '(0 0 400000)
|
||||
"Time to run agent before switching to other idle processes.
|
||||
Delay used when the buffer to initialize isn't current.")
|
||||
(defvar org-indent-agent-resume-delay '(0 0 100000)
|
||||
"Minimal time for other idle processes before switching back to agent.")
|
||||
(defvar org-indent-initial-marker nil
|
||||
"Position of initialization before interrupt.
|
||||
This is used locally in each buffer being initialized.")
|
||||
(defvar org-hide-leading-stars-before-indent-mode nil
|
||||
"Used locally.")
|
||||
(defvar org-indent-modified-headline-flag nil
|
||||
"Non-nil means the last deletion operated on a headline.
|
||||
It is modified by `org-indent-notify-modified-headline'.")
|
||||
|
||||
|
||||
(defcustom org-indent-boundary-char ?\s
|
||||
"The end of the virtual indentation strings, a single-character string.
|
||||
The default is just a space, but if you wish, you can use \"|\" or so.
|
||||
This can be useful on a terminal window - under a windowing system,
|
||||
it may be prettier to customize the `org-indent' face."
|
||||
:group 'org-indent
|
||||
:type 'character)
|
||||
|
||||
(defcustom org-indent-mode-turns-off-org-adapt-indentation t
|
||||
"Non-nil means setting the variable `org-indent-mode' will \
|
||||
turn off indentation adaptation.
|
||||
For details see the variable `org-adapt-indentation'."
|
||||
:group 'org-indent
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-indent-mode-turns-on-hiding-stars t
|
||||
"Non-nil means setting the variable `org-indent-mode' will \
|
||||
turn on `org-hide-leading-stars'."
|
||||
:group 'org-indent
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-indent-indentation-per-level 2
|
||||
"Indentation per level in number of characters."
|
||||
:group 'org-indent
|
||||
:type 'integer)
|
||||
|
||||
(defface org-indent '((t (:inherit org-hide)))
|
||||
"Face for outline indentation.
|
||||
The default is to make it look like whitespace. But you may find it
|
||||
useful to make it ever so slightly different."
|
||||
:group 'org-faces)
|
||||
|
||||
(defsubst org-indent-remove-properties (beg end)
|
||||
"Remove indentations between BEG and END."
|
||||
(org-with-silent-modifications
|
||||
(remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode org-indent-mode
|
||||
"When active, indent text according to outline structure.
|
||||
|
||||
Internally this works by adding `line-prefix' and `wrap-prefix'
|
||||
properties, after each buffer modification, on the modified zone.
|
||||
|
||||
The process is synchronous. Though, initial indentation of
|
||||
buffer, which can take a few seconds on large buffers, is done
|
||||
during idle time."
|
||||
nil " Ind" nil
|
||||
(cond
|
||||
((and org-indent-mode (featurep 'xemacs))
|
||||
(message "org-indent-mode does not work in XEmacs - refusing to turn it on")
|
||||
(setq org-indent-mode nil))
|
||||
((and org-indent-mode
|
||||
(not (org-version-check "23.1.50" "Org Indent mode" :predicate)))
|
||||
(message "org-indent-mode can crash Emacs 23.1 - refusing to turn it on!")
|
||||
(ding)
|
||||
(sit-for 1)
|
||||
(setq org-indent-mode nil))
|
||||
(org-indent-mode
|
||||
;; mode was turned on.
|
||||
(org-set-local 'indent-tabs-mode nil)
|
||||
(org-set-local 'org-indent-initial-marker (copy-marker 1))
|
||||
(when org-indent-mode-turns-off-org-adapt-indentation
|
||||
(org-set-local 'org-adapt-indentation nil))
|
||||
(when org-indent-mode-turns-on-hiding-stars
|
||||
(org-set-local 'org-hide-leading-stars-before-indent-mode
|
||||
org-hide-leading-stars)
|
||||
(org-set-local 'org-hide-leading-stars t))
|
||||
(org-add-hook 'filter-buffer-substring-functions
|
||||
(lambda (fun start end delete)
|
||||
(org-indent-remove-properties-from-string
|
||||
(funcall fun start end delete)))
|
||||
nil t)
|
||||
(org-add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local)
|
||||
(org-add-hook 'before-change-functions
|
||||
'org-indent-notify-modified-headline nil 'local)
|
||||
(and font-lock-mode (org-restart-font-lock))
|
||||
(org-indent-remove-properties (point-min) (point-max))
|
||||
;; Submit current buffer to initialize agent. If it's the first
|
||||
;; buffer submitted, also start the agent. Current buffer is
|
||||
;; pushed in both cases to avoid a race condition.
|
||||
(if org-indent-agentized-buffers
|
||||
(push (current-buffer) org-indent-agentized-buffers)
|
||||
(push (current-buffer) org-indent-agentized-buffers)
|
||||
(setq org-indent-agent-timer
|
||||
(run-with-idle-timer 0.2 t #'org-indent-initialize-agent))))
|
||||
(t
|
||||
;; mode was turned off (or we refused to turn it on)
|
||||
(kill-local-variable 'org-adapt-indentation)
|
||||
(setq org-indent-agentized-buffers
|
||||
(delq (current-buffer) org-indent-agentized-buffers))
|
||||
(when (markerp org-indent-initial-marker)
|
||||
(set-marker org-indent-initial-marker nil))
|
||||
(when (boundp 'org-hide-leading-stars-before-indent-mode)
|
||||
(org-set-local 'org-hide-leading-stars
|
||||
org-hide-leading-stars-before-indent-mode))
|
||||
(remove-hook 'filter-buffer-substring-functions
|
||||
(lambda (fun start end delete)
|
||||
(org-indent-remove-properties-from-string
|
||||
(funcall fun start end delete))))
|
||||
(remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local)
|
||||
(remove-hook 'before-change-functions
|
||||
'org-indent-notify-modified-headline 'local)
|
||||
(org-with-wide-buffer
|
||||
(org-indent-remove-properties (point-min) (point-max)))
|
||||
(and font-lock-mode (org-restart-font-lock))
|
||||
(redraw-display))))
|
||||
|
||||
(defun org-indent-indent-buffer ()
|
||||
"Add indentation properties to the accessible part of the buffer."
|
||||
(interactive)
|
||||
(if (not (derived-mode-p 'org-mode))
|
||||
(error "Not in Org mode")
|
||||
(message "Setting buffer indentation. It may take a few seconds...")
|
||||
(org-indent-remove-properties (point-min) (point-max))
|
||||
(org-indent-add-properties (point-min) (point-max))
|
||||
(message "Indentation of buffer set.")))
|
||||
|
||||
(defun org-indent-remove-properties-from-string (string)
|
||||
"Remove indentation properties from STRING."
|
||||
(remove-text-properties 0 (length string)
|
||||
'(line-prefix nil wrap-prefix nil) string)
|
||||
string)
|
||||
|
||||
(defun org-indent-initialize-agent ()
|
||||
"Start or resume current buffer initialization.
|
||||
Only buffers in `org-indent-agentized-buffers' trigger an action.
|
||||
When no more buffer is being watched, the agent suppress itself."
|
||||
(when org-indent-agent-resume-timer
|
||||
(cancel-timer org-indent-agent-resume-timer))
|
||||
(setq org-indent-agentized-buffers
|
||||
(org-remove-if-not #'buffer-live-p org-indent-agentized-buffers))
|
||||
(cond
|
||||
;; Job done: kill agent.
|
||||
((not org-indent-agentized-buffers) (cancel-timer org-indent-agent-timer))
|
||||
;; Current buffer is agentized: start/resume initialization
|
||||
;; somewhat aggressively.
|
||||
((memq (current-buffer) org-indent-agentized-buffers)
|
||||
(org-indent-initialize-buffer (current-buffer)
|
||||
org-indent-agent-active-delay))
|
||||
;; Else, start/resume initialization of the last agentized buffer,
|
||||
;; softly.
|
||||
(t (org-indent-initialize-buffer (car org-indent-agentized-buffers)
|
||||
org-indent-agent-passive-delay))))
|
||||
|
||||
(defun org-indent-initialize-buffer (buffer delay)
|
||||
"Set virtual indentation for the buffer BUFFER, asynchronously.
|
||||
Give hand to other idle processes if it takes longer than DELAY,
|
||||
a time value."
|
||||
(with-current-buffer buffer
|
||||
(when org-indent-mode
|
||||
(org-with-wide-buffer
|
||||
(let ((interruptp
|
||||
;; Always nil unless interrupted.
|
||||
(catch 'interrupt
|
||||
(and org-indent-initial-marker
|
||||
(marker-position org-indent-initial-marker)
|
||||
(org-indent-add-properties org-indent-initial-marker
|
||||
(point-max)
|
||||
delay)
|
||||
nil))))
|
||||
(move-marker org-indent-initial-marker interruptp)
|
||||
;; Job is complete: un-agentize buffer.
|
||||
(unless interruptp
|
||||
(setq org-indent-agentized-buffers
|
||||
(delq buffer org-indent-agentized-buffers))))))))
|
||||
|
||||
(defun org-indent-set-line-properties (level indentation &optional heading)
|
||||
"Set prefix properties on current line an move to next one.
|
||||
|
||||
LEVEL is the current level of heading. INDENTATION is the
|
||||
expected indentation when wrapping line.
|
||||
|
||||
When optional argument HEADING is non-nil, assume line is at
|
||||
a heading. Moreover, if is is `inlinetask', the first star will
|
||||
have `org-warning' face."
|
||||
(let* ((stars (if (<= level 1) ""
|
||||
(make-string (* (1- org-indent-indentation-per-level)
|
||||
(1- level))
|
||||
?*)))
|
||||
(line
|
||||
(cond
|
||||
((and (org-bound-and-true-p org-inlinetask-show-first-star)
|
||||
(eq heading 'inlinetask))
|
||||
(concat org-indent-inlinetask-first-star
|
||||
(org-add-props (substring stars 1) nil 'face 'org-hide)))
|
||||
(heading (org-add-props stars nil 'face 'org-hide))
|
||||
(t (concat (org-add-props (concat stars (make-string level ?*))
|
||||
nil 'face 'org-indent)
|
||||
(and (> level 0)
|
||||
(char-to-string org-indent-boundary-char))))))
|
||||
(wrap
|
||||
(org-add-props
|
||||
(concat stars
|
||||
(make-string level ?*)
|
||||
(if heading " "
|
||||
(make-string (+ indentation (min level 1)) ?\s)))
|
||||
nil 'face 'org-indent)))
|
||||
;; Add properties down to the next line to indent empty lines.
|
||||
(add-text-properties (line-beginning-position) (line-beginning-position 2)
|
||||
`(line-prefix ,line wrap-prefix ,wrap)))
|
||||
(forward-line))
|
||||
|
||||
(defun org-indent-add-properties (beg end &optional delay)
|
||||
"Add indentation properties between BEG and END.
|
||||
|
||||
When DELAY is non-nil, it must be a time value. In that case,
|
||||
the process is asynchronous and can be interrupted, either by
|
||||
user request, or after DELAY. This is done by throwing the
|
||||
`interrupt' tag along with the buffer position where the process
|
||||
stopped."
|
||||
(save-match-data
|
||||
(org-with-wide-buffer
|
||||
(goto-char beg)
|
||||
(beginning-of-line)
|
||||
;; Initialize prefix at BEG, according to current entry's level.
|
||||
(let* ((case-fold-search t)
|
||||
(limited-re (org-get-limited-outline-regexp))
|
||||
(level (or (org-current-level) 0))
|
||||
(time-limit (and delay (time-add (current-time) delay))))
|
||||
;; For each line, set `line-prefix' and `wrap-prefix'
|
||||
;; properties depending on the type of line (headline, inline
|
||||
;; task, item or other).
|
||||
(org-with-silent-modifications
|
||||
(while (and (<= (point) end) (not (eobp)))
|
||||
(cond
|
||||
;; When in asynchronous mode, check if interrupt is
|
||||
;; required.
|
||||
((and delay (input-pending-p)) (throw 'interrupt (point)))
|
||||
;; In asynchronous mode, take a break of
|
||||
;; `org-indent-agent-resume-delay' every DELAY to avoid
|
||||
;; blocking any other idle timer or process output.
|
||||
((and delay (time-less-p time-limit (current-time)))
|
||||
(setq org-indent-agent-resume-timer
|
||||
(run-with-idle-timer
|
||||
(time-add (current-idle-time) org-indent-agent-resume-delay)
|
||||
nil #'org-indent-initialize-agent))
|
||||
(throw 'interrupt (point)))
|
||||
;; Headline or inline task.
|
||||
((looking-at org-outline-regexp)
|
||||
(let* ((nstars (- (match-end 0) (match-beginning 0) 1))
|
||||
(type (or (org-looking-at-p limited-re) 'inlinetask)))
|
||||
(org-indent-set-line-properties nstars 0 type)
|
||||
;; At an headline, define new value for LEVEL.
|
||||
(unless (eq type 'inlinetask) (setq level nstars))))
|
||||
;; List item: `wrap-prefix' is set where body starts.
|
||||
((org-at-item-p)
|
||||
(org-indent-set-line-properties
|
||||
level (org-list-item-body-column (point))))
|
||||
;; Regular line.
|
||||
(t
|
||||
(org-indent-set-line-properties level (org-get-indentation))))))))))
|
||||
|
||||
(defun org-indent-notify-modified-headline (beg end)
|
||||
"Set `org-indent-modified-headline-flag' depending on context.
|
||||
|
||||
BEG and END are the positions of the beginning and end of the
|
||||
range of deleted text.
|
||||
|
||||
This function is meant to be called by `before-change-functions'.
|
||||
Flag will be non-nil if command is going to modify or delete an
|
||||
headline."
|
||||
(when org-indent-mode
|
||||
(setq org-indent-modified-headline-flag
|
||||
(org-with-wide-buffer
|
||||
(goto-char beg)
|
||||
(save-match-data
|
||||
(or (and (org-at-heading-p) (< beg (match-end 0)))
|
||||
(re-search-forward
|
||||
(org-with-limited-levels org-outline-regexp-bol) end t)))))))
|
||||
|
||||
(defun org-indent-refresh-maybe (beg end dummy)
|
||||
"Refresh indentation properties in an adequate portion of buffer.
|
||||
BEG and END are the positions of the beginning and end of the
|
||||
range of inserted text. DUMMY is an unused argument.
|
||||
|
||||
This function is meant to be called by `after-change-functions'."
|
||||
(when org-indent-mode
|
||||
(save-match-data
|
||||
;; If a headline was modified or inserted, set properties until
|
||||
;; next headline.
|
||||
(org-with-wide-buffer
|
||||
(if (or org-indent-modified-headline-flag
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(beginning-of-line)
|
||||
(re-search-forward
|
||||
(org-with-limited-levels org-outline-regexp-bol) end t)))
|
||||
(let ((end (save-excursion
|
||||
(goto-char end)
|
||||
(org-with-limited-levels (outline-next-heading))
|
||||
(point))))
|
||||
(setq org-indent-modified-headline-flag nil)
|
||||
(org-indent-add-properties beg end))
|
||||
;; Otherwise, only set properties on modified area.
|
||||
(org-indent-add-properties beg end))))))
|
||||
|
||||
(provide 'org-indent)
|
||||
|
||||
;; Local variables:
|
||||
;; generated-autoload-file: "org-loaddefs.el"
|
||||
;; End:
|
||||
|
||||
;;; org-indent.el ends here
|
99
elpa/org-20160919/org-info.el
Normal file
99
elpa/org-20160919/org-info.el
Normal file
@ -0,0 +1,99 @@
|
||||
;;; org-info.el --- Support for links to Info nodes from within Org-Mode
|
||||
|
||||
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;; This file implements links to Info nodes from within Org-mode.
|
||||
;; Org-mode loads this module by default - if this is not what you want,
|
||||
;; configure the variable `org-modules'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
;; Declare external functions and variables
|
||||
|
||||
(declare-function Info-find-node "info"
|
||||
(filename nodename &optional no-going-back strict-case))
|
||||
(defvar Info-current-file)
|
||||
(defvar Info-current-node)
|
||||
|
||||
;; Install the link type
|
||||
(org-add-link-type "info" 'org-info-open 'org-info-export)
|
||||
(add-hook 'org-store-link-functions 'org-info-store-link)
|
||||
|
||||
;; Implementation
|
||||
(defun org-info-store-link ()
|
||||
"Store a link to an Info file and node."
|
||||
(when (eq major-mode 'Info-mode)
|
||||
(let (link desc)
|
||||
(setq link (concat "info:"
|
||||
(file-name-nondirectory Info-current-file)
|
||||
"#" Info-current-node))
|
||||
(setq desc (concat (file-name-nondirectory Info-current-file)
|
||||
"#" Info-current-node))
|
||||
(org-store-link-props :type "info" :file Info-current-file
|
||||
:node Info-current-node
|
||||
:link link :desc desc)
|
||||
link)))
|
||||
|
||||
(defun org-info-open (path)
|
||||
"Follow an Info file and node link specified by PATH."
|
||||
(org-info-follow-link path))
|
||||
|
||||
|
||||
(defun org-info-follow-link (name)
|
||||
"Follow an Info file and node link specified by NAME."
|
||||
(if (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" name)
|
||||
(string-match "\\(.*\\)" name))
|
||||
(let ((filename (match-string 1 name))
|
||||
(nodename-or-index (or (match-string 2 name) "Top")))
|
||||
(require 'info)
|
||||
;; If nodename-or-index is invalid node name, then look it up
|
||||
;; in the index.
|
||||
(condition-case nil
|
||||
(Info-find-node filename nodename-or-index)
|
||||
(user-error (Info-find-node filename "Top")
|
||||
(condition-case nil
|
||||
(Info-index nodename-or-index)
|
||||
(user-error "Could not find '%s' node or index entry"
|
||||
nodename-or-index)))))
|
||||
(user-error "Could not open: %s" name)))
|
||||
|
||||
(defun org-info-export (path desc format)
|
||||
"Export an info link.
|
||||
See `org-add-link-type' for details about PATH, DESC and FORMAT."
|
||||
(when (eq format 'html)
|
||||
(or (string-match "\\(.*\\)[#:]:?\\(.*\\)" path)
|
||||
(string-match "\\(.*\\)" path))
|
||||
(let ((filename (match-string 1 path))
|
||||
(node (or (match-string 2 path) "Top")))
|
||||
(format "<a href=\"%s.html#%s\">%s</a>"
|
||||
filename
|
||||
(replace-regexp-in-string " " "-" node)
|
||||
(or desc path)))))
|
||||
|
||||
(provide 'org-info)
|
||||
|
||||
;;; org-info.el ends here
|
350
elpa/org-20160919/org-inlinetask.el
Normal file
350
elpa/org-20160919/org-inlinetask.el
Normal file
@ -0,0 +1,350 @@
|
||||
;;; org-inlinetask.el --- Tasks independent of outline hierarchy
|
||||
|
||||
;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This module implements inline tasks in Org-mode. Inline tasks are
|
||||
;; tasks that have all the properties of normal outline nodes,
|
||||
;; including the ability to store meta data like scheduling dates,
|
||||
;; TODO state, tags and properties. However, these nodes are treated
|
||||
;; specially by the visibility cycling.
|
||||
;;
|
||||
;; Visibility cycling exempts these nodes from cycling. So whenever
|
||||
;; their parent is opened, so are these tasks. This will only work
|
||||
;; with `org-cycle', so if you are also using other commands to
|
||||
;; show/hide entries, you will occasionally find these tasks to behave
|
||||
;; like all other outline nodes, seemingly splitting the text of the
|
||||
;; parent into children.
|
||||
;;
|
||||
;; Special fontification of inline tasks, so that they can be
|
||||
;; immediately recognized. From the stars of the headline, only the
|
||||
;; first and the last two will be visible, the others will be hidden
|
||||
;; using the `org-hide' face.
|
||||
;;
|
||||
;; An inline task is identified solely by a minimum outline level,
|
||||
;; given by the variable `org-inlinetask-min-level', default 15.
|
||||
;;
|
||||
;; If you need to have a time planning line (DEADLINE etc), drawers,
|
||||
;; for example LOGBOOK of PROPERTIES, or even normal text as part of
|
||||
;; the inline task, you must add an "END" headline with the same
|
||||
;; number of stars.
|
||||
;;
|
||||
;; As an example, here are two valid inline tasks:
|
||||
;;
|
||||
;; **************** TODO a small task
|
||||
;;
|
||||
;; and
|
||||
;;
|
||||
;; **************** TODO another small task
|
||||
;; DEADLINE: <2009-03-30 Mon>
|
||||
;; :PROPERTIES:
|
||||
;; :SOMETHING: or other
|
||||
;; :END:
|
||||
;; And here is some extra text
|
||||
;; **************** END
|
||||
;;
|
||||
;; Also, if you want to use refiling and archiving for inline tasks,
|
||||
;; The END line must be present to make things work properly.
|
||||
;;
|
||||
;; Note that you should not try to use inline tasks within plain list,
|
||||
;; visibility cycling is known to be problematic when doing so.
|
||||
;;
|
||||
;; This package installs one new command:
|
||||
;;
|
||||
;; C-c C-x t Insert a new inline task with END line
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defgroup org-inlinetask nil
|
||||
"Options concerning inline tasks in Org mode."
|
||||
:tag "Org Inline Tasks"
|
||||
:group 'org-structure)
|
||||
|
||||
(defcustom org-inlinetask-min-level 15
|
||||
"Minimum level a headline must have before it is treated as an inline task.
|
||||
Don't set it to something higher than `29' or clocking will break since this
|
||||
is the hardcoded maximum number of stars `org-clock-sum' will work with.
|
||||
|
||||
It is strongly recommended that you set `org-cycle-max-level' not at all,
|
||||
or to a number smaller than this one. In fact, when `org-cycle-max-level' is
|
||||
not set, it will be assumed to be one less than the value of smaller than
|
||||
the value of this variable."
|
||||
:group 'org-inlinetask
|
||||
:type '(choice
|
||||
(const :tag "Off" nil)
|
||||
(integer)))
|
||||
|
||||
(defcustom org-inlinetask-show-first-star nil
|
||||
"Non-nil means display the first star of an inline task as additional marker.
|
||||
When nil, the first star is not shown."
|
||||
:tag "Org Inline Tasks"
|
||||
:group 'org-structure
|
||||
:type 'boolean)
|
||||
|
||||
(defvar org-odd-levels-only)
|
||||
(defvar org-keyword-time-regexp)
|
||||
(defvar org-complex-heading-regexp)
|
||||
(defvar org-property-end-re)
|
||||
|
||||
(defcustom org-inlinetask-default-state nil
|
||||
"Non-nil means make inline tasks have a TODO keyword initially.
|
||||
This should be the state `org-inlinetask-insert-task' should use by
|
||||
default, or nil of no state should be assigned."
|
||||
:group 'org-inlinetask
|
||||
:version "24.1"
|
||||
:type '(choice
|
||||
(const :tag "No state" nil)
|
||||
(string :tag "Specific state")))
|
||||
|
||||
(defun org-inlinetask-insert-task (&optional no-state)
|
||||
"Insert an inline task.
|
||||
If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'."
|
||||
(interactive "P")
|
||||
;; Error when inside an inline task, except if point was at its very
|
||||
;; beginning, in which case the new inline task will be inserted
|
||||
;; before this one.
|
||||
(when (and (org-inlinetask-in-task-p)
|
||||
(not (and (org-inlinetask-at-task-p) (bolp))))
|
||||
(error "Cannot nest inline tasks"))
|
||||
(or (bolp) (newline))
|
||||
(let* ((indent (if org-odd-levels-only
|
||||
(1- (* 2 org-inlinetask-min-level))
|
||||
org-inlinetask-min-level))
|
||||
(indent-string (concat (make-string indent ?*) " ")))
|
||||
(insert indent-string
|
||||
(if (or no-state (not org-inlinetask-default-state))
|
||||
"\n"
|
||||
(concat org-inlinetask-default-state " \n"))
|
||||
indent-string "END\n"))
|
||||
(end-of-line -1))
|
||||
(define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)
|
||||
|
||||
(defun org-inlinetask-outline-regexp ()
|
||||
"Return string matching an inline task heading.
|
||||
The number of levels is controlled by `org-inlinetask-min-level'."
|
||||
(let ((nstars (if org-odd-levels-only
|
||||
(1- (* org-inlinetask-min-level 2))
|
||||
org-inlinetask-min-level)))
|
||||
(format "^\\(\\*\\{%d,\\}\\)[ \t]+" nstars)))
|
||||
|
||||
(defun org-inlinetask-at-task-p ()
|
||||
"Return true if point is at beginning of an inline task."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(and (looking-at (concat (org-inlinetask-outline-regexp) "\\(.*\\)"))
|
||||
(not (string-match "^end[ \t]*$" (downcase (match-string 2)))))))
|
||||
|
||||
(defun org-inlinetask-in-task-p ()
|
||||
"Return true if point is inside an inline task."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(let* ((case-fold-search t)
|
||||
(stars-re (org-inlinetask-outline-regexp))
|
||||
(task-beg-re (concat stars-re "\\(?:.*\\)"))
|
||||
(task-end-re (concat stars-re "END[ \t]*$")))
|
||||
(or (org-looking-at-p task-beg-re)
|
||||
(and (re-search-forward "^\\*+[ \t]+" nil t)
|
||||
(progn (beginning-of-line) (org-looking-at-p task-end-re)))))))
|
||||
|
||||
(defun org-inlinetask-goto-beginning ()
|
||||
"Go to the beginning of the inline task at point."
|
||||
(end-of-line)
|
||||
(let ((case-fold-search t)
|
||||
(inlinetask-re (org-inlinetask-outline-regexp)))
|
||||
(re-search-backward inlinetask-re nil t)
|
||||
(when (org-looking-at-p (concat inlinetask-re "END[ \t]*$"))
|
||||
(re-search-backward inlinetask-re nil t))))
|
||||
|
||||
(defun org-inlinetask-goto-end ()
|
||||
"Go to the end of the inline task at point.
|
||||
Return point."
|
||||
(save-match-data
|
||||
(beginning-of-line)
|
||||
(let* ((case-fold-search t)
|
||||
(inlinetask-re (org-inlinetask-outline-regexp))
|
||||
(task-end-re (concat inlinetask-re "END[ \t]*$")))
|
||||
(cond
|
||||
((looking-at task-end-re) (forward-line))
|
||||
((looking-at inlinetask-re)
|
||||
(forward-line)
|
||||
(cond
|
||||
((looking-at task-end-re) (forward-line))
|
||||
((looking-at inlinetask-re))
|
||||
((org-inlinetask-in-task-p)
|
||||
(re-search-forward inlinetask-re nil t)
|
||||
(forward-line))))
|
||||
(t (re-search-forward inlinetask-re nil t)
|
||||
(forward-line)))
|
||||
(point))))
|
||||
|
||||
(defun org-inlinetask-get-task-level ()
|
||||
"Get the level of the inline task around.
|
||||
This assumes the point is inside an inline task."
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
(re-search-backward (org-inlinetask-outline-regexp) nil t)
|
||||
(- (match-end 1) (match-beginning 1))))
|
||||
|
||||
(defun org-inlinetask-promote ()
|
||||
"Promote the inline task at point.
|
||||
If the task has an end part, promote it. Also, prevents level from
|
||||
going below `org-inlinetask-min-level'."
|
||||
(interactive)
|
||||
(if (not (org-inlinetask-in-task-p))
|
||||
(error "Not in an inline task")
|
||||
(save-excursion
|
||||
(let* ((lvl (org-inlinetask-get-task-level))
|
||||
(next-lvl (org-get-valid-level lvl -1))
|
||||
(diff (- next-lvl lvl))
|
||||
(down-task (concat (make-string next-lvl ?*)))
|
||||
beg)
|
||||
(if (< next-lvl org-inlinetask-min-level)
|
||||
(error "Cannot promote an inline task at minimum level")
|
||||
(org-inlinetask-goto-beginning)
|
||||
(setq beg (point))
|
||||
(replace-match down-task nil t nil 1)
|
||||
(org-inlinetask-goto-end)
|
||||
(if (eobp) (beginning-of-line) (forward-line -1))
|
||||
(unless (= (point) beg)
|
||||
(replace-match down-task nil t nil 1)
|
||||
(when org-adapt-indentation
|
||||
(goto-char beg)
|
||||
(org-fixup-indentation diff))))))))
|
||||
|
||||
(defun org-inlinetask-demote ()
|
||||
"Demote the inline task at point.
|
||||
If the task has an end part, also demote it."
|
||||
(interactive)
|
||||
(if (not (org-inlinetask-in-task-p))
|
||||
(error "Not in an inline task")
|
||||
(save-excursion
|
||||
(let* ((lvl (org-inlinetask-get-task-level))
|
||||
(next-lvl (org-get-valid-level lvl 1))
|
||||
(diff (- next-lvl lvl))
|
||||
(down-task (concat (make-string next-lvl ?*)))
|
||||
beg)
|
||||
(org-inlinetask-goto-beginning)
|
||||
(setq beg (point))
|
||||
(replace-match down-task nil t nil 1)
|
||||
(org-inlinetask-goto-end)
|
||||
(if (eobp) (beginning-of-line) (forward-line -1))
|
||||
(unless (= (point) beg)
|
||||
(replace-match down-task nil t nil 1)
|
||||
(when org-adapt-indentation
|
||||
(goto-char beg)
|
||||
(org-fixup-indentation diff)))))))
|
||||
|
||||
(defun org-inlinetask-get-current-indentation ()
|
||||
"Get the indentation of the last non-while line above this one."
|
||||
(save-excursion
|
||||
(beginning-of-line 1)
|
||||
(skip-chars-backward " \t\n")
|
||||
(beginning-of-line 1)
|
||||
(or (org-at-item-p)
|
||||
(looking-at "[ \t]*"))
|
||||
(goto-char (match-end 0))
|
||||
(current-column)))
|
||||
|
||||
(defvar org-indent-indentation-per-level) ; defined in org-indent.el
|
||||
|
||||
(defface org-inlinetask
|
||||
(org-compatible-face 'shadow '((t (:bold t))))
|
||||
"Face for inlinetask headlines."
|
||||
:group 'org-faces)
|
||||
|
||||
(defun org-inlinetask-fontify (limit)
|
||||
"Fontify the inline tasks down to LIMIT."
|
||||
(let* ((nstars (if org-odd-levels-only
|
||||
(1- (* 2 (or org-inlinetask-min-level 200)))
|
||||
(or org-inlinetask-min-level 200)))
|
||||
(re (concat "^\\(\\*\\)\\(\\*\\{"
|
||||
(format "%d" (- nstars 3))
|
||||
",\\}\\)\\(\\*\\* .*\\)"))
|
||||
;; Virtual indentation will add the warning face on the first
|
||||
;; star. Thus, in that case, only hide it.
|
||||
(start-face (if (and (org-bound-and-true-p org-indent-mode)
|
||||
(> org-indent-indentation-per-level 1))
|
||||
'org-hide
|
||||
'org-warning)))
|
||||
(while (re-search-forward re limit t)
|
||||
(if org-inlinetask-show-first-star
|
||||
(add-text-properties (match-beginning 1) (match-end 1)
|
||||
`(face ,start-face font-lock-fontified t)))
|
||||
(add-text-properties (match-beginning
|
||||
(if org-inlinetask-show-first-star 2 1))
|
||||
(match-end 2)
|
||||
'(face org-hide font-lock-fontified t))
|
||||
(add-text-properties (match-beginning 3) (match-end 3)
|
||||
'(face org-inlinetask font-lock-fontified t)))))
|
||||
|
||||
(defun org-inlinetask-toggle-visibility ()
|
||||
"Toggle visibility of inline task at point."
|
||||
(let ((end (save-excursion
|
||||
(org-inlinetask-goto-end)
|
||||
(if (bolp) (1- (point)) (point))))
|
||||
(start (save-excursion
|
||||
(org-inlinetask-goto-beginning)
|
||||
(point-at-eol))))
|
||||
(cond
|
||||
;; Nothing to show/hide.
|
||||
((= end start))
|
||||
;; Inlinetask was folded: expand it.
|
||||
((eq (get-char-property (1+ start) 'invisible) 'outline)
|
||||
(outline-flag-region start end nil)
|
||||
(org-cycle-hide-drawers 'children))
|
||||
(t (outline-flag-region start end t)))))
|
||||
|
||||
(defun org-inlinetask-hide-tasks (state)
|
||||
"Hide inline tasks in buffer when STATE is `contents' or `children'.
|
||||
This function is meant to be used in `org-cycle-hook'."
|
||||
(case state
|
||||
(contents
|
||||
(let ((regexp (org-inlinetask-outline-regexp)))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward regexp nil t)
|
||||
(org-inlinetask-toggle-visibility)
|
||||
(org-inlinetask-goto-end)))))
|
||||
(children
|
||||
(save-excursion
|
||||
(while (and (outline-next-heading) (org-inlinetask-at-task-p))
|
||||
(org-inlinetask-toggle-visibility)
|
||||
(org-inlinetask-goto-end))))))
|
||||
|
||||
(defun org-inlinetask-remove-END-maybe ()
|
||||
"Remove an END line when present."
|
||||
(when (looking-at (format "\\([ \t]*\n\\)*\\*\\{%d,\\}[ \t]+END[ \t]*$"
|
||||
org-inlinetask-min-level))
|
||||
(replace-match "")))
|
||||
|
||||
(add-hook 'org-font-lock-hook 'org-inlinetask-fontify)
|
||||
(add-hook 'org-cycle-hook 'org-inlinetask-hide-tasks)
|
||||
|
||||
(provide 'org-inlinetask)
|
||||
|
||||
;;; org-inlinetask.el ends here
|
17
elpa/org-20160919/org-install.el
Normal file
17
elpa/org-20160919/org-install.el
Normal file
@ -0,0 +1,17 @@
|
||||
;;; org-install.el --- backward compatibility file for obsolete configuration
|
||||
;;
|
||||
;;; Code:
|
||||
;;
|
||||
;; The file org-install is obsolete.
|
||||
;;
|
||||
;; It is provided here so that (require 'org-install) does not
|
||||
;; trigger an error for users with obsolete Emacs configuration.
|
||||
;; You can safely remove (require 'org-install) from your config."
|
||||
|
||||
(provide 'org-install)
|
||||
|
||||
;; Local Variables:
|
||||
;; no-byte-compile: t
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; org-install.el ends here
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user