Merge branch 'maint' into emacs-sync

This commit is contained in:
Kyle Meyer 2017-05-15 17:48:34 -04:00
commit db91535701
16 changed files with 1710 additions and 1356 deletions

View File

@ -5,7 +5,7 @@
;; Author: Kyle Meyer <kyle@kyleam.com>
;; URL: https://gitlab.com/kyleam/org-link-edit
;; Keywords: convenience
;; Version: 1.1.0
;; Version: 1.1.1
;; Package-Requires: ((cl-lib "0.5") (org "8.2.10"))
;; This program is free software; you can redistribute it and/or modify
@ -373,17 +373,18 @@ END."
(progn (goto-char pt)
(org-link-edit--on-link-p)))
(user-error "Cannot transport next link with point on a link"))
(goto-char (car desc-bounds))
(cl-multiple-value-bind (link-beg link-end link desc)
(goto-char (or (car desc-bounds) pt))
(cl-multiple-value-bind (link-beg link-end link orig-desc)
(org-link-edit--next-link-data previous)
(unless (or (not desc-bounds) (= (length desc) 0))
(unless (or (not desc-bounds) (= (length orig-desc) 0))
(user-error "Link already has a description"))
(delete-region link-beg link-end)
(insert (org-make-link-string
link
(and desc-bounds
(delete-and-extract-region (car desc-bounds)
(cdr desc-bounds))))))))
(if desc-bounds
(delete-and-extract-region (car desc-bounds)
(cdr desc-bounds))
orig-desc))))))
(provide 'org-link-edit)
;;; org-link-edit.el ends here

View File

@ -56,7 +56,7 @@
;;; Code:
(require 'ox)
(eval-when-compile (require 'cl))
(require 'cl-lib)
(defun org-latex-header-blocks-filter (backend)
(when (org-export-derived-backend-p backend 'latex)
@ -72,8 +72,10 @@
(org-element-property :post-affiliated block)))))))
(mapc (lambda (pos)
(goto-char (nth 2 pos))
(destructuring-bind
(cl-destructuring-bind
(beg end &rest ignore)
;; FIXME: `org-edit-src-find-region-and-lang' was
;; removed in 9c06f8cce (2014-11-11).
(org-edit-src-find-region-and-lang)
(let ((contents-lines (split-string
(buffer-substring-no-properties beg end)
@ -150,8 +152,27 @@ parent."
(org-element-contents object)))
(org-element-extract-element object)))
info nil)
(org-extra--merge-sections data backend info)
data)
(defun org-extra--merge-sections (data _backend info)
(org-element-map data 'headline
(lambda (hl)
(let ((sections
(cl-loop
for el in (org-element-map (org-element-contents hl)
'(headline section) #'identity info)
until (eq (org-element-type el) 'headline)
collect el)))
(when (and sections
(> (length sections) 1))
(apply #'org-element-adopt-elements
(car sections)
(cl-mapcan (lambda (s) (org-element-contents s))
(cdr sections)))
(mapc #'org-element-extract-element (cdr sections)))))
info))
(defconst ox-extras
'((latex-header-blocks org-latex-header-blocks-filter org-export-before-parsing-hook)
(ignore-headlines org-export-ignore-headlines org-export-filter-parse-tree-functions))

View File

@ -304,13 +304,15 @@ holding export options."
"Return complete document string after HTML conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
(let ((org-html-divs
(if (equal (plist-get info :html-container) "li")
(append '((content "ol" "content")) org-s5--divs)
org-s5--divs))
(info (plist-put
(let ((info (plist-put
(plist-put
(plist-put info :html-preamble (plist-get info :s5-preamble))
:html-postamble (plist-get info :s5-postamble))))
:html-postamble
(plist-get info :s5-postamble))
:html-divs
(if (equal "li" (plist-get info :html-container))
(cons '(content "ol" "content") org-s5--divs)
org-s5--divs))))
(mapconcat
'identity
(list

File diff suppressed because it is too large Load Diff

View File

@ -1487,19 +1487,17 @@ balanced instances of \"[ \t]:\", set ALTS to ((32 9) . 58)."
(push after partial)
(goto-char (1+ origin)))))
((and (eq ?\" (char-after)) (not (eq ?\\ (char-before))))
;; Include everything between non-escaped double quotes.
(push ?\" partial)
;; Include everything from current double quote to next
;; non-escaped double quote.
(let ((origin (point)))
(condition-case nil
;; Use `read' since it is fast and takes care of
;; escaped quotes already.
(if (re-search-forward "[^\\]\"" nil t)
(setq partial
(nconc (cons ?\"
(nreverse (string-to-list
(read (current-buffer)))))
(nconc (nreverse (string-to-list
(buffer-substring origin (point))))
partial))
;; No closing double quote found. Backtrack.
(end-of-file (goto-char (1+ origin))))))
;; No closing double quote. Backtrack.
(push ?\" partial)
(forward-char))))
(t (push (char-after) partial)
(forward-char))))
;; Add pending parsing and return result.

View File

@ -187,7 +187,7 @@ This function is called by `org-babel-execute-src-block'."
script-file
(if (member system-type '(cygwin windows-nt ms-dos))
t nil)))))
(message output))
(message "%s" output))
(with-temp-buffer
(insert (concat body "\n"))
(gnuplot-mode)

View File

@ -131,7 +131,7 @@ the variable."
;; if ref is indexed grab the indices -- beware nested indices
(when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref)
(let ((str (substring ref 0 (match-beginning 0))))
(= (cl-count ?( str) (cl-count ?) str))))
(= (cl-count ?\( str) (cl-count ?\) str))))
(setq index (match-string 1 ref))
(setq ref (substring ref 0 (match-beginning 0))))
;; assign any arguments to pass to source block

View File

@ -9869,7 +9869,6 @@ This will remove the markers and the overlays."
(interactive)
(if (null org-agenda-bulk-marked-entries)
(message "No entry to unmark")
(mapc (lambda (m) (move-marker m nil)) org-agenda-bulk-marked-entries)
(setq org-agenda-bulk-marked-entries nil)
(org-agenda-bulk-remove-overlays (point-min) (point-max))))
@ -9970,11 +9969,13 @@ The prefix arg is passed through to the command if possible."
(c1 (if (eq action ?s) 'org-agenda-schedule
'org-agenda-deadline)))
;; Make sure to not prompt for a note when bulk
;; rescheduling as Org cannot cope with simultaneous Org.
;; Besides, it could be annoying depending on the number
;; of items re-scheduled.
;; rescheduling as Org cannot cope with simultaneous
;; notes. Besides, it could be annoying depending on the
;; number of items re-scheduled.
(setq cmd `(eval '(let ((org-log-reschedule
(and org-log-reschedule 'time)))
(and org-log-reschedule 'time))
(org-log-redeadline
(and org-log-redeadline 'time)))
(,c1 arg ,time))))))
((equal action ?S)

View File

@ -1961,7 +1961,8 @@ will be easy to remove."
(make-string
(max 0 (- (- 60 (current-column))
(- (match-end 4) (match-beginning 4))
(length (org-get-at-bol 'line-prefix)))) )
(length (org-get-at-bol 'line-prefix))))
?\·)
'(face shadow))
(org-add-props
(format " %9s " (org-minutes-to-clocksum-string time))

View File

@ -3040,7 +3040,8 @@ Assume point is at the beginning of the LaTeX fragment."
(search-forward "$" nil t 2)
(not (memq (char-before (match-beginning 0))
'(?\s ?\t ?\n ?, ?.)))
(looking-at "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|$\\)")
(looking-at-p
"\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
(point)))
(pcase (char-after (1+ (point)))
(?\( (search-forward "\\)" nil t))

View File

@ -535,10 +535,10 @@ An entry can be toggled between COMMENT and normal with
(defconst org-latex-regexps
'(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil)
;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil)
;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
("$1" "\\([^$]\\|^\\)\\(\\$[^ \r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|$\\)" 2 nil)
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|$\\)" 2 nil)
("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))

View File

@ -545,14 +545,14 @@ publishing FILENAME."
(lambda (p)
;; Ignore meta-projects.
(unless (org-publish-property :components p)
(let ((base (expand-file-name
(let ((base (file-truename
(org-publish-property :base-directory p))))
(cond
;; Check if FILENAME is explicitly included in one
;; project.
((member filename
(mapcar (lambda (f) (expand-file-name f base))
(org-publish-property :include p)))
((cl-some (lambda (f) (file-equal-p f filename))
(mapcar (lambda (f) (expand-file-name f base))
(org-publish-property :include p)))
p)
;; Exclude file names matching :exclude property.
((let ((exclude-re (org-publish-property :exclude p)))
@ -571,8 +571,8 @@ publishing FILENAME."
;; directory, or some of its sub-directories
;; if :recursive in non-nil.
((org-publish-property :recursive p)
(and (string-prefix-p base filename) p))
((equal base (file-name-directory filename)) p)
(and (file-in-directory-p filename base) p))
((file-equal-p base (file-name-directory filename)) p)
(t nil)))))
org-publish-project-alist)))
(cond
@ -628,7 +628,8 @@ Return output file name."
plist
`(:crossrefs
,(org-publish-cache-get-file-property
(expand-file-name filename) :crossrefs nil t)
;; Normalize file names in cache.
(file-truename filename) :crossrefs nil t)
:filter-final-output
(org-publish--store-crossrefs
org-publish-collect-index
@ -647,9 +648,9 @@ Return output file name."
(unless (file-directory-p pub-dir)
(make-directory pub-dir t))
(let ((output (expand-file-name (file-name-nondirectory filename) pub-dir)))
(or (equal (expand-file-name (file-name-directory filename))
(file-name-as-directory (expand-file-name pub-dir)))
(copy-file filename output t))
(unless (file-equal-p (expand-file-name (file-name-directory filename))
(file-name-as-directory (expand-file-name pub-dir)))
(copy-file filename output t))
;; Return file name.
output))
@ -664,44 +665,43 @@ If NO-CACHE is not nil, do not initialize `org-publish-cache'.
This is needed, since this function is used to publish single
files, when entire projects are published (see
`org-publish-projects')."
(let* ((project
(let* ((filename (file-truename filename)) ;normalize name
(project
(or project
(or (org-publish-get-project-from-filename filename)
(error "File %s not part of any known project"
(abbreviate-file-name filename)))))
(org-publish-get-project-from-filename filename)
(user-error "File %S is not part of any known project"
(abbreviate-file-name filename))))
(project-plist (cdr project))
(ftname (expand-file-name filename))
(publishing-function
(let ((fun (plist-get project-plist :publishing-function)))
(cond ((null fun) (error "No publishing function chosen"))
((listp fun) fun)
(t (list fun)))))
(pcase (plist-get project-plist :publishing-function)
(`nil (user-error "No publishing function chosen"))
((and f (pred listp)) f)
(f (list f))))
(base-dir
(file-name-as-directory
(expand-file-name
(file-truename
(or (plist-get project-plist :base-directory)
(error "Project %s does not have :base-directory defined"
(car project))))))
(pub-dir
(user-error "Project %S does not have :base-directory defined"
(car project))))))
(pub-base-dir
(file-name-as-directory
(file-truename
(or (eval (plist-get project-plist :publishing-directory))
(error "Project %s does not have :publishing-directory defined"
(car project))))))
tmp-pub-dir)
(user-error
"Project %S does not have :publishing-directory defined"
(car project))))))
(pub-dir
(file-name-directory
(expand-file-name (file-relative-name filename base-dir)
pub-base-dir))))
(unless no-cache (org-publish-initialize-cache (car project)))
(setq tmp-pub-dir
(file-name-directory
(concat pub-dir
(and (string-match (regexp-quote base-dir) ftname)
(substring ftname (match-end 0))))))
;; Allow chain of publishing functions.
(dolist (f publishing-function)
(when (org-publish-needed-p filename pub-dir f tmp-pub-dir base-dir)
(let ((output (funcall f project-plist filename tmp-pub-dir)))
(org-publish-update-timestamp filename pub-dir f base-dir)
(when (org-publish-needed-p filename pub-base-dir f pub-dir base-dir)
(let ((output (funcall f project-plist filename pub-dir)))
(org-publish-update-timestamp filename pub-base-dir f base-dir)
(run-hook-with-args 'org-publish-after-publishing-hook
filename
output))))
@ -742,7 +742,8 @@ If `:auto-sitemap' is set, publish the sitemap too. If
(plist-get project-plist :base-directory)))
(exclude-regexp (plist-get project-plist :exclude)))
(dolist (file (org-publish-get-base-files project exclude-regexp))
(unless (equal file theindex) (org-publish-file file project t)))
(unless (file-equal-p file theindex)
(org-publish-file file project t)))
;; Populate "theindex.inc", if needed, and publish
;; "theindex.org".
(when (plist-get project-plist :makeindex)
@ -787,8 +788,7 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
(when sitemap-sans-extension
(setq link (file-name-sans-extension link)))
;; sitemap shouldn't list itself
(unless (equal (file-truename sitemap-filename)
(file-truename file))
(unless (file-equal-p sitemap-filename file)
(if (eq sitemap-style 'list)
(message "Generating list-style sitemap for %s" sitemap-title)
(message "Generating tree-style sitemap for %s" sitemap-title)
@ -1007,7 +1007,7 @@ PARENT is a reference to the headline, if any, containing the
original index keyword. When non-nil, this reference is a cons
cell. Its CAR is a symbol among `id', `custom-id' and `name' and
its CDR is a string."
(let ((file (plist-get info :input-file)))
(let ((file (file-truename (plist-get info :input-file))))
(org-publish-cache-set-file-property
file :index
(delete-dups
@ -1117,7 +1117,8 @@ a plist.
This function is meant to be used as a final output filter. See
`org-publish-org-to'."
(org-publish-cache-set-file-property
(plist-get info :input-file) :crossrefs
(file-truename (plist-get info :input-file))
:crossrefs
;; Update `:crossrefs' so as to remove unused references and search
;; cells. Actually used references are extracted from
;; `:internal-references', with references as strings removed. See
@ -1147,7 +1148,7 @@ references with `org-export-get-reference'."
search
file)
"MissingReference")
(let* ((filename (expand-file-name file))
(let* ((filename (file-truename file))
(crossrefs
(org-publish-cache-get-file-property filename :crossrefs nil t))
(cells (org-export-string-to-search-cell search)))
@ -1286,23 +1287,19 @@ will be created. Return VALUE."
filename property value nil project-name))))
(defun org-publish-cache-get-file-property
(filename property &optional default no-create project-name)
(filename property &optional default no-create project-name)
"Return the value for a PROPERTY of file FILENAME in publishing cache.
Use cache file of PROJECT-NAME. Return the value of that PROPERTY,
or DEFAULT, if the value does not yet exist. Create the entry,
if necessary, unless NO-CREATE is non-nil."
;; Evtl. load the requested cache file:
(if project-name (org-publish-initialize-cache project-name))
(let ((pl (org-publish-cache-get filename)) retval)
(if pl
(if (plist-member pl property)
(setq retval (plist-get pl property))
(setq retval default))
;; no pl yet:
(unless no-create
(org-publish-cache-set filename (list property default)))
(setq retval default))
retval))
(when project-name (org-publish-initialize-cache project-name))
(let ((properties (org-publish-cache-get filename)))
(cond ((null properties)
(unless no-create
(org-publish-cache-set filename (list property default)))
default)
((plist-member properties property) (plist-get properties property))
(t default))))
(defun org-publish-cache-get (key)
"Return the value stored in `org-publish-cache' for key KEY.

View File

@ -717,7 +717,15 @@ x
;; Handle un-balanced quotes.
(should
(equal '(":foo \"1" "bar 3")
(org-babel-balanced-split ":foo \"1 :bar 3" '((32 9) . 58)))))
(org-babel-balanced-split ":foo \"1 :bar 3" '((32 9) . 58))))
;; Handle empty string.
(should
(equal '(":foo \"\"")
(org-babel-balanced-split ":foo \"\"" '((32 9) . 58))))
;; Handle control characters within double quotes.
(should
(equal '(":foo \"\\n\"")
(org-babel-balanced-split ":foo \"\\n\"" '((32 9) . 58)))))
(ert-deftest test-ob/commented-last-block-line-no-var ()
(org-test-with-temp-text-in-file "

View File

@ -1558,6 +1558,10 @@ e^{i\\pi}+1=0
(eq 'latex-fragment
(org-test-with-temp-text "$a$ "
(org-element-type (org-element-context)))))
(should
(eq 'latex-fragment
(org-test-with-temp-text "$a$'"
(org-element-type (org-element-context)))))
(should-not
(eq 'latex-fragment
(org-test-with-temp-text "$a$a"

View File

@ -1000,6 +1000,74 @@
(org-toggle-item t)
(buffer-string)))))
(ert-deftest test-org-list/sort ()
"Test `org-sort-list'."
;; Sort alphabetically.
(should
(equal "- abc\n- def\n- xyz\n"
(org-test-with-temp-text "- def\n- xyz\n- abc\n"
(org-sort-list nil ?a)
(buffer-string))))
(should
(equal "- xyz\n- def\n- abc\n"
(org-test-with-temp-text "- def\n- xyz\n- abc\n"
(org-sort-list nil ?A)
(buffer-string))))
;; Sort numerically.
(should
(equal "- 1\n- 2\n- 10\n"
(org-test-with-temp-text "- 10\n- 1\n- 2\n"
(org-sort-list nil ?n)
(buffer-string))))
(should
(equal "- 10\n- 2\n- 1\n"
(org-test-with-temp-text "- 10\n- 1\n- 2\n"
(org-sort-list nil ?N)
(buffer-string))))
;; Sort by checked status.
(should
(equal "- [ ] xyz\n- [ ] def\n- [X] abc\n"
(org-test-with-temp-text "- [X] abc\n- [ ] xyz\n- [ ] def\n"
(org-sort-list nil ?x)
(buffer-string))))
(should
(equal "- [X] abc\n- [ ] xyz\n- [ ] def\n"
(org-test-with-temp-text "- [X] abc\n- [ ] xyz\n- [ ] def\n"
(org-sort-list nil ?X)
(buffer-string))))
;; Sort by time stamp.
(should
(equal "- <2017-05-08 Mon>\n- <2017-05-09 Tue>\n- <2018-05-09 Wed>\n"
(org-test-with-temp-text
"- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
(org-sort-list nil ?t)
(buffer-string))))
(should
(equal "- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
(org-test-with-temp-text
"- <2018-05-09 Wed>\n- <2017-05-09 Tue>\n- <2017-05-08 Mon>\n"
(org-sort-list nil ?T)
(buffer-string))))
;; Sort by custom function.
(should
(equal "- b\n- aa\n- ccc\n"
(org-test-with-temp-text "- ccc\n- b\n- aa\n"
(org-sort-list nil ?f
(lambda ()
(length (buffer-substring (point-at-bol)
(point-at-eol))))
#'<)
(buffer-string))))
(should
(equal "- ccc\n- aa\n- b\n"
(org-test-with-temp-text "- ccc\n- b\n- aa\n"
(org-sort-list nil ?F
(lambda ()
(length (buffer-substring (point-at-bol)
(point-at-eol))))
#'<)
(buffer-string)))))
;;; Radio Lists

View File

@ -2533,6 +2533,202 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(org-test-with-temp-text "xx abc<point> xx"
(org-in-regexp "abc" nil t))))
(ert-deftest test-org/sort-entries ()
"Test `org-sort-entries'."
;; Sort alphabetically.
(should
(equal "\n* abc\n* def\n* xyz\n"
(org-test-with-temp-text "\n* def\n* xyz\n* abc\n"
(org-sort-entries nil ?a)
(buffer-string))))
(should
(equal "\n* xyz\n* def\n* abc\n"
(org-test-with-temp-text "\n* def\n* xyz\n* abc\n"
(org-sort-entries nil ?A)
(buffer-string))))
;; Sort numerically.
(should
(equal "\n* 1\n* 2\n* 10\n"
(org-test-with-temp-text "\n* 10\n* 1\n* 2\n"
(org-sort-entries nil ?n)
(buffer-string))))
(should
(equal "\n* 10\n* 2\n* 1\n"
(org-test-with-temp-text "\n* 10\n* 1\n* 2\n"
(org-sort-entries nil ?N)
(buffer-string))))
;; Sort by custom function.
(should
(equal "\n* b\n* aa\n* ccc\n"
(org-test-with-temp-text "\n* ccc\n* b\n* aa\n"
(org-sort-entries nil ?f
(lambda ()
(length (buffer-substring (point-at-bol)
(point-at-eol))))
#'<)
(buffer-string))))
(should
(equal "\n* ccc\n* aa\n* b\n"
(org-test-with-temp-text "\n* ccc\n* b\n* aa\n"
(org-sort-entries nil ?F
(lambda ()
(length (buffer-substring (point-at-bol)
(point-at-eol))))
#'<)
(buffer-string))))
;; Sort by TODO keyword.
(should
(equal "\n* TODO h1\n* TODO h3\n* DONE h2\n"
(org-test-with-temp-text
"\n* TODO h1\n* DONE h2\n* TODO h3\n"
(org-sort-entries nil ?o)
(buffer-string))))
(should
(equal "\n* DONE h2\n* TODO h1\n* TODO h3\n"
(org-test-with-temp-text
"\n* TODO h1\n* DONE h2\n* TODO h3\n"
(org-sort-entries nil ?O)
(buffer-string))))
;; Sort by priority.
(should
(equal "\n* [#A] h2\n* [#B] h3\n* [#C] h1\n"
(org-test-with-temp-text
"\n* [#C] h1\n* [#A] h2\n* [#B] h3\n"
(org-sort-entries nil ?p)
(buffer-string))))
(should
(equal "\n* [#C] h1\n* [#B] h3\n* [#A] h2\n"
(org-test-with-temp-text
"\n* [#C] h1\n* [#A] h2\n* [#B] h3\n"
(org-sort-entries nil ?P)
(buffer-string))))
;; Sort by creation time.
(should
(equal "
* h3
[2017-05-08 Mon]
* h2
[2017-05-09 Tue]
* h1
[2018-05-09 Wed]
"
(org-test-with-temp-text
"
* h1
[2018-05-09 Wed]
* h2
[2017-05-09 Tue]
* h3
[2017-05-08 Mon]
"
(org-sort-entries nil ?c)
(buffer-string))))
;; Sort by scheduled date.
(should
(equal "
* TODO h4
SCHEDULED: <2017-05-06 Sat>
* TODO h3
SCHEDULED: <2017-05-08 Mon>
* TODO h2
DEADLINE: <2017-05-09 Tue>
* TODO h1
DEADLINE: <2017-05-07 Sun>
"
(org-test-with-temp-text
"
* TODO h2
DEADLINE: <2017-05-09 Tue>
* TODO h1
DEADLINE: <2017-05-07 Sun>
* TODO h3
SCHEDULED: <2017-05-08 Mon>
* TODO h4
SCHEDULED: <2017-05-06 Sat>
"
(org-sort-entries nil ?s)
(buffer-string))))
;; Sort by deadline date.
(should
(equal "
* TODO h1
DEADLINE: <2017-05-07 Sun>
* TODO h2
DEADLINE: <2017-05-09 Tue>
* TODO h3
SCHEDULED: <2017-05-08 Mon>
* TODO h4
SCHEDULED: <2017-05-06 Sat>
"
(org-test-with-temp-text
"
* TODO h2
DEADLINE: <2017-05-09 Tue>
* TODO h1
DEADLINE: <2017-05-07 Sun>
* TODO h3
SCHEDULED: <2017-05-08 Mon>
* TODO h4
SCHEDULED: <2017-05-06 Sat>
"
(org-sort-entries nil ?d)
(buffer-string))))
;; Sort by any date/time
(should
(equal "
* TODO h4
SCHEDULED: <2017-05-06 Sat>
* TODO h1
DEADLINE: <2017-05-07 Sun>
* TODO h3
SCHEDULED: <2017-05-08 Mon>
* TODO h2
DEADLINE: <2017-05-09 Tue>
"
(org-test-with-temp-text
"
* TODO h2
DEADLINE: <2017-05-09 Tue>
* TODO h1
DEADLINE: <2017-05-07 Sun>
* TODO h3
SCHEDULED: <2017-05-08 Mon>
* TODO h4
SCHEDULED: <2017-05-06 Sat>
"
(org-sort-entries nil ?t)
(buffer-string))))
;; Sort by clocking time.
(should
(equal "
* clocked h2
:LOGBOOK:
CLOCK: [2017-05-09 Tue 00:15]--[2017-05-09 Tue 00:22] => 0:07
CLOCK: [2017-05-09 Tue 00:00]--[2017-05-09 Tue 00:10] => 0:10
:END:
* clocked h1
:LOGBOOK:
CLOCK: [2017-05-09 Tue 00:15]--[2017-05-09 Tue 00:22] => 0:07
CLOCK: [2017-05-09 Tue 00:00]--[2017-05-09 Tue 00:12] => 0:12
:END:
"
(org-test-with-temp-text
"
* clocked h1
:LOGBOOK:
CLOCK: [2017-05-09 Tue 00:15]--[2017-05-09 Tue 00:22] => 0:07
CLOCK: [2017-05-09 Tue 00:00]--[2017-05-09 Tue 00:12] => 0:12
:END:
* clocked h2
:LOGBOOK:
CLOCK: [2017-05-09 Tue 00:15]--[2017-05-09 Tue 00:22] => 0:07
CLOCK: [2017-05-09 Tue 00:00]--[2017-05-09 Tue 00:10] => 0:10
:END:
"
(org-sort-entries nil ?k)
(buffer-string)))))
;;; Navigation