Merge branch 'maint' into emacs-sync

This commit is contained in:
Kyle Meyer 2017-02-08 21:48:04 -05:00
commit 836c2d385d
13 changed files with 331 additions and 237 deletions

View File

@ -235,7 +235,7 @@ Return new parse tree."
;; Update `org-bibtex-html-entries-alist'.
(goto-char (point-min))
(while (re-search-forward
"a name=\"\\([-_a-zA-Z0-9:]+\\)\">\\(\\w+\\)" nil t)
"a name=\"\\([-_a-zA-Z0-9:]+\\)\">\\([^<]+\\)" nil t)
(push (cons (match-string 1) (match-string 2))
org-bibtex-html-entries-alist)))
;; Open produced HTML file, wrap references within a block and

View File

@ -16760,7 +16760,7 @@ region even if the cursor moves across a special context.
#+begin_src emacs-lisp
(add-hook 'org-mode-hook
(lambda ()
(org-set-local 'yas/trigger-key [tab])
(setq-local yas/trigger-key [tab])
(define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
#+end_src

View File

@ -17687,7 +17687,7 @@ fixed this problem:
@lisp
(add-hook 'org-mode-hook
(lambda ()
(org-set-local 'yas/trigger-key [tab])
(setq-local yas/trigger-key [tab])
(define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
@end lisp

View File

@ -1,6 +1,6 @@
% Reference Card for Org Mode
\def\orgversionnumber{8.2}
\def\versionyear{2014} % latest update
\def\orgversionnumber{9.0.4}
\def\versionyear{2017} % latest update
\input emacsver.tex
%**start of header
@ -312,10 +312,11 @@
\key{turn item/line into headline}{C-c *}
\key{promote/demote heading}{M-LEFT/RIGHT}
\metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
\metax{move subtree/list item up/down}{M-S-UP/DOWN}
\metax{move subtree/list item up/down}{M-UP/DOWN}
\metax{move the line at point up/down}{M-S-UP/DOWN}
\metax{sort subtree/region/plain-list}{C-c \^{}}
\metax{clone a subtree}{C-c C-x c}
\metax{copy visible text}{C-c C-x v}
\metax{copy visible parts of the region}{C-c C-x v}
\metax{kill/copy subtree}{C-c C-x C-w/M-w}
\metax{yank subtree}{C-c C-x C-y or C-y}
\metax{narrow buffer to subtree / widen}{C-x n s/w}
@ -375,7 +376,6 @@ Outside of tables, the same keys may have other functionality.
\metax{cut/copy/paste rectangular region}{C-c C-x C-w/M-w/C-y}
%\key{copy rectangular region}{C-c C-x M-w}
%\key{paste rectangular region}{C-c C-x C-y}
\key{fill paragraph across selected cells}{C-c C-q}
{\bf Miscellaneous}
@ -574,7 +574,6 @@ after ``{\tt :}'', and dictionary words elsewhere.
\key{match tags, TODO kwds, properties}{C-c a m \noteone}
\key{match only in TODO entries}{C-c a M \noteone}
\key{find stuck projects}{C-c a \# \noteone}
\key{show timeline of current org file}{C-c a L \noteone}
\key{configure custom commands}{C-c a C \noteone}
%\key{configure stuck projects}{C-c a ! \noteone}
\key{agenda for date at cursor}{C-c C-o}

View File

@ -6069,19 +6069,24 @@ specification like [h]h:mm."
(show-all (or (eq org-agenda-repeating-timestamp-show-all t)
(member todo-state
org-agenda-repeating-timestamp-show-all)))
(sexp? (string-prefix-p "%%" s))
;; DEADLINE is the bare deadline date, i.e., without
;; any repeater, or the last repeat if SHOW-ALL is
;; non-nil. REPEAT is closest repeat after CURRENT, if
;; all repeated time stamps are to be shown, or after
;; TODAY otherwise. REPEAT only applies to future
;; dates.
(deadline (if show-all (org-agenda--timestamp-to-absolute s)
(org-agenda--timestamp-to-absolute
s today 'past (current-buffer) pos)))
(repeat
(if (< current today) deadline
(org-agenda--timestamp-to-absolute
s (if show-all current today) 'future (current-buffer) pos)))
(deadline (cond
(sexp? (org-agenda--timestamp-to-absolute s current))
(show-all (org-agenda--timestamp-to-absolute s))
(t (org-agenda--timestamp-to-absolute
s today 'past (current-buffer) pos))))
(repeat (cond (sexp? deadline)
((< current today) deadline)
(t
(org-agenda--timestamp-to-absolute
s (if show-all current today) 'future
(current-buffer) pos))))
(diff (- deadline current))
(suppress-prewarning
(let ((scheduled
@ -6234,22 +6239,25 @@ scheduled items with an hour specification like [h]h:mm."
(show-all (or (eq org-agenda-repeating-timestamp-show-all t)
(member todo-state
org-agenda-repeating-timestamp-show-all)))
(sexp? (string-prefix-p "%%" s))
;; SCHEDULE is the bare scheduled date, i.e., without
;; any repeater if non-nil, or last repeat if SHOW-ALL
;; is nil. REPEAT is the closest repeat after CURRENT,
;; if all repeated time stamps are to be shown, or
;; after TODAY otherwise. REPEAT only applies to
;; future dates.
(schedule (if show-all (org-agenda--timestamp-to-absolute s)
(org-agenda--timestamp-to-absolute
s today 'past (current-buffer) pos)))
(repeat (cond ((< current today) schedule)
(show-all
(org-agenda--timestamp-to-absolute
s current 'future (current-buffer) pos))
(t
(org-agenda--timestamp-to-absolute
s today 'future (current-buffer) pos))))
(schedule (cond
(sexp? (org-agenda--timestamp-to-absolute s current))
(show-all (org-agenda--timestamp-to-absolute s))
(t (org-agenda--timestamp-to-absolute
s today 'past (current-buffer) pos))))
(repeat (cond
(sexp? schedule)
((< current today) schedule)
(t
(org-agenda--timestamp-to-absolute
s (if show-all current today) 'future
(current-buffer) pos))))
(diff (- current schedule))
(warntime (get-text-property (point) 'org-appt-warntime))
(pastschedp (< schedule today))

View File

@ -1437,6 +1437,7 @@ Use PREFIX as a prefix for the name of the indirect buffer."
(defun org-mks (table title &optional prompt specials)
"Select a member of an alist with multiple keys.
TABLE is the alist which should contain entries where the car is a string.
There should be two types of entries.
@ -1444,7 +1445,7 @@ There should be two types of entries.
This indicates that `a' is a prefix key for multi-letter selection, and
that there are entries following with keys like \"ab\", \"ax\"...
2. Selectable members must have more than two elements, with the first
2. Select-able members must have more than two elements, with the first
being the string of keys that lead to selecting it, and the second a
short description string of the item.
@ -1455,84 +1456,72 @@ When you press a prefix key, the commands (and maybe further prefixes)
under this key will be shown and offered for selection.
TITLE will be placed over the selection in the temporary buffer,
PROMPT will be used when prompting for a key. SPECIAL is an alist with
also (\"key\" \"description\") entries. When one of these is selection,
only the bare key is returned."
(setq prompt (or prompt "Select: "))
(let (tbl orig-table dkey ddesc des-keys allowed-keys
current prefix rtn re pressed buffer (inhibit-quit t))
(save-window-excursion
(setq buffer (org-switch-to-buffer-other-window "*Org Select*"))
(setq orig-table table)
(catch 'exit
(while t
(erase-buffer)
(insert title "\n\n")
(setq tbl table
des-keys nil
allowed-keys nil
cursor-type nil)
(setq prefix (if current (concat current " ") ""))
(while tbl
(cond
((and (= 2 (length (car tbl))) (= (length (caar tbl)) 1))
;; This is a description on this level
(setq dkey (caar tbl) ddesc (cl-cadar tbl))
(pop tbl)
(push dkey des-keys)
(push dkey allowed-keys)
(insert prefix "[" dkey "]" "..." " " ddesc "..." "\n")
;; Skip keys which are below this prefix
(setq re (concat "\\`" (regexp-quote dkey)))
(let (case-fold-search)
(while (and tbl (string-match re (caar tbl))) (pop tbl))))
((= 2 (length (car tbl)))
;; Not yet a usable description, skip it
)
(t
;; usable entry on this level
(insert prefix "[" (caar tbl) "]" " " (nth 1 (car tbl)) "\n")
(push (caar tbl) allowed-keys)
(pop tbl))))
(when specials
(insert "-------------------------------------------------------------------------------\n")
(let ((sp specials))
(while sp
(insert (format "[%s] %s\n"
(caar sp) (nth 1 (car sp))))
(push (caar sp) allowed-keys)
(pop sp))))
(push "\C-g" allowed-keys)
(goto-char (point-min))
(if (not (pos-visible-in-window-p (point-max)))
(org-fit-window-to-buffer))
(message prompt)
(setq pressed (char-to-string (read-char-exclusive)))
(while (not (member pressed allowed-keys))
(message "Invalid key `%s'" pressed) (sit-for 1)
(message prompt)
(setq pressed (char-to-string (read-char-exclusive))))
(when (equal pressed "\C-g")
(kill-buffer buffer)
(user-error "Abort"))
(when (and (not (assoc pressed table))
(not (member pressed des-keys))
(assoc pressed specials))
(throw 'exit (setq rtn pressed)))
(unless (member pressed des-keys)
(throw 'exit (setq rtn (rassoc (cdr (assoc pressed table))
orig-table))))
(setq current (concat current pressed))
(setq table (mapcar
(lambda (x)
(if (and (> (length (car x)) 1)
(equal (substring (car x) 0 1) pressed))
(cons (substring (car x) 1) (cdr x))
nil))
table))
(setq table (remove nil table)))))
(when buffer (kill-buffer buffer))
rtn))
PROMPT will be used when prompting for a key. SPECIAL is an
alist with (\"key\" \"description\") entries. When one of these
is selected, only the bare key is returned."
(save-window-excursion
(let ((inhibit-quit t)
(buffer (org-switch-to-buffer-other-window "*Org Select*"))
(prompt (or prompt "Select: "))
current)
(unwind-protect
(catch 'exit
(while t
(erase-buffer)
(insert title "\n\n")
(let ((des-keys nil)
(allowed-keys '("\C-g"))
(cursor-type nil))
;; Populate allowed keys and descriptions keys
;; available with CURRENT selector.
(let ((re (format "\\`%s\\(.\\)\\'"
(if current (regexp-quote current) "")))
(prefix (if current (concat current " ") "")))
(dolist (entry table)
(pcase entry
;; Description.
(`(,(and key (pred (string-match re))) ,desc)
(let ((k (match-string 1 key)))
(push k des-keys)
(push k allowed-keys)
(insert prefix "[" k "]" "..." " " desc "..." "\n")))
;; Usable entry.
(`(,(and key (pred (string-match re))) ,desc . ,_)
(let ((k (match-string 1 key)))
(insert prefix "[" k "]" " " desc "\n")
(push k allowed-keys)))
(_ nil))))
;; Insert special entries, if any.
(when specials
(insert "----------------------------------------------------\
---------------------------\n")
(pcase-dolist (`(,key ,description) specials)
(insert (format "[%s] %s\n" key description))
(push key allowed-keys)))
;; Display UI and let user select an entry or
;; a sub-level prefix.
(goto-char (point-min))
(unless (pos-visible-in-window-p (point-max))
(org-fit-window-to-buffer))
(message prompt)
(let ((pressed (char-to-string (read-char-exclusive))))
(while (not (member pressed allowed-keys))
(message "Invalid key `%s'" pressed) (sit-for 1)
(message prompt)
(setq pressed (char-to-string (read-char-exclusive))))
(setq current (concat current pressed))
(cond
((equal pressed "\C-g") (user-error "Abort"))
;; Selection is a prefix: open a new menu.
((member pressed des-keys))
;; Selection matches an association: return it.
((let ((entry (assoc current table)))
(and entry (throw 'exit entry))))
;; Selection matches a special entry: return the
;; selection prefix.
((assoc current specials) (throw 'exit current))
(t (error "No entry available")))))))
(when buffer (kill-buffer buffer))))))
;;; The template code
(defun org-capture-select-template (&optional keys)

View File

@ -1593,18 +1593,19 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
m (floor (/ s 60))
s (- s (* 60 s)))
(insert " => " (format "%2d:%02d" h m))
(when (setq remove (and org-clock-out-remove-zero-time-clocks
(= (+ h m) 0)))
(beginning-of-line 1)
(delete-region (point) (point-at-eol))
(and (looking-at "\n") (> (point-max) (1+ (point)))
(delete-char 1)))
(move-marker org-clock-marker nil)
(move-marker org-clock-hd-marker nil)
(when org-log-note-clock-out
(org-add-log-setup
'clock-out nil nil nil
(concat "# Task: " (org-get-heading t) "\n\n")))
;; Possibly remove zero time clocks. However, do not add
;; a note associated to the CLOCK line in this case.
(cond ((and org-clock-out-remove-zero-time-clocks
(= (+ h m) 0))
(setq remove t)
(delete-region (line-beginning-position)
(line-beginning-position 2)))
(org-log-note-clock-out
(org-add-log-setup
'clock-out nil nil nil
(concat "# Task: " (org-get-heading t) "\n\n"))))
(when org-clock-mode-line-timer
(cancel-timer org-clock-mode-line-timer)
(setq org-clock-mode-line-timer nil))
@ -2471,10 +2472,11 @@ from the dynamic block definition."
(properties (plist-get params :properties))
(ntcol (max 1 (or (plist-get params :tcolumns) 100)))
(indent (plist-get params :indent))
(formula (plist-get params :formula))
(case-fold-search t)
range-text total-time tbl level hlc formula pcol
range-text total-time tbl level hlc
file-time entries entry headline
recalc content narrow-cut-p tcol)
recalc narrow-cut-p)
;; Implement abbreviations
(when (plist-get params :compact)
@ -2543,8 +2545,10 @@ from the dynamic block definition."
(if level-p (concat (nth 2 lwords) "|") "") ; level column, maybe
(if timestamp (concat (nth 3 lwords) "|") "") ; timestamp column, maybe
(if properties (concat (mapconcat 'identity properties "|") "|") "") ;properties columns, maybe
(concat (nth 4 lwords) "|"
(nth 5 lwords) "|\n")) ; headline and time columns
(nth 4 lwords) "|" ;headline
(nth 5 lwords) "|" ;time column
(make-string (1- (min maxlevel (or ntcol 100))) ?|)
(if (eq formula '%) "%|\n" "\n"))
;; Insert the total time in the table
(insert-before-markers
@ -2554,11 +2558,16 @@ from the dynamic block definition."
; file column, maybe
(if level-p "|" "") ; level column, maybe
(if timestamp "|" "") ; timestamp column, maybe
(if properties (make-string (length properties) ?|) "") ; properties columns, maybe
(make-string (length properties) ?|) ; properties columns, maybe
(concat (format org-clock-total-time-cell-format (nth 7 lwords)) "| ") ; instead of a headline
(format org-clock-total-time-cell-format
(org-minutes-to-clocksum-string (or total-time 0))) ; the time
"|\n") ; close line
(org-minutes-to-clocksum-string (or total-time 0))) ;time
"|"
(make-string (1- (min maxlevel (or ntcol 100))) ?|)
(cond ((not (eq formula '%)) "")
((or (not total-time) (= total-time 0)) "0.0|")
(t "100.0|"))
"\n")
;; Now iterate over the tables and insert the data
;; but only if any time has been collected
@ -2612,49 +2621,29 @@ from the dynamic block definition."
properties "|") "|") "") ;properties columns, maybe
(if indent (org-clocktable-indent-string level) "") ; indentation
hlc headline hlc "|" ; headline
(make-string (min (1- ntcol) (or (- level 1))) ?|)
; empty fields for higher levels
(make-string (1- (min ntcol level)) ?|) ; empty fields for higher levels
hlc (org-minutes-to-clocksum-string (nth 3 entry)) hlc ; time
"|\n" ; close line
(make-string (1+ (- maxlevel level)) ?|)
(if (eq formula '%)
(format "%.1f |" (* 100 (/ (nth 3 entry) (float total-time))))
"")
"\n" ; close line
)))))
;; When exporting subtrees or regions the region might be
;; activated, so let's disable ̀delete-active-region'
(let ((delete-active-region nil)) (backward-delete-char 1))
(if (setq formula (plist-get params :formula))
(cond
((eq formula '%)
;; compute the column where the % numbers need to go
(setq pcol (+ 2
(length properties)
(if multifile 1 0)
(if level-p 1 0)
(if timestamp 1 0)
(min maxlevel (or ntcol 100))))
;; compute the column where the total time is
(setq tcol (+ 2
(length properties)
(if multifile 1 0)
(if level-p 1 0)
(if timestamp 1 0)))
(insert
(format
"\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f"
pcol ; the column where the % numbers should go
(if (and narrow (not narrow-cut-p)) 3 2) ; row of the total time
tcol ; column of the total time
tcol (1- pcol) ; range of columns where times can be found
))
(setq recalc t))
((stringp formula)
(insert "\n#+TBLFM: " formula)
(setq recalc t))
(t (error "Invalid formula in clocktable")))
;; Should we rescue an old formula?
(when (stringp (setq content (plist-get params :content)))
(when (string-match "^\\([ \t]*#\\+tblfm:.*\\)" content)
(delete-char -1)
(cond
;; Possibly rescue old formula?
((or (not formula) (eq formula '%))
(let ((contents (org-string-nw-p (plist-get params :content))))
(when (and contents (string-match "^\\([ \t]*#\\+tblfm:.*\\)" contents))
(setq recalc t)
(insert "\n" (match-string 1 (plist-get params :content)))
(insert "\n" (match-string 1 contents))
(beginning-of-line 0))))
;; Insert specified formula line.
((stringp formula)
(insert "\n#+TBLFM: " formula)
(setq recalc t))
(t
(user-error "Invalid :formula parameter in clocktable")))
;; Back to beginning, align the table, recalculate if necessary
(goto-char ipos)
(skip-chars-forward "^|")
@ -2667,13 +2656,7 @@ from the dynamic block definition."
(org-table-goto-line 3)
(org-table-goto-column (car sort))
(org-table-sort-lines nil (cdr sort))))
(when recalc
(if (eq formula '%)
(save-excursion
(if (and narrow (not narrow-cut-p)) (beginning-of-line 2))
(org-table-goto-column pcol nil 'force)
(insert "%")))
(org-table-recalculate 'all))
(when recalc (org-table-recalculate 'all))
total-time))
(defun org-clocktable-indent-string (level)
@ -2846,23 +2829,6 @@ TIME: The sum of all time spend in this tree, in minutes. This time
(setq tbl (nreverse tbl))
(list file org-clock-file-total-minutes tbl))))
(defun org-clock-time% (total &rest strings)
"Compute a time fraction in percent.
TOTAL s a time string like 10:21 specifying the total times.
STRINGS is a list of strings that should be checked for a time.
The first string that does have a time will be used.
This function is made for clock tables."
(save-match-data
(let ((total (org-duration-string-to-minutes total)))
(if (= total 0) 0
(cl-some (lambda (s)
;; Any number can express a duration. See
;; `org-hh:mm-string-to-minutes' for details.
(and (string-match-p "[0-9]" s)
(/ (* 100.0 (org-duration-string-to-minutes s))
total)))
strings)))))
;; Saving and loading the clock
(defvar org-clock-loaded nil

View File

@ -1250,21 +1250,21 @@ Return t when the line exists, nil if it does not exist."
(defun org-table-get-field (&optional n replace)
"Return the value of the field in column N of current row.
N defaults to current field.
If REPLACE is a string, replace field with this value. The return value
is always the old value."
(and n (org-table-goto-column n))
N defaults to current column. If REPLACE is a string, replace
field with this value. The return value is always the old
value."
(when n (org-table-goto-column n))
(skip-chars-backward "^|\n")
(backward-char 1)
(if (looking-at "|[^|\r\n]*")
(let* ((pos (match-beginning 0))
(val (buffer-substring (1+ pos) (match-end 0))))
(if replace
(replace-match (concat "|" (if (equal replace "") " " replace))
t t))
(goto-char (min (point-at-eol) (+ 2 pos)))
val)
(forward-char 1) ""))
(if (or (bolp) (looking-at-p "[ \t]*$"))
;; Before first column or after last one.
""
(looking-at "[^|\r\n]*")
(let* ((pos (match-beginning 0))
(val (buffer-substring pos (match-end 0))))
(when replace
(replace-match (if (equal replace "") " " replace) t t))
(goto-char (min (line-end-position) (1+ pos)))
val)))
;;;###autoload
(defun org-table-field-info (_arg)

View File

@ -13317,9 +13317,11 @@ This function is run automatically after each state change to a DONE state."
(when (eq org-log-repeat t) (setq org-log-repeat 'state))
(let ((to-state (or (org-entry-get nil "REPEAT_TO_STATE" 'selective)
org-todo-repeat-to-state)))
(unless (and to-state (member to-state org-todo-keywords-1))
(setq to-state (if (eq interpret 'type) org-last-state head)))
(org-todo to-state))
(org-todo (cond ((and to-state (member to-state org-todo-keywords-1))
to-state)
((eq interpret 'type) org-last-state)
(head)
(t 'none))))
(when (or org-log-repeat (org-entry-get nil "CLOCK"))
(org-entry-put nil "LAST_REPEAT" (format-time-string
(org-time-stamp-format t t))))
@ -13892,7 +13894,10 @@ EXTRA is additional text that will be inserted into the notes buffer."
;; Find location for the new note.
(goto-char org-log-note-marker)
(set-marker org-log-note-marker nil)
(goto-char (org-log-beginning t))
;; Note associated to a clock is to be located right after
;; the clock. Do not move point.
(unless (eq org-log-note-purpose 'clock-out)
(goto-char (org-log-beginning t)))
;; Make sure point is at the beginning of an empty line.
(cond ((not (bolp)) (let ((inhibit-read-only t)) (insert "\n")))
((looking-at "[ \t]*\\S-") (save-excursion (insert "\n"))))
@ -22797,7 +22802,7 @@ ELEMENT."
(goto-char start)
(org-get-indentation))))
((memq type '(headline inlinetask nil))
(if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
(if (org-match-line "[ \t]*$")
(org--get-expected-indentation element t)
0))
((memq type '(diary-sexp footnote-definition)) 0)
@ -22949,6 +22954,13 @@ Also align node properties according to `org-property-format'."
(= (line-beginning-position)
(org-element-property :post-affiliated element)))
'noindent)
((and (eq type 'latex-environment)
(>= (point) (org-element-property :post-affiliated element))
(< (point) (org-with-wide-buffer
(goto-char (org-element-property :end element))
(skip-chars-backward " \r\t\n")
(line-beginning-position 2))))
'noindent)
((and (eq type 'src-block)
org-src-tab-acts-natively
(> (line-beginning-position)
@ -23000,22 +23012,38 @@ assumed to be significant there."
(element-end (copy-marker (org-element-property :end element)))
(ind (org--get-expected-indentation element nil)))
(cond
;; Element indented as a single block. Example blocks
;; preserving indentation are a special case since the
;; "contents" must not be indented whereas the block
;; boundaries can.
((or (memq type '(export-block latex-environment))
(and (eq type 'example-block)
(not
(or org-src-preserve-indentation
(org-element-property :preserve-indent element)))))
(let ((offset (- ind (org-get-indentation))))
(unless (zerop offset)
(indent-rigidly (org-element-property :begin element)
(org-element-property :end element)
offset)))
(goto-char element-end))
;; Elements indented line wise. Be sure to exclude
;; example blocks (preserving indentation) and source
;; blocks from this category as they are treated
;; specially later.
((or (memq type '(paragraph table table-row))
(not (or (org-element-property :contents-begin element)
(memq type
'(example-block export-block src-block)))))
;; Elements here are indented as a single block. Also
;; align node properties.
(memq type '(example-block src-block)))))
(when (eq type 'node-property)
(org--align-node-property)
(beginning-of-line))
(funcall indent-to ind (min element-end end)))
;; Elements consisting of three parts: before the
;; contents, the contents, and after the contents. The
;; contents are treated specially, according to the
;; element type, or not indented at all. Other parts are
;; indented as a single block.
(t
;; Elements in this category consist of three parts:
;; before the contents, the contents, and after the
;; contents. The contents are treated specially,
;; according to the element type, or not indented at
;; all. Other parts are indented as a single block.
(let* ((post (copy-marker
(org-element-property :post-affiliated element)))
(cbeg
@ -23025,8 +23053,7 @@ assumed to be significant there."
;; Fake contents for source blocks.
(org-with-wide-buffer
(goto-char post)
(forward-line)
(point)))
(line-beginning-position 2)))
((memq type '(footnote-definition item plain-list))
;; Contents in these elements could start on
;; the same line as the beginning of the
@ -23060,7 +23087,7 @@ assumed to be significant there."
(t (funcall indent-to ind (min cbeg end))))
(when (< (point) end)
(cl-case type
((example-block export-block verse-block))
((example-block verse-block))
(src-block
;; In a source block, indent source code
;; according to language major mode, but only if

View File

@ -1298,8 +1298,7 @@ For non-floats, see `org-latex--wrap-label'."
main)
(and (eq type 'src-block)
(not (plist-get attr :float))
(memq (plist-get info :latex-listings)
'(nil minted)))))
(null (plist-get info :latex-listings)))))
(short (org-export-get-caption element t))
(caption-from-attr-latex (plist-get attr :caption)))
(cond
@ -2875,13 +2874,19 @@ contextual information."
(float-env
(cond
((string= "multicolumn" float)
(format "\\begin{listing*}\n%s%%s\n%s\\end{listing*}"
(format "\\begin{listing*}[%s]\n%s%%s\n%s\\end{listing*}"
(plist-get info :latex-default-figure-position)
(if caption-above-p caption-str "")
(if caption-above-p "" caption-str)))
(caption
(concat (if caption-above-p caption-str "")
"%s"
(if caption-above-p "" (concat "\n" caption-str))))
(format "\\begin{listing}[%s]\n%s%%s\n%s\\end{listing}"
(plist-get info :latex-default-figure-position)
(if caption-above-p caption-str "")
(if caption-above-p "" caption-str)))
((string= "t" float)
(concat (format "\\begin{listing}[%s]\n"
(plist-get info :latex-default-figure-position))
"%s\n\\end{listing}"))
(t "%s")))
(options (plist-get info :latex-minted-options))
(body

View File

@ -389,8 +389,8 @@ CLOCK: [2012-03-29 Thu 16:40]--[2014-03-04 Thu 00:41] => 16905:01
|--------------+-----------+-------|
| *Total time* | *1d 4:00* | 100.0 |
|--------------+-----------+-------|
| Foo | 1d 2:00 | 83.3 |
| Bar | 2:00 | 16.7 |
| Foo | 1d 2:00 | 92.9 |
| Bar | 2:00 | 7.1 |
"
(org-test-with-temp-text
"

View File

@ -2093,6 +2093,69 @@ is t, then new columns should be added as needed"
(let ((org-table-tab-jumps-over-hlines nil)) (org-table-next-field))
(buffer-string)))))
;;; Miscellaneous
(ert-deftest test-org-table/get-field ()
"Test `org-table-get-field' specifications."
;; Regular test.
(should
(equal " a "
(org-test-with-temp-text "| <point>a |" (org-table-get-field))))
;; Get field in open last column.
(should
(equal " a "
(org-test-with-temp-text "| <point>a " (org-table-get-field))))
;; Get empty field.
(should
(equal ""
(org-test-with-temp-text "|<point>|" (org-table-get-field))))
(should
(equal " "
(org-test-with-temp-text "| <point>|" (org-table-get-field))))
;; Outside the table, return the empty string.
(should
(equal ""
(org-test-with-temp-text "<point>| a |" (org-table-get-field))))
(should
(equal ""
(org-test-with-temp-text "| a |<point>" (org-table-get-field))))
;; With optional N argument, select a particular column in current
;; row.
(should
(equal " 3 "
(org-test-with-temp-text "| 1 | 2 | 3 |" (org-table-get-field 3))))
(should
(equal " 4 "
(org-test-with-temp-text "| 1 | 2 |\n<point>| 3 | 4 |"
(org-table-get-field 2))))
;; REPLACE optional argument is used to replace selected field.
(should
(equal "| foo |"
(org-test-with-temp-text "| <point>1 |"
(org-table-get-field nil " foo ")
(buffer-string))))
(should
(equal "| 1 | 2 | foo |"
(org-test-with-temp-text "| 1 | 2 | 3 |"
(org-table-get-field 3 " foo ")
(buffer-string))))
(should
(equal " 4 "
(org-test-with-temp-text "| 1 | 2 |\n<point>| 3 | 4 |"
(org-table-get-field 2))))
;; An empty REPLACE string clears the field.
(should
(equal "| |"
(org-test-with-temp-text "| <point>1 |"
(org-table-get-field nil "")
(buffer-string))))
;; When using REPLACE still return old value.
(should
(equal " 1 "
(org-test-with-temp-text "| <point>1 |"
(org-table-get-field nil " foo ")))))
(provide 'test-org-table)
;;; test-org-table.el ends here

View File

@ -720,36 +720,36 @@
;; `org-adapt-indentation' is nil.
(should
(= 2
(org-test-with-temp-text "* H\nA"
(forward-line)
(org-test-with-temp-text "* H\n<point>A"
(let ((org-adapt-indentation t)) (org-indent-line))
(org-get-indentation))))
(should
(= 2
(org-test-with-temp-text "* H\n\nA"
(forward-line)
(org-test-with-temp-text "* H\n<point>\nA"
(let ((org-adapt-indentation t)) (org-indent-line))
(org-get-indentation))))
(should
(zerop
(org-test-with-temp-text "* H\nA"
(forward-line)
(org-test-with-temp-text "* H\n<point>A"
(let ((org-adapt-indentation nil)) (org-indent-line))
(org-get-indentation))))
;; Indenting preserves point position.
(should
(org-test-with-temp-text "* H\nAB"
(forward-line)
(forward-char)
(org-test-with-temp-text "* H\nA<point>B"
(let ((org-adapt-indentation t)) (org-indent-line))
(looking-at "B")))
;; Do not change indentation at an item.
;; Do not change indentation at an item or a LaTeX environment.
(should
(= 1
(org-test-with-temp-text "* H\n - A"
(forward-line)
(org-test-with-temp-text "* H\n<point> - A"
(let ((org-adapt-indentation t)) (org-indent-line))
(org-get-indentation))))
(should
(= 1
(org-test-with-temp-text
"\\begin{equation}\n <point>1+1=2\n\\end{equation}"
(org-indent-line)
(org-get-indentation))))
;; On blank lines at the end of a list, indent like last element
;; within it if the line is still in the list. If the last element
;; is an item, indent like its contents. Otherwise, indent like the
@ -889,17 +889,54 @@
(org-test-with-temp-text "#+BEGIN_CENTER\n A\n B\n#+END_CENTER"
(org-indent-region (point-min) (point-max))
(buffer-string))))
;; Ignore contents of verse blocks and example blocks.
;; Ignore contents of verse blocks. Only indent block delimiters.
(should
(equal "#+BEGIN_VERSE\n A\n B\n#+END_VERSE"
(org-test-with-temp-text "#+BEGIN_VERSE\n A\n B\n#+END_VERSE"
(org-indent-region (point-min) (point-max))
(buffer-string))))
(should
(equal "#+BEGIN_VERSE\n A\n B\n#+END_VERSE"
(org-test-with-temp-text " #+BEGIN_VERSE\n A\n B\n #+END_VERSE"
(org-indent-region (point-min) (point-max))
(buffer-string))))
;; Indent example blocks as a single block, unless indentation
;; should be preserved. In this case only indent the block markers.
(should
(equal "#+BEGIN_EXAMPLE\n A\n B\n#+END_EXAMPLE"
(org-test-with-temp-text "#+BEGIN_EXAMPLE\n A\n B\n#+END_EXAMPLE"
(org-indent-region (point-min) (point-max))
(buffer-string))))
(should
(equal "#+BEGIN_EXAMPLE\n A\n B\n#+END_EXAMPLE"
(org-test-with-temp-text " #+BEGIN_EXAMPLE\n A\n B\n #+END_EXAMPLE"
(org-indent-region (point-min) (point-max))
(buffer-string))))
(should
(equal "#+BEGIN_EXAMPLE -i\n A\n B\n#+END_EXAMPLE"
(org-test-with-temp-text
" #+BEGIN_EXAMPLE -i\n A\n B\n #+END_EXAMPLE"
(org-indent-region (point-min) (point-max))
(buffer-string))))
(should
(equal "#+BEGIN_EXAMPLE\n A\n B\n#+END_EXAMPLE"
(org-test-with-temp-text
" #+BEGIN_EXAMPLE\n A\n B\n #+END_EXAMPLE"
(let ((org-src-preserve-indentation t))
(org-indent-region (point-min) (point-max)))
(buffer-string))))
;; Treat export blocks as a whole.
(should
(equal "#+BEGIN_EXPORT latex\n A\n B\n#+END_EXPORT"
(org-test-with-temp-text "#+BEGIN_EXPORT latex\n A\n B\n#+END_EXPORT"
(org-indent-region (point-min) (point-max))
(buffer-string))))
(should
(equal "#+BEGIN_EXPORT latex\n A\n B\n#+END_EXPORT"
(org-test-with-temp-text
" #+BEGIN_EXPORT latex\n A\n B\n #+END_EXPORT"
(org-indent-region (point-min) (point-max))
(buffer-string))))
;; Indent according to mode if `org-src-tab-acts-natively' is
;; non-nil. Otherwise, do not indent code at all.
(should