Prefer `forward-line' over `beginning-of-line'

The latter is much slower.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#98
This commit is contained in:
Ihor Radchenko 2023-05-10 15:27:13 +02:00
parent 1c7c67b3c6
commit f93d855c51
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
34 changed files with 329 additions and 328 deletions

View File

@ -1524,11 +1524,11 @@ portions of results lines."
"Toggle the visibility of the current result."
(interactive)
(save-excursion
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t))
(unless (re-search-forward org-babel-result-regexp nil t)
(error "Not looking at a result line")))
(let ((start (progn (beginning-of-line 2) (1- (point))))
(let ((start (progn (forward-line 1) (1- (point))))
(end (progn
(while (looking-at org-babel-multi-line-header-regexp)
(forward-line 1))
@ -1872,7 +1872,7 @@ src block, then return nil."
(let ((end (org-element-end element)))
(org-with-wide-buffer
;; Ensure point is not on a blank line after the block.
(beginning-of-line)
(forward-line 0)
(skip-chars-forward " \r\t\n" end)
(when (< (point) end)
(prog1 (goto-char (org-element-post-affiliated element))
@ -2105,7 +2105,7 @@ the results hash, or nil. Leave point before the keyword."
;;
;; : fixed-width area, unrelated to the above.
(unless (looking-at "^[ \t]*$") (save-excursion (insert "\n")))
(beginning-of-line 0)
(forward-line -1)
(when hash (org-babel-hide-hash)))
(defun org-babel--clear-results-maybe (hash)
@ -2212,7 +2212,7 @@ to HASH."
(empty-result-re (concat org-babel-result-regexp "$"))
(case-fold-search t))
(re-search-forward empty-result-re end t))
(beginning-of-line)
(forward-line 0)
(when (org-babel--clear-results-maybe hash)
(org-babel--insert-results-keyword nil hash))
(throw :found (point))))))
@ -2274,8 +2274,8 @@ Return nil if ELEMENT cannot be read."
(defun org-babel-read-result ()
"Read the result at point into emacs-lisp."
(and (not (save-excursion
(beginning-of-line)
(looking-at-p "[ \t]*$")))
(forward-line 0)
(looking-at-p "[ \t]*$")))
(org-babel-read-element (org-element-at-point))))
(defun org-babel-read-table ()
@ -2798,7 +2798,7 @@ specified as an an \"attachment:\" style link."
((< size org-babel-min-lines-for-block-output)
(goto-char beg)
(dotimes (_ size)
(beginning-of-line 1) (insert ": ") (forward-line 1)))
(forward-line 0) (insert ": ") (forward-line 1)))
(t
(goto-char beg)
(insert (if results-switches

View File

@ -279,7 +279,7 @@ this template."
((equal replacement "")
(goto-char end)
(skip-chars-forward " \r\t\n")
(beginning-of-line)
(forward-line 0)
(delete-region begin (point)))
(t
(if (or org-src-preserve-indentation

View File

@ -378,7 +378,7 @@ references."
(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))
(delete-region (save-excursion (forward-line) (point))
(save-excursion (end-of-line 1) (forward-char 1) (point)))))
(defun org-babel-spec-to-string (spec)

View File

@ -1529,7 +1529,7 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
((memq type '(headline inlinetask))
(or (not (org-at-heading-p))
(and (save-excursion
(beginning-of-line)
(forward-line 0)
(and (let ((case-fold-search t))
(not (looking-at-p "\\*+ END[ \t]*$")))
(let ((case-fold-search nil))
@ -1548,10 +1548,10 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
;; White spaces after an object or blank lines after an element
;; are OK.
((>= (point)
(save-excursion (goto-char (org-element-end context))
(skip-chars-backward " \r\t\n")
(if (eq (org-element-class context) 'object) (point)
(line-beginning-position 2)))))
(save-excursion (goto-char (org-element-end context))
(skip-chars-backward " \r\t\n")
(if (eq (org-element-class context) 'object) (point)
(line-beginning-position 2)))))
;; At the beginning of a footnote definition, right after the
;; label, is OK.
((eq type 'footnote-definition) (looking-at (rx space)))

View File

@ -1239,7 +1239,7 @@ of matched result, which is either `dedicated' or `fuzzy'."
(name (org-element-property :name element)))
(when (and name (equal words (split-string name)))
(setq type 'dedicated)
(beginning-of-line)
(forward-line 0)
(throw :name-match t))))
nil))))
;; Regular text search. Prefer headlines in Org mode buffers.
@ -1260,7 +1260,7 @@ of matched result, which is either `dedicated' or `fuzzy'."
(org-get-heading t t t t))))
(throw :found t)))
nil)))
(beginning-of-line)
(forward-line 0)
(setq type 'dedicated))
;; Offer to create non-existent headline depending on
;; `org-link-search-must-match-exact-headline'.
@ -1271,7 +1271,7 @@ of matched result, which is either `dedicated' or `fuzzy'."
(unless (bolp) (newline))
(org-insert-heading nil t t)
(insert s "\n")
(beginning-of-line 0))
(forward-line -1))
;; Only headlines are looked after. No need to process
;; further: throw an error.
((and (derived-mode-p 'org-mode)
@ -1590,7 +1590,7 @@ non-nil."
(setq link nil))
;; A code reference exists. Use it.
((save-excursion
(beginning-of-line)
(forward-line 0)
(re-search-forward (org-src-coderef-regexp coderef-format)
(line-end-position)
t))

View File

@ -3705,7 +3705,7 @@ Drawers will be excluded, also the line with scheduling/deadline info."
(goto-char (point-min))
(while (not (eobp))
(if (not (setq m (org-get-at-bol 'org-hd-marker)))
(beginning-of-line 2)
(forward-line 1)
(setq txt (org-agenda-get-some-entry-text
m org-agenda-add-entry-text-maxlines " > "))
(end-of-line 1)
@ -3773,13 +3773,13 @@ removed from the entry content. Currently only `planning' is allowed here."
(while (not (eobp))
(unless (looking-at "[ \t]*$")
(setq ind (min ind (org-current-text-indentation))))
(beginning-of-line 2))
(forward-line 1))
(goto-char (point-min))
(while (not (eobp))
(unless (looking-at "[ \t]*$")
(move-to-column ind)
(delete-region (line-beginning-position) (point)))
(beginning-of-line 2))
(forward-line 1))
(run-hooks 'org-agenda-entry-text-cleanup-hook)
@ -4329,11 +4329,11 @@ This check for agenda markers in all agenda buffers currently active."
(interactive)
(save-excursion
(goto-char (point-max))
(beginning-of-line 1)
(forward-line 0)
(while (not (bobp))
(when (org-get-at-bol 'org-hd-marker)
(org-agenda-entry-text-show-here))
(beginning-of-line 0))))
(forward-line -1))))
(defun org-agenda-entry-text-hide ()
"Remove any shown entry context."
@ -5651,7 +5651,7 @@ timestamp and the timestamp type relevant for the sorting strategy in
(while (re-search-forward regexp nil t)
(catch :skip
(save-match-data
(beginning-of-line)
(forward-line 0)
(org-agenda-skip)
(setq beg (point) end (save-excursion (outline-next-heading) (point)))
(unless (and (setq todo-state (org-get-todo-state))
@ -7368,7 +7368,7 @@ The optional argument TYPE tells the agenda type."
re)
(if (eq x 'line)
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(setq re (org-get-at-bol 'org-todo-regexp))
(goto-char (or (text-property-any (line-beginning-position)
(line-end-position)
@ -8452,7 +8452,7 @@ grouptags."
(txt (or (org-get-at-bol 'txt) "")))
(unless (eval org-agenda-filter-form t)
(org-agenda-filter-hide-line type))))
(beginning-of-line 2)))
(forward-line 1)))
(when (get-char-property (point) 'invisible)
(ignore-errors (org-agenda-previous-line))))
@ -8467,7 +8467,7 @@ grouptags."
(when (and tophl (funcall (if negative 'identity 'not)
(string= hl tophl)))
(org-agenda-filter-hide-line 'top-headline)))
(beginning-of-line 2)))
(forward-line 1)))
(when (get-char-property (point) 'invisible)
(org-agenda-previous-line))
(setq org-agenda-top-headline-filter hl
@ -8877,7 +8877,7 @@ so that the date SD will be in that range."
"Jump to the next line indicating a date in agenda buffer."
(interactive "p")
(org-agenda-check-type t 'agenda)
(beginning-of-line 1)
(forward-line 0)
;; This does not work if user makes date format that starts with a blank
(when (looking-at-p "^\\S-") (forward-char 1))
(unless (re-search-forward "^\\S-" nil t arg)
@ -8889,7 +8889,7 @@ so that the date SD will be in that range."
"Jump to the previous line indicating a date in agenda buffer."
(interactive "p")
(org-agenda-check-type t 'agenda)
(beginning-of-line 1)
(forward-line 0)
(unless (re-search-backward "^\\S-" nil t arg)
(error "No previous date before this line in this buffer")))
@ -9352,7 +9352,7 @@ If this information is not given, the function uses the tree at point."
(set-buffer (get-buffer org-agenda-buffer-name))
(save-excursion
(goto-char (point-max))
(beginning-of-line 1)
(forward-line 0)
(while (not (bobp))
(when (and (setq m (org-get-at-bol 'org-marker))
(equal buf (marker-buffer m))
@ -9362,7 +9362,7 @@ If this information is not given, the function uses the tree at point."
(let ((inhibit-read-only t))
(delete-region (line-beginning-position)
(1+ (line-end-position)))))
(beginning-of-line 0))))))
(forward-line -1))))))
(defun org-agenda-refile (&optional goto rfloc no-update)
"Refile the item at point.
@ -9444,7 +9444,7 @@ It also looks at the text of the entry itself."
lk))
((or (org-in-regexp (concat "\\(" org-link-bracket-re "\\)"))
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(looking-at (concat ".*?\\(" org-link-bracket-re "\\)"))))
(org-link-open-from-string (match-string 1)))
(t (message "No link to open here")))))
@ -9711,14 +9711,14 @@ the same tree node, and the headline of the tree node in the Org file."
(setq newhead (org-get-heading))
(when (and org-agenda-headline-snapshot-before-repeat
(not (equal org-agenda-headline-snapshot-before-repeat
newhead))
newhead))
todayp)
(setq newhead org-agenda-headline-snapshot-before-repeat
just-one t))
(save-excursion
(org-back-to-heading)
(move-marker org-last-heading-marker (point))))
(beginning-of-line 1)
(forward-line 0)
(save-window-excursion
(org-agenda-change-all-lines newhead hdmarker 'fixface just-one))
(when (bound-and-true-p org-clock-out-when-done)
@ -9763,7 +9763,7 @@ If FORCE-TAGS is non-nil, the car of it returns the new tags."
effort effort-minutes) ;; pl
(save-excursion
(goto-char (point-max))
(beginning-of-line 1)
(forward-line 0)
(while (not finish)
(setq finish (bobp))
(when (and (setq m (org-get-at-bol 'org-hd-marker))
@ -9784,15 +9784,15 @@ If FORCE-TAGS is non-nil, the car of it returns the new tags."
(with-current-buffer (marker-buffer hdmarker)
(org-with-wide-buffer
(org-agenda-format-item extra
(org-add-props newhead nil
'effort effort
'effort-minutes effort-minutes)
level cat tags dotime))))
(org-add-props newhead nil
'effort effort
'effort-minutes effort-minutes)
level cat tags dotime))))
;; pl (text-property-any (line-beginning-position)
;; (line-end-position) 'org-heading t)
undone-face (org-get-at-bol 'undone-face)
done-face (org-get-at-bol 'done-face))
(beginning-of-line 1)
(forward-line 0)
(cond
((equal new "") (delete-region (point) (line-beginning-position 2)))
((looking-at ".*")
@ -9804,7 +9804,7 @@ If FORCE-TAGS is non-nil, the car of it returns the new tags."
'org-marked-entry-overlay)
(throw :overlay o))))))
(replace-match new t t)
(beginning-of-line)
(forward-line 0)
(when mark (move-overlay mark (point) (+ 2 (point)))))
(add-text-properties (line-beginning-position)
(line-end-position) props)
@ -9815,12 +9815,12 @@ If FORCE-TAGS is non-nil, the car of it returns the new tags."
(if org-last-todo-state-is-todo
undone-face done-face))))
(org-agenda-highlight-todo 'line)
(beginning-of-line 1))
(forward-line 0))
(t (error "Line update did not work")))
(save-restriction
(narrow-to-region (line-beginning-position) (line-end-position))
(org-agenda-finalize)))
(beginning-of-line 0)))))
(forward-line -1)))))
(defun org-agenda-align-tags (&optional line)
"Align all tags in agenda items to `org-agenda-tags-column'.
@ -9924,7 +9924,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up',
(end-of-line 1)
(setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker)
(beginning-of-line 1)))))
(forward-line 0)))))
(defun org-agenda-set-property ()
"Set a property for the current headline."
@ -9988,7 +9988,7 @@ When called programmatically, FORCE-DIRECTION can be `set', `up',
(end-of-line 1)
(setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker)
(beginning-of-line 1)))))
(forward-line 0)))))
(defun org-agenda-do-date-later (arg)
(interactive "P")
@ -10106,8 +10106,8 @@ When called programmatically, FORCE-DIRECTION can be `set', `up',
(1- (point)) (line-end-position)
(list 'display (org-add-props stamp nil
'face '(secondary-selection default))))
(beginning-of-line 1))
(beginning-of-line 0)))))
(forward-line 0))
(forward-line -1)))))
(defun org-agenda-date-prompt (arg)
"Change the date of this item. Date is prompted for, with default today.
@ -10326,7 +10326,7 @@ the resulting entry will not be shown. When TEXT is empty, switch to
(progn
(outline-next-heading)
(insert "* Anniversaries\n\n")
(beginning-of-line -1)))))
(forward-line -2)))))
(outline-next-heading)
(org-back-over-empty-lines)
(backward-char 1)
@ -10610,9 +10610,9 @@ When ARG is greater than one mark ARG lines."
(end-of-line 1)
(or (ignore-errors
(goto-char (next-single-property-change (point) 'org-hd-marker)))
(beginning-of-line 2))
(forward-line 1))
(while (and (get-char-property (point) 'invisible) (not (eobp)))
(beginning-of-line 2)))))
(forward-line 1)))))
(message "%d entries marked for bulk action"
(length org-agenda-bulk-marked-entries)))
@ -10632,7 +10632,7 @@ When ARG is greater than one mark ARG lines."
(setq txt-at-point
(get-text-property (match-beginning 0) 'txt)))
(if (get-char-property (point) 'invisible)
(beginning-of-line 2)
(forward-line 1)
(when (string-match-p regexp txt-at-point)
(setq entries-marked (1+ entries-marked))
(call-interactively 'org-agenda-bulk-mark)))))
@ -10653,9 +10653,9 @@ When ARG is greater than one mark ARG lines."
(end-of-line 1)
(or (ignore-errors
(goto-char (next-single-property-change (point) 'txt)))
(beginning-of-line 2))
(forward-line 1))
(while (and (get-char-property (point) 'invisible) (not (eobp)))
(beginning-of-line 2))
(forward-line 1))
(message "%d entries left marked for bulk action"
(length org-agenda-bulk-marked-entries)))
(t (message "No entry to unmark here")))))

View File

@ -476,9 +476,9 @@ Archiving time is retained in the ARCHIVE_TIME node property."
(goto-char e)
(or (bolp) (newline))
(insert leader org-archive-sibling-heading "\n")
(beginning-of-line 0)
(forward-line -1)
(org-toggle-tag org-archive-tag 'on))
(beginning-of-line 1)
(forward-line 0)
(if org-archive-reversed-order
(outline-next-heading)
(org-end-of-subtree t t))
@ -607,7 +607,7 @@ the children that do not contain any open TODO items."
(org-back-to-heading t)
(setq set (org-toggle-tag org-archive-tag))
(when set (org-fold-subtree t)))
(and set (beginning-of-line 1))
(and set (forward-line 0))
(message "Subtree %s" (if set "archived" "unarchived"))))))
(defun org-archive-set-tag ()

View File

@ -1029,11 +1029,11 @@ Store them in the capture property list."
(if (re-search-forward (format org-complex-heading-regexp-format
(regexp-quote headline))
nil t)
(beginning-of-line)
(forward-line 0)
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert "* " headline "\n")
(beginning-of-line 0)))
(forward-line -1)))
(`(file+olp ,path . ,outline-path)
(let ((m (org-find-olp (cons (org-capture-expand-file path)
outline-path))))
@ -1415,7 +1415,7 @@ may have been stored before."
(goto-char (point-min))
(cond
((not (re-search-forward org-table-hline-regexp nil t)))
((re-search-forward org-table-dataline-regexp nil t) (beginning-of-line))
((re-search-forward org-table-dataline-regexp nil t) (forward-line 0))
(t (goto-char (org-table-end)))))
(t
(goto-char (org-table-end))))

View File

@ -937,7 +937,7 @@ If CLOCK-SOUND is non-nil, it overrides `org-clock-sound'."
`(with-current-buffer (marker-buffer (car ,clock))
(org-with-wide-buffer
(goto-char (car ,clock))
(beginning-of-line)
(forward-line 0)
,@forms)))
(defmacro org-with-clock (clock &rest forms)
@ -1389,8 +1389,8 @@ the default behavior."
(when newstate (org-todo newstate))))
((and org-clock-in-switch-to-state
(not (looking-at (concat org-outline-regexp "[ \t]*"
org-clock-in-switch-to-state
"\\>"))))
org-clock-in-switch-to-state
"\\>"))))
(org-todo org-clock-in-switch-to-state)))
(setq org-clock-heading (org-clock--mode-line-heading))
(org-clock-find-position org-clock-in-resume)
@ -1421,7 +1421,7 @@ the default behavior."
(when (and (save-excursion
(end-of-line 0)
(org-in-item-p)))
(beginning-of-line 1)
(forward-line 0)
(indent-line-to (max 0 (- (current-indentation) 2))))
(insert-and-inherit org-clock-string " ")
(setq org-clock-effort (org-entry-get (point) org-effort-property))
@ -1597,7 +1597,7 @@ line and position cursor in that line."
(let ((element (org-element-at-point)))
(when (and (org-element-type-p element 'clock)
(eq (org-element-property :status element) 'running))
(beginning-of-line)
(forward-line 0)
(throw 'exit t))))))
;; Look for an existing clock drawer.
(when drawer
@ -1670,7 +1670,7 @@ line and position cursor in that line."
(forward-line)
(unless org-log-states-order-reversed
(goto-char end)
(beginning-of-line -1))
(forward-line -2))
(set-marker end nil)))))
(org-log-states-order-reversed (goto-char (car (last positions))))
(t (goto-char (car positions))))))))
@ -1713,7 +1713,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
(save-restriction
(widen)
(goto-char org-clock-marker)
(beginning-of-line 1)
(forward-line 0)
(if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
(equal (match-string 1) org-clock-string))
(setq ts (match-string 2))
@ -1761,10 +1761,10 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
(when newstate (org-todo newstate))))
((and org-clock-out-switch-to-state
(not (looking-at
(concat
org-outline-regexp "[ \t]*"
org-clock-out-switch-to-state
"\\>"))))
(concat
org-outline-regexp "[ \t]*"
org-clock-out-switch-to-state
"\\>"))))
(org-todo org-clock-out-switch-to-state))))))
(force-mode-line-update)
(message (if remove
@ -2540,7 +2540,7 @@ the currently selected interval size."
(goto-char b)
(insert ins)
(delete-region (point) (+ (point) (- e b)))
(beginning-of-line 1)
(forward-line 0)
(org-update-dblock)
t)))))
@ -2842,13 +2842,13 @@ from the dynamic block definition."
(if timestamp (concat ts "|") "") ;timestamp, maybe
(if tags (concat (mapconcat #'identity tgs ", ") "|") "") ;tags, maybe
(if properties ;properties columns, maybe
(concat (mapconcat (lambda (p) (or (cdr (assoc p props)) ""))
properties
"|")
"|")
(concat (mapconcat (lambda (p) (or (cdr (assoc p props)) ""))
properties
"|")
"|")
"")
(if indent ;indentation
(org-clocktable-indent-string level)
(org-clocktable-indent-string level)
"")
(format-field headline)
;; Empty fields for higher levels.
@ -2856,7 +2856,7 @@ from the dynamic block definition."
(format-field (org-duration-from-minutes time))
(make-string (max 0 (- time-columns level)) ?|)
(if (eq formula '%)
(format "%.1f |" (* 100 (/ time (float total-time))))
(format "%.1f |" (* 100 (/ time (float total-time))))
"")
"\n")))))))
(delete-char -1)
@ -2867,7 +2867,7 @@ from the dynamic block definition."
(when (and contents (string-match "^\\([ \t]*#\\+tblfm:.*\\)" contents))
(setq recalc t)
(insert "\n" (match-string 1 contents))
(beginning-of-line 0))))
(forward-line -1))))
;; Insert specified formula line.
((stringp formula)
(insert "\n#+TBLFM: " formula)
@ -3110,7 +3110,7 @@ Otherwise, return nil."
(let ((origin (point))) ;; `save-excursion' may not work when deleting.
(prog1
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(skip-chars-forward " \t")
(when (looking-at org-clock-string)
(let ((re (concat "[ \t]*" org-clock-string

View File

@ -186,18 +186,18 @@ See `org-columns-summary-types' for details.")
(org-defkey org-columns-map [down]
(lambda () (interactive)
(let ((col (current-column)))
(beginning-of-line 2)
(forward-line 1)
(while (and (org-invisible-p2) (not (eobp)))
(beginning-of-line 2))
(forward-line 1))
(move-to-column col)
(if (derived-mode-p 'org-agenda-mode)
(org-agenda-do-context-action)))))
(org-defkey org-columns-map [up]
(lambda () (interactive)
(let ((col (current-column)))
(beginning-of-line 0)
(forward-line -1)
(while (and (org-invisible-p2) (not (bobp)))
(beginning-of-line 0))
(forward-line -1))
(move-to-column col)
(if (eq major-mode 'org-agenda-mode)
(org-agenda-do-context-action)))))
@ -385,7 +385,7 @@ DATELINE is non-nil when the face used should be
(setq org-columns-header-line-remap
(face-remap-add-relative 'header-line '(:inherit default))))
(save-excursion
(beginning-of-line)
(forward-line 0)
(let* ((level-face (and (looking-at "\\(\\**\\)\\(\\* \\)")
(org-get-level-face 2)))
(ref-face (or level-face

View File

@ -631,7 +631,7 @@ See `org-link-parameters' for documentation on the other parameters."
(defun org-table-recognize-table.el ()
"If there is a table.el table nearby, recognize it and move into it."
(when (org-at-table.el-p)
(beginning-of-line)
(forward-line 0)
(unless (or (looking-at org-table-dataline-regexp)
(not (looking-at org-table1-hline-regexp)))
(forward-line)
@ -900,7 +900,7 @@ region as a drawer without further ado."
(let ((drawer
(or element
(and (save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at-p "^[ \t]*:\\(\\(?:\\w\\|[-_]\\)+\\):[ \t]*$"))
(org-element-at-point)))))
(when (org-element-type-p drawer '(drawer property-drawer))
@ -1406,7 +1406,7 @@ ELEMENT is the element at point."
"Function used for `flyspell-generic-check-word-predicate'."
(if (org-at-heading-p)
;; At a headline or an inlinetask, check title only.
(and (save-excursion (beginning-of-line)
(and (save-excursion (forward-line 0)
(and (let ((case-fold-search t))
(not (looking-at-p "\\*+ END[ \t]*$")))
(let ((case-fold-search nil))
@ -1423,7 +1423,7 @@ ELEMENT is the element at point."
;; Ignore checks in all affiliated keywords but captions.
((< (point) post-affiliated)
(and (save-excursion
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t)) (looking-at "[ \t]*#\\+CAPTION:")))
(> (point) (match-end 0))
(org--flyspell-object-check-p element)))
@ -1592,7 +1592,7 @@ key."
"Run `org-back-to-heading' when in org-mode."
(if (derived-mode-p 'org-mode)
(progn
(beginning-of-line)
(forward-line 0)
(or (org-at-heading-p (not invisible-ok))
(let (found)
(save-excursion

View File

@ -422,7 +422,7 @@ Use `\\[org-edit-special]' to edit table.el tables"))
(call-interactively (global-key-binding (kbd "TAB"))))
((or (eq org-cycle-emulate-tab t)
(and (memq org-cycle-emulate-tab '(white whitestart))
(save-excursion (beginning-of-line 1) (looking-at "[ \t]*"))
(save-excursion (forward-line 0) (looking-at "[ \t]*"))
(or (and (eq org-cycle-emulate-tab 'white)
(= (match-end 0) (line-end-position)))
(and (eq org-cycle-emulate-tab 'whitestart)
@ -481,7 +481,7 @@ Use `\\[org-edit-special]' to edit table.el tables"))
(save-excursion
(if (org-at-item-p)
(progn
(beginning-of-line)
(forward-line 0)
(setq struct (org-list-struct))
(setq eoh (line-end-position))
(setq eos (org-list-get-item-end-before-blank (point) struct))
@ -503,16 +503,16 @@ Use `\\[org-edit-special]' to edit table.el tables"))
(save-excursion
(org-list-search-forward (org-item-beginning-re) eos t))))))
;; Determine end invisible part of buffer (EOL)
(beginning-of-line 2)
(forward-line 1)
(if (eq org-fold-core-style 'text-properties)
(while (and (not (eobp)) ;this is like `next-line'
(org-fold-folded-p (1- (point))))
(goto-char (org-fold-next-visibility-change nil nil t))
(and (eolp) (beginning-of-line 2)))
(and (eolp) (forward-line 1)))
(while (and (not (eobp)) ;this is like `next-line'
(get-char-property (1- (point)) 'invisible))
(goto-char (next-single-char-property-change (point) 'invisible))
(and (eolp) (beginning-of-line 2))))
(and (eolp) (forward-line 1))))
(setq eol (point)))
;; Find out what to do next and set `this-command'
(cond
@ -546,7 +546,7 @@ Use `\\[org-edit-special]' to edit table.el tables"))
(save-excursion
(org-back-to-heading)
(while (org-list-search-forward (org-item-beginning-re) eos t)
(beginning-of-line 1)
(forward-line 0)
(let* ((struct (org-list-struct))
(prevs (org-list-prevs-alist struct))
(end (org-list-get-bottom-point struct)))

View File

@ -198,9 +198,9 @@ inserted into the buffer."
(unless (bolp) (insert "\n"))
(org-datetree-insert-line year month day insert))
((= (string-to-number (match-string 1)) (or day month year))
(beginning-of-line))
(forward-line 0))
(t
(beginning-of-line)
(forward-line 0)
(org-datetree-insert-line year month day insert)))))
(defun org-datetree-insert-line (year &optional month day text)
@ -226,7 +226,7 @@ inserted into the buffer."
(org-encode-time 0 0 0 day month year)
nil
(eq org-datetree-add-timestamp 'inactive))))
(beginning-of-line))
(forward-line 0))
(defun org-datetree-file-entry-under (txt d)
"Insert a node TXT into the date tree under date D."

View File

@ -1342,7 +1342,7 @@ Return a new syntax node of `org-data' type containing `:begin',
(contents-begin (progn
(goto-char 1)
(org-skip-whitespace)
(beginning-of-line)
(forward-line 0)
(point)))
(end (point-max))
(pos-before-blank (progn (goto-char (point-max))
@ -1510,7 +1510,7 @@ string instead.
Assume point is at the beginning of the item."
(save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at org-list-full-item-re)
(let* ((begin (point))
(bullet (org-element--get-cached-string (match-string-no-properties 1)))
@ -2623,7 +2623,7 @@ Assume point is at the beginning of the paragraph."
(cond
((not (and (re-search-forward
org-element-paragraph-separate limit 'move)
(progn (beginning-of-line) t))))
(progn (forward-line 0) t))))
((looking-at-p org-element-drawer-re)
(save-excursion
(re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
@ -4395,7 +4395,7 @@ element it has to parse."
((match-beginning 6)
(org-element-babel-call-parser limit affiliated))
((match-beginning 7)
(beginning-of-line)
(forward-line 0)
(org-element-dynamic-block-parser limit affiliated))
((match-beginning 8)
(org-element-keyword-parser limit affiliated))
@ -4435,7 +4435,7 @@ element it has to parse."
(cond
;; Must end with a full rule.
((not (re-search-forward non-table.el-line limit 'move))
(if (bolp) (forward-line -1) (beginning-of-line))
(if (bolp) (forward-line -1) (forward-line 0))
(looking-at-p rule-regexp))
;; Ignore pseudo-tables with a single
;; rule.
@ -6591,7 +6591,7 @@ the expected result."
(setq element (org-element-org-data-parser))
(setq mode 'org-data))
(org-skip-whitespace)
(beginning-of-line))
(forward-line 0))
;; Check if CACHED or any of its ancestors contain point.
;;
;; If there is such an element, we inspect it in order to know
@ -6631,7 +6631,7 @@ the expected result."
(cl-incf org-element--cache-interrupt-C-g-count)
(setq quit-flag nil))
(when (>= org-element--cache-interrupt-C-g-count
org-element--cache-interrupt-C-g-max-count)
org-element--cache-interrupt-C-g-max-count)
(setq quit-flag t)
(setq org-element--cache-interrupt-C-g-count 0)
(org-element-cache-reset)
@ -6679,7 +6679,7 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li
(re-search-forward
(org-headline-re (1- (org-element-property :true-level element)))
pos t))
(beginning-of-line)
(forward-line 0)
t)
;; There are headings with lower level than
;; ELEMENT between ELEM-END and POS. Siblings
@ -6779,7 +6779,7 @@ The function returns the new value of `org-element--cache-change-warning'."
(setq org-element--cache-change-tic (buffer-chars-modified-tick))
(setq org-element--cache-last-buffer-size (buffer-size))
(goto-char beg)
(beginning-of-line)
(forward-line 0)
(let ((bottom (save-excursion
(goto-char end)
(if (and (bolp)
@ -6814,7 +6814,7 @@ The function returns the new value of `org-element--cache-change-warning'."
(when (re-search-forward
org-element--cache-sensitive-re bottom t)
(goto-char beg)
(beginning-of-line)
(forward-line 0)
(let (min-level)
(cl-loop while (re-search-forward
(rx-to-string
@ -6826,7 +6826,7 @@ The function returns the new value of `org-element--cache-change-warning'."
do (setq min-level (1- (length (match-string 0))))
until (= min-level 1))
(goto-char beg)
(beginning-of-line)
(forward-line 0)
(or (and min-level (org-reduced-level min-level))
(when (looking-at-p "^[ \t]*#\\+CATEGORY:")
'org-data)
@ -8104,7 +8104,7 @@ This function may modify match data."
;; At a parsed affiliated keyword, check if we're inside main
;; or dual value.
((and post (< pos post))
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t)) (looking-at org-element--affiliated-re))
(cond
((not (member-ignore-case (match-string 1)
@ -8124,7 +8124,7 @@ This function may modify match data."
(let ((tag (org-element-property :tag element)))
(if (or (not tag) (/= (line-beginning-position) post))
(throw 'objects-forbidden element)
(beginning-of-line)
(forward-line 0)
(search-forward tag (line-end-position))
(goto-char (match-beginning 0))
(if (and (>= pos (point)) (< pos (match-end 0)))
@ -8193,7 +8193,7 @@ This function may modify match data."
(and (= pos cend)
(or (= (point-max) pos)
(not (memq (char-before pos)
'(?\s ?\t)))))))
'(?\s ?\t)))))))
(goto-char cbeg)
(narrow-to-region (point) cend)
(setq parent next)

View File

@ -495,7 +495,7 @@ This will find DRAWER and extract the alist."
(match-beginning 0)))))
(outline-next-heading)
(insert " :" drawer ":\n :END:\n")
(beginning-of-line 0))
(forward-line -1))
(insert (pp-to-string status)))))
(defun org-feed-add-items (pos entries)
@ -508,7 +508,7 @@ This will find DRAWER and extract the alist."
(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)
(forward-line 1)
(setq pos (point))
(while (setq entry (pop entries))
(org-paste-subtree level entry 'yank))
@ -565,7 +565,7 @@ If that property is already present, nothing changes."
(let ((v (plist-get entry (intern (concat ":" name)))))
(save-excursion
(save-match-data
(beginning-of-line)
(forward-line 0)
(if (looking-at
(concat "^\\([ \t]*\\)%" name "[ \t]*$"))
(org-feed-make-indented-block

View File

@ -389,7 +389,7 @@ of the current heading, or to 1 if the current line is not a heading."
(interactive (list
(cond
(current-prefix-arg (prefix-numeric-value current-prefix-arg))
((save-excursion (beginning-of-line)
((save-excursion (forward-line 0)
(looking-at outline-regexp))
(funcall outline-level))
(t 1))))
@ -624,7 +624,7 @@ Return a non-nil value when toggling is successful."
(re (concat org-outline-regexp-bol ".*:" org-archive-tag ":")))
(goto-char beg)
;; Include headline point is currently on.
(beginning-of-line)
(forward-line 0)
(while (and (< (point) end) (re-search-forward re end t))
(when (member org-archive-tag (org-get-tags nil t))
(org-fold-subtree t)
@ -674,7 +674,7 @@ DETAIL is either nil, `minimal', `local', `ancestors',
(ignore org-hide-macro-markers)
(when region
(org-with-point-at (car region)
(beginning-of-line)
(forward-line 0)
(let (font-lock-extend-region-functions)
(font-lock-fontify-region (max (point-min) (1- (car region))) (cdr region))))))
;; Unfold links.
@ -757,7 +757,7 @@ the contents consists of blank lines.
Assume that point is located at the header line."
(org-with-wide-buffer
(beginning-of-line)
(forward-line 0)
(org-fold-region
(max (point-min) (1- (point)))
(let ((endl (line-end-position)))
@ -785,7 +785,7 @@ This function is intended to be used as :fragile property of
;; The line before beginning of the fold should be either a
;; headline or a list item.
(backward-char)
(beginning-of-line)
(forward-line 0)
;; Make sure that headline is not partially hidden.
(unless (org-fold-folded-p nil 'headline)
(org-fold--reveal-headline-at-point))
@ -797,14 +797,14 @@ This function is intended to be used as :fragile property of
(org-fold--reveal-headline-at-point))))
;; Make sure that headline after is not partially hidden.
(goto-char (cdr region))
(beginning-of-line)
(forward-line 0)
(unless (org-fold-folded-p nil 'headline)
(when (looking-at-p org-element-headline-re)
(org-fold--reveal-headline-at-point)))
;; Check the validity of headline
(goto-char (car region))
(backward-char)
(beginning-of-line)
(forward-line 0)
(unless (let ((case-fold-search t))
(looking-at (rx-to-string
`(or (regex ,(org-item-re))
@ -840,7 +840,7 @@ This function is intended to be used as :fragile property of
;; The line before beginning of the fold should be the
;; first line of the drawer/block.
(backward-char)
(beginning-of-line)
(forward-line 0)
(unless (let ((case-fold-search t))
(looking-at begin-re)) ; the match-data will be used later
(throw :exit (setq unfold? t))))
@ -860,7 +860,7 @@ This function is intended to be used as :fragile property of
;; The last line of the folded text should match `end-re'.
(save-excursion
(goto-char fold-end)
(beginning-of-line)
(forward-line 0)
(unless (let ((case-fold-search t))
(looking-at end-re))
(throw :exit (setq unfold? t))))

View File

@ -184,14 +184,14 @@ extracted will be filled again."
"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 forbidden blocks.
(org-in-block-p org-footnote-forbidden-blocks)))))
(org-inside-LaTeX-fragment-p)
;; Avoid literal example.
(org-in-verbatim-emphasis)
(save-excursion
(forward-line 0)
(looking-at "[ \t]*:[ \t]+"))
;; Avoid forbidden blocks.
(org-in-block-p org-footnote-forbidden-blocks)))))
(defun org-footnote-at-reference-p ()
"Non-nil if point is at a footnote reference.
@ -270,7 +270,7 @@ otherwise."
((memq type '(headline inlinetask))
(or (not (org-at-heading-p))
(and (save-excursion
(beginning-of-line)
(forward-line 0)
(and (let ((case-fold-search t))
(not (looking-at-p "\\*+ END[ \t]*$")))
(let ((case-fold-search nil))
@ -282,10 +282,10 @@ otherwise."
;; 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 (eq (org-element-class context) 'object) (point)
(line-beginning-position 2)))))
(save-excursion (goto-char (org-element-property :end context))
(skip-chars-backward " \r\t\n")
(if (eq (org-element-class context) 'object) (point)
(line-beginning-position 2)))))
;; At the beginning of a footnote definition, right after the
;; label, is OK.
((eq type 'footnote-definition) (looking-at (rx space)))
@ -299,7 +299,7 @@ otherwise."
;; :contents-begin is not reliable on empty cells, so special
;; case it.
(<= (save-excursion (skip-chars-backward " \t") (point))
(org-element-property :contents-end context)))
(org-element-property :contents-end context)))
((let ((cbeg (org-element-property :contents-begin context))
(cend (org-element-property :contents-end context)))
(and cbeg (>= (point) cbeg) (<= (point) cend))))))))
@ -517,7 +517,7 @@ This function is meant to be used for fontification only."
;; Definition: also grab the last square bracket, matched in
;; `org-footnote-re' for non-inline footnotes.
((and (save-excursion
(beginning-of-line)
(forward-line 0)
(save-match-data (org-footnote-in-valid-context-p)))
(save-excursion
(end-of-line)

View File

@ -145,7 +145,7 @@ When nil, you can use these keybindings to navigate the buffer:
(search-backward string bound noerror))
(when (save-match-data
(and (save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at org-complex-heading-regexp))
(or (not (match-beginning 5))
(< (point) (match-beginning 5)))))
@ -172,7 +172,7 @@ When nil, you can use these keybindings to navigate the buffer:
(interactive)
(if (org-at-heading-p)
(progn
(beginning-of-line 1)
(forward-line 0)
(setq org-goto-selected-point (point)
org-goto-exit-command 'left)
(throw 'exit nil))

View File

@ -328,7 +328,7 @@ stopped."
(save-match-data
(org-with-wide-buffer
(goto-char beg)
(beginning-of-line)
(forward-line 0)
;; Initialize prefix at BEG, according to current entry's level.
(let* ((case-fold-search t)
(limited-re (org-get-limited-outline-regexp))
@ -410,7 +410,7 @@ This function is meant to be called by `after-change-functions'."
(if (or org-indent-modified-headline-flag
(save-excursion
(goto-char beg)
(beginning-of-line)
(forward-line 0)
(re-search-forward
(org-with-limited-levels org-outline-regexp-bol)
(save-excursion

View File

@ -174,7 +174,7 @@ The number of levels is controlled by `org-inlinetask-min-level'."
(defun org-inlinetask-in-task-p ()
"Return true if point is inside an inline task."
(save-excursion
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t))
(or (looking-at-p (concat (org-inlinetask-outline-regexp) "\\(?:.*\\)"))
(and (re-search-forward "^\\*+[ \t]+" nil t)
@ -193,7 +193,7 @@ The number of levels is controlled by `org-inlinetask-min-level'."
"Go to the end of the inline task at point.
Return point."
(save-match-data
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t)
(inlinetask-re (org-inlinetask-outline-regexp)))
(cond
@ -241,7 +241,7 @@ going below `org-inlinetask-min-level'."
(replace-match down-task nil t nil 1)
(org-inlinetask-goto-end)
(if (and (eobp) (looking-back "END\\s-*" (line-beginning-position)))
(beginning-of-line)
(forward-line 0)
(forward-line -1))
(unless (= (point) beg)
(looking-at (org-inlinetask-outline-regexp))
@ -267,7 +267,7 @@ If the task has an end part, also demote it."
(replace-match down-task nil t nil 1)
(org-inlinetask-goto-end)
(if (and (eobp) (looking-back "END\\s-*" (line-beginning-position)))
(beginning-of-line)
(forward-line 0)
(forward-line -1))
(unless (= (point) beg)
(looking-at (org-inlinetask-outline-regexp))

View File

@ -209,7 +209,7 @@ for `tabulated-list-printer'."
(cons
(progn
(goto-char (car report))
(beginning-of-line)
(forward-line 0)
(prog1 (number-to-string
(cl-incf last-line
(count-lines last-pos (point))))
@ -1020,7 +1020,7 @@ Use \"export %s\" instead"
(unless (or (string-prefix-p "BEGIN" name t)
(string-prefix-p "END" name t)
(save-excursion
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t)) (looking-at exception-re))))
(push (list (match-beginning 0)
(format "Possible missing colon in keyword \"%s\"" name))

View File

@ -423,7 +423,7 @@ group 4: description tag")
(defun org-in-item-p ()
"Return item beginning position when in a plain list, nil otherwise."
(save-excursion
(beginning-of-line)
(forward-line 0)
(let* ((case-fold-search t)
(context (org-list-context))
(lim-up (car context))
@ -471,7 +471,7 @@ group 4: description tag")
(re-search-backward "^[ \t]*#\\+begin_" lim-up t)))
((and (looking-at "^[ \t]*:END:")
(re-search-backward org-drawer-regexp lim-up t))
(beginning-of-line))
(forward-line 0))
((and inlinetask-re (looking-at inlinetask-re))
(org-inlinetask-goto-beginning)
(forward-line -1))
@ -490,7 +490,7 @@ group 4: description tag")
"Is point in a line starting a hand-formatted item?
Modify match data, matching against `org-item-re'."
(save-excursion
(beginning-of-line)
(forward-line 0)
(and
(org-element-type-p
(org-element-at-point)
@ -538,7 +538,7 @@ Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
(save-match-data
(save-excursion
(org-with-limited-levels
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search t) (pos (point)) beg end context-type
;; Get positions of surrounding headings. This is the
;; default context.
@ -625,7 +625,7 @@ will get the following structure:
Assume point is at an item."
(save-excursion
(beginning-of-line)
(forward-line 0)
(let* ((case-fold-search t)
(context (org-list-context))
(lim-up (car context))
@ -693,7 +693,7 @@ Assume point is at an item."
(re-search-backward "^[ \t]*#\\+begin_" lim-up t)))
((and (looking-at "^[ \t]*:END:")
(re-search-backward org-drawer-regexp lim-up t))
(beginning-of-line))
(forward-line 0))
((and inlinetask-re (looking-at inlinetask-re))
(org-inlinetask-goto-beginning)
(forward-line -1))
@ -1861,7 +1861,7 @@ Initial position of cursor is restored after the changes."
(lambda (end beg delta)
(goto-char end)
(skip-chars-backward " \r\t\n")
(beginning-of-line)
(forward-line 0)
(while (or (> (point) beg)
(and (= (point) beg)
(not (looking-at item-re))))
@ -2248,7 +2248,7 @@ item is invisible."
(setq struct (org-list-insert-item pos struct prevs checkbox desc))
(org-list-write-struct struct (org-list-parents-alist struct))
(when checkbox (org-update-checkbox-count-maybe))
(beginning-of-line)
(forward-line 0)
(looking-at org-list-full-item-re)
(goto-char (if (and (match-beginning 4)
(save-match-data
@ -2278,7 +2278,7 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
(interactive "P")
(unless (org-at-item-p) (error "Not at an item"))
(let ((origin (point-marker)))
(beginning-of-line)
(forward-line 0)
(let* ((struct (org-list-struct))
(parents (org-list-parents-alist struct))
(prevs (org-list-prevs-alist struct))
@ -2340,14 +2340,14 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
(setq struct (org-list-struct))
(cond
((>= origin-offset2 0)
(beginning-of-line)
(forward-line 0)
(move-marker origin (+ (point)
(org-list-get-ind (point) struct)
(length (org-list-get-bullet (point) struct))
origin-offset2))
(goto-char origin))
((>= origin-offset 0)
(beginning-of-line)
(forward-line 0)
(move-marker origin (+ (point)
(org-list-get-ind (point) struct)
origin-offset))
@ -2392,7 +2392,7 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
(defun org-at-radio-list-p ()
"Is point at a list item with radio buttons?"
(when (org-match-line (org-item-re)) ;short-circuit
(let* ((e (save-excursion (beginning-of-line) (org-element-at-point))))
(let* ((e (save-excursion (forward-line 0) (org-element-at-point))))
;; Check we're really on a line with a bullet.
(when (org-element-type-p e '(item plain-list))
;; Look for ATTR_ORG attribute in the current plain list.
@ -2522,7 +2522,7 @@ subtree, ignoring planning line and any drawer following it."
(while (< (point) end)
(when (org-at-item-checkbox-p)
(replace-match "[ ]" t t nil 1))
(beginning-of-line 2)))
(forward-line 1)))
(org-update-checkbox-count-maybe 'all)))))
(defun org-update-checkbox-count (&optional all)
@ -2991,7 +2991,7 @@ function is being called interactively."
(now (current-time))
(next-record (lambda ()
(skip-chars-forward " \r\t\n")
(or (eobp) (beginning-of-line))))
(or (eobp) (forward-line 0))))
(end-record (lambda ()
(goto-char (org-list-get-item-end-before-blank
(point) struct))))
@ -3071,7 +3071,7 @@ With a prefix argument ARG, change the region in a single item."
;; footnote definition, thus not slurping the
;; following element.
(unless (<= 2 (org-element-post-blank
(org-element-at-point)))
(org-element-at-point)))
(setf (car definitions)
(concat (car definitions)
(make-string
@ -3200,7 +3200,7 @@ With a prefix argument ARG, change the region in a single item."
(when footnote-definitions
(goto-char end)
;; Insert footnote definitions after the list.
(unless (bolp) (beginning-of-line 2))
(unless (bolp) (forward-line 1))
;; At (point-max).
(unless (bolp) (insert "\n"))
(dolist (def footnote-definitions)
@ -3232,7 +3232,7 @@ With a prefix argument ARG, change the region in a single item."
(org-element-at-point (1- end))
'plain-list t)))
;; Insert footnote definitions after the list.
(unless (bolp) (beginning-of-line 2))
(unless (bolp) (forward-line 1))
;; At (point-max).
(unless (bolp) (insert "\n"))
(dolist (def footnote-definitions)
@ -3449,7 +3449,7 @@ Valid parameters are:
(if (consp e) (funcall insert-list e)
(insert e)
(insert "\n")))
(beginning-of-line)
(forward-line 0)
(save-excursion
(let ((ind (if (eq type 'ordered) 3 2)))
(while (> (point) start)

View File

@ -872,23 +872,22 @@ Match at beginning of line when WITH-BOL is non-nil."
(org-headline-re nstars (not with-bol))))))
(defun org--line-empty-p (n)
"Is the Nth next line empty?
Counts the current line as N = 1 and the previous line as N = 0;
see `beginning-of-line'."
"Is the Nth next line empty?"
(and (not (bobp))
(save-excursion
(beginning-of-line n)
(looking-at-p "[ \t]*$"))))
(forward-line n)
(skip-chars-forward "[ \t]")
(eolp))))
(defun org-previous-line-empty-p ()
"Is the previous line a blank line?
When NEXT is non-nil, check the next line instead."
(org--line-empty-p 0))
(org--line-empty-p -1))
(defun org-next-line-empty-p ()
"Is the previous line a blank line?
When NEXT is non-nil, check the next line instead."
(org--line-empty-p 2))
(org--line-empty-p 1))
(defun org-id-uuid ()
"Return string with random (version 4) UUID."
@ -986,7 +985,7 @@ Return nil when PROP is not set at POS."
(defun org-match-line (regexp)
"Match REGEXP at the beginning of the current line."
(save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at regexp)))
(defun org-match-any-p (re list)
@ -1008,7 +1007,7 @@ match."
(let ((pos (point))
(eol (line-end-position (if nlines (1+ nlines) 1))))
(save-excursion
(beginning-of-line (- 1 (or nlines 0)))
(forward-line (- (or nlines 0)))
(while (and (re-search-forward regexp eol t)
(<= (match-beginning 0) pos))
(let ((end (match-end 0)))

View File

@ -627,11 +627,11 @@ The table of checksums is written to the file mobile-checksums."
(setq short (get-text-property (point) 'short-heading))
(when (and short (looking-at ".+"))
(replace-match short nil t)
(beginning-of-line 1))
(forward-line 0))
(when app
(end-of-line 1)
(insert app)
(beginning-of-line 1))
(forward-line 0))
(insert "* "))
((get-text-property (point) 'org-agenda-date-header)
(setq in-date t)
@ -649,7 +649,7 @@ The table of checksums is written to the file mobile-checksums."
(line-end-position))))
(delete-region (line-beginning-position) (line-end-position))
(insert line "<before>" prefix "</before>")
(beginning-of-line 1))
(forward-line 0))
(and (looking-at "[ \t]+") (replace-match "")))
(insert (if in-date "*** " "** "))
(end-of-line 1)
@ -666,7 +666,7 @@ The table of checksums is written to the file mobile-checksums."
(org-mobile-get-outline-path-link m))))
(insert " :PROPERTIES:\n :ORIGINAL_ID: " id
"\n :END:\n")))))
(beginning-of-line 2))
(forward-line 1))
(push (cons "agendas.org" (md5 (buffer-string)))
org-mobile-checksum-files))
(message "Agenda written to Org file %s" file)))
@ -1071,7 +1071,7 @@ be returned that indicates what went wrong."
(end-of-line 1)
(org-insert-heading-respect-content t)
(org-demote))
(beginning-of-line)
(forward-line 0)
(insert "* "))
(insert new))

View File

@ -186,7 +186,7 @@ Changing this variable requires a restart of Emacs to get activated."
(defun org-mouse-re-search-line (regexp)
"Search the current line for a given regular expression."
(beginning-of-line)
(forward-line 0)
(re-search-forward regexp (line-end-position) t))
(defun org-mouse-end-headline ()
@ -242,13 +242,13 @@ return `:middle'."
(defun org-mouse-empty-line ()
"Return non-nil if the line contains only white space."
(save-excursion (beginning-of-line) (looking-at "[ \t]*$")))
(save-excursion (forward-line 0) (looking-at "[ \t]*$")))
(defun org-mouse-next-heading ()
"Go to the next heading.
If there is none, ensure that the point is at the beginning of an empty line."
(unless (outline-next-heading)
(beginning-of-line)
(forward-line 0)
(unless (org-mouse-empty-line)
(end-of-line)
(newline))))
@ -261,7 +261,7 @@ insert the new heading before the current line. Otherwise, insert it
after the current heading."
(interactive)
(cl-case (org-mouse-line-position)
(:beginning (beginning-of-line)
(:beginning (forward-line 0)
(org-insert-heading))
(t (org-mouse-next-heading)
(org-insert-heading))))
@ -566,7 +566,7 @@ This means, between the beginning of line and the point."
(defun org-mouse-insert-item (text)
(cl-case (org-mouse-line-position)
(:beginning ; insert before
(beginning-of-line)
(forward-line 0)
(looking-at "[ \t]*")
(open-line 1)
(indent-to-column (- (match-end 0) (match-beginning 0)))
@ -582,7 +582,7 @@ This means, between the beginning of line and the point."
(unless (looking-back org-mouse-punctuation (line-beginning-position))
(insert (concat org-mouse-punctuation " ")))))
(insert text)
(beginning-of-line))
(forward-line 0))
(advice-add 'dnd-insert-text :around #'org--mouse-dnd-insert-text)
(defun org--mouse-dnd-insert-text (orig-fun window action text &rest args)
@ -632,7 +632,7 @@ This means, between the beginning of line and the point."
(progn (save-excursion (goto-char (region-beginning)) (insert "[["))
(save-excursion (goto-char (region-end)) (insert "]]")))]
["Insert Link Here" (org-mouse-yank-link ',event)]))))
((save-excursion (beginning-of-line) (looking-at "[ \t]*#\\+STARTUP: \\(.*\\)"))
((save-excursion (forward-line 0) (looking-at "[ \t]*#\\+STARTUP: \\(.*\\)"))
(popup-menu
`(nil
,@(org-mouse-list-options-menu (mapcar #'car org-startup-options)
@ -817,11 +817,11 @@ This means, between the beginning of line and the point."
["Set Deadline"
(progn (org-mouse-end-headline) (insert " ") (org-deadline))
:active (not (save-excursion
(org-mouse-re-search-line org-deadline-regexp)))]
(org-mouse-re-search-line org-deadline-regexp)))]
["Schedule Task"
(progn (org-mouse-end-headline) (insert " ") (org-schedule))
:active (not (save-excursion
(org-mouse-re-search-line org-scheduled-regexp)))]
(org-mouse-re-search-line org-scheduled-regexp)))]
["Insert Timestamp"
(progn (org-mouse-end-headline) (insert " ") (org-timestamp nil)) t]
; ["Timestamp (inactive)" org-timestamp-inactive t]
@ -976,7 +976,7 @@ This means, between the beginning of line and the point."
(org-back-to-heading)
(let ((minlevel 1000)
(replace-text (concat (make-string (org-current-level) ?*) "* ")))
(beginning-of-line 2)
(forward-line 1)
(save-excursion
(while (not (or (eobp) (looking-at org-outline-regexp)))
(when (looking-at org-mouse-plain-list-regexp)
@ -1024,7 +1024,7 @@ This means, between the beginning of line and the point."
(unless (eq (marker-position marker) (marker-position endmarker))
(setq newhead (org-get-heading))))
(beginning-of-line 1)
(forward-line 1)
(save-excursion
(org-agenda-change-all-lines newhead hdmarker 'fixface))))
t))))

View File

@ -213,7 +213,7 @@ Assume point is at a headline."
(let ((after-edit-functions
(list (lambda (o &rest _) (org-num--invalidate-overlay o))))
(o (save-excursion
(beginning-of-line)
(forward-line 0)
(skip-chars-forward "*")
(make-overlay (line-beginning-position) (1+ (point))))))
(overlay-put o 'org-num t)

View File

@ -330,7 +330,7 @@ converted to a headline before refiling."
(goto-char (point-min))
(setq org-outline-path-cache nil)
(while (re-search-forward descre nil t)
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search nil))
(looking-at org-complex-heading-regexp))
(let ((begin (point))
@ -365,7 +365,7 @@ converted to a headline before refiling."
(buffer-base-buffer))))
(_ nil))
(mapcar (lambda (s) (replace-regexp-in-string
"/" "\\/" s nil t))
"/" "\\/" s nil t))
(org-get-outline-path t t)))
"/"))))
(push (list target f re (org-refile-marker (point)))
@ -474,7 +474,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
(setq last-command nil)
(when regionp
(goto-char region-start)
(beginning-of-line)
(forward-line 0)
(setq region-start (point))
(unless (or (org-kill-is-subtree-p
(buffer-substring region-start region-end))
@ -720,7 +720,7 @@ this function appends the default value from
(with-current-buffer buffer
(org-with-wide-buffer
(goto-char pos)
(beginning-of-line 1)
(forward-line 0)
(unless (looking-at-p re)
(user-error "Invalid refile position, please clear the cache with `C-0 C-c C-w' before refiling"))))))))
@ -745,7 +745,7 @@ this function appends the default value from
(insert "\n" (make-string
(if pos (org-get-valid-level level 1) 1) ?*)
" " child "\n")
(beginning-of-line 0)
(forward-line -1)
(list (concat (car parent-target) "/" child) file "" (point))))))
(defun org-olpath-completing-read (prompt collection &rest args)

View File

@ -557,7 +557,7 @@ Leave point in edit buffer."
(org-element-parent datum) nil))
(t (org-current-text-indentation)))))
(content-ind org-edit-src-content-indentation)
(blank-line (save-excursion (beginning-of-line)
(blank-line (save-excursion (forward-line 0)
(looking-at-p "^[[:space:]]*$")))
(empty-line (and blank-line (looking-at-p "^$")))
(preserve-blank-line (or (and blank-line (not empty-line))
@ -1424,8 +1424,8 @@ EVENT is passed to `mouse-set-point'."
(org-with-wide-buffer
(when (and write-back
(not (equal (buffer-substring beg end)
(with-current-buffer write-back-buf
(buffer-string)))))
(with-current-buffer write-back-buf
(buffer-string)))))
(undo-boundary)
(goto-char beg)
(let ((expecting-bol (bolp)))
@ -1450,7 +1450,7 @@ EVENT is passed to `mouse-set-point'."
(org-fold-folded-p nil 'block)
(cl-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block))
(overlays-at (point))))
(beginning-of-line 0))
(forward-line -1))
(write-back (org-src--goto-coordinates coordinates beg end))))
;; Clean up left-over markers and restore window configuration.
(set-marker beg nil)

View File

@ -754,7 +754,7 @@ Field is restored even in case of abnormal exit."
"Non-nil when point (or POS) is in #+TBLFM line."
(save-excursion
(goto-char (or pos (point)))
(beginning-of-line)
(forward-line 0)
(and (let ((case-fold-search t)) (looking-at org-TBLFM-regexp))
(org-element-type-p (org-element-at-point) 'table))))
@ -845,7 +845,7 @@ SIZE is a string Columns x Rows like for example \"3x2\"."
"\n")))
(if (string-match "^[ \t]*$" (buffer-substring-no-properties
(line-beginning-position) (point)))
(beginning-of-line 1)
(forward-line 0)
(newline))
;; (mapcar (lambda (x) (insert line)) (make-list rows t))
(dotimes (_ rows) (insert line))
@ -891,7 +891,7 @@ nil When nil, the command tries to be smart and figure out the
(when (equal separator '(64))
(setq separator (read-regexp "Regexp for field separator")))
(goto-char beg)
(beginning-of-line 1)
(forward-line 0)
(setq beg (point-marker))
(goto-char end)
(if (bolp) (backward-char 1) (end-of-line 1))
@ -910,13 +910,13 @@ nil When nil, the command tries to be smart and figure out the
;; parse the csv stuff
(cond
((looking-at "^") (insert "| "))
((looking-at "[ \t]*$") (replace-match " |") (beginning-of-line 2))
((looking-at "[ \t]*$") (replace-match " |") (forward-line 1))
((looking-at "[ \t]*\"\\([^\"\n]*\\)\"")
(replace-match "\\1")
(if (looking-at "\"") (insert "\"")))
((looking-at "[^,\n]+") (goto-char (match-end 0)))
((looking-at "[ \t]*,") (replace-match " | "))
(t (beginning-of-line 2))))
(t (forward-line 1))))
(setq re (cond
((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
((equal separator '(16)) "^\\|\t")
@ -993,9 +993,9 @@ applies a recipe that works for simple tables."
;; insert a hline before first
(goto-char beg)
(org-table-insert-hline 'above)
(beginning-of-line -1)
(forward-line -2)
;; insert a hline after each line
(while (progn (beginning-of-line 3) (< (point) end))
(while (progn (forward-line 2) (< (point) end))
(org-table-insert-hline))
(goto-char beg)
(setq end (move-marker end (org-table-end)))
@ -1069,7 +1069,7 @@ Before doing so, re-align the table if necessary."
(goto-char (match-beginning 1)))
(if (looking-at "-")
(progn
(beginning-of-line 0)
(forward-line -1)
(org-table-insert-row 'below))
(if (looking-at " ") (forward-char 1))))
(error
@ -1143,11 +1143,11 @@ Before doing so, re-align the table if necessary."
org-table-may-need-update)
(org-table-align))
(let ((col (org-table-current-column)))
(beginning-of-line 2)
(forward-line 1)
(unless (bolp) (insert "\n")) ;missing newline at eob
(when (or (not (org-at-table-p))
(org-at-table-hline-p))
(beginning-of-line 0)
(forward-line -1)
(org-table-insert-row 'below))
(org-table-goto-column col)
(skip-chars-backward "^|\n\r")
@ -1190,7 +1190,7 @@ When ALIGN is set, also realign the table."
(interactive)
(save-excursion
(let ((pos (point)))
(beginning-of-line)
(forward-line 0)
(if (not (search-forward "|" pos t)) 0
(let ((column 1)
(separator (if (org-at-table-hline-p) "[+|]" "|")))
@ -1342,7 +1342,7 @@ of the field.
If there are less than N fields, just go to after the last delimiter.
However, when FORCE is non-nil, create new columns if necessary."
(interactive "p")
(beginning-of-line 1)
(forward-line 0)
(when (> n 0)
(while (and (> (setq n (1- n)) -1)
(or (search-forward "|" (line-end-position) t)
@ -1621,15 +1621,15 @@ Swap with anything in target cell."
(interactive "P")
(let* ((col (current-column))
(pos (point))
(hline1p (save-excursion (beginning-of-line 1)
(hline1p (save-excursion (forward-line 0)
(looking-at org-table-hline-regexp)))
(dline1 (org-table-current-dline))
(dline2 (+ dline1 (if up -1 1)))
(tonew (if up 0 2))
(tonew (if up -1 1))
hline2p)
(when (and up (= (point-min) (line-beginning-position)))
(user-error "Cannot move row further"))
(beginning-of-line tonew)
(forward-line tonew)
(when (or (and (not up) (eobp)) (not (org-at-table-p)))
(goto-char pos)
(user-error "Cannot move row further"))
@ -1638,16 +1638,16 @@ Swap with anything in target cell."
(goto-char pos)
(let ((row (delete-and-extract-region (line-beginning-position)
(line-beginning-position 2))))
(beginning-of-line tonew)
(forward-line tonew)
(unless (bolp) (insert "\n")) ;at eob without a newline
(insert row)
(unless (bolp) (insert "\n")) ;missing final newline in ROW
(beginning-of-line 0)
(forward-line -1)
(org-move-to-column col)
(unless (or hline1p hline2p
(not (or (not org-table-fix-formulas-confirm)
(funcall org-table-fix-formulas-confirm
"Fix formulas? "))))
(funcall org-table-fix-formulas-confirm
"Fix formulas? "))))
(org-table-fix-formulas
"@" (list
(cons (number-to-string dline1) (number-to-string dline2))
@ -1668,12 +1668,12 @@ With prefix ARG, insert below the current line."
;; Fix the first field if necessary
(when (string-match "^[ \t]*| *[#*$] *|" line)
(setq new (replace-match (match-string 0 line) t t new)))
(beginning-of-line (if arg 2 1))
(forward-line (if arg 1 0))
;; Buffer may not end of a newline character, so ensure
;; (beginning-of-line 2) moves point to a new line.
;; (forward-line 1) moves point to a new line.
(unless (bolp) (insert "\n"))
(let (org-table-may-need-update) (insert-before-markers new "\n"))
(beginning-of-line 0)
(forward-line -1)
(re-search-forward "| ?" (line-end-position) t)
(when (or org-table-may-need-update org-table-overlay-coordinates)
(org-table-align))
@ -1699,9 +1699,9 @@ With prefix ABOVE, insert above the current line."
(concat "+" (make-string (- (match-end 1) (match-beginning 1))
?-) "|") t t line)))
(and (string-match "\\+" line) (setq line (replace-match "|" t t line)))
(beginning-of-line (if above 1 2))
(forward-line (if above 0 1))
(insert line "\n")
(beginning-of-line (if above 1 -1))
(forward-line (if above 0 -2))
(org-move-to-column col)
(when org-table-overlay-coordinates (org-table-align)))))
@ -1747,7 +1747,7 @@ In particular, this does handle wide and invisible characters."
(org-table-with-shrunk-columns
(kill-region (line-beginning-position)
(min (1+ (line-end-position)) (point-max)))
(if (not (org-at-table-p)) (beginning-of-line 0))
(if (not (org-at-table-p)) (forward-line -1))
(org-move-to-column col)
(when (and dline
(or (not org-table-fix-formulas-confirm)
@ -1893,7 +1893,7 @@ However, when N is 0, do not increment the field at all."
(save-excursion
;; Get reference field.
(if initial-field (setq field initial-field)
(beginning-of-line)
(forward-line 0)
(setq field
(catch :exit
(while (re-search-backward org-table-dataline-regexp beg t)
@ -1901,7 +1901,7 @@ However, when N is 0, do not increment the field at all."
(cond ((and (> n 1) f) (cl-decf n))
(f (throw :exit (org-trim f)))
(t nil))
(beginning-of-line)))
(forward-line 0)))
(user-error "No non-empty field found"))))
;; Check if increment is appropriate, and how it should be done.
(when (and org-table-copy-increment (/= n 0))
@ -2186,7 +2186,7 @@ If optional argument LOCATION is a buffer position, insert it at
LOCATION instead."
(save-excursion
(if location
(progn (goto-char location) (beginning-of-line))
(progn (goto-char location) (forward-line 0))
(goto-char (org-table-end)))
(let ((case-fold-search t))
(if (looking-at "\\([ \t]*\n\\)*[ \t]*\\(#\\+TBLFM:\\)\\(.*\n?\\)")
@ -2236,7 +2236,7 @@ on the first line after the table. However, if optional argument
LOCATION is a buffer position, consider the formulas there."
(save-excursion
(if location
(progn (goto-char location) (beginning-of-line))
(progn (goto-char location) (forward-line 0))
(goto-char (org-table-end)))
(let ((case-fold-search t))
(when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM: *\\(.*\\)")
@ -2356,7 +2356,7 @@ of the new mark."
newchar))
(when l1 (goto-char l1))
(save-excursion
(beginning-of-line)
(forward-line 0)
(unless (looking-at org-table-dataline-regexp)
(user-error "Not at a table data line")))
(when no-special-column
@ -2365,7 +2365,7 @@ of the new mark."
(let ((previous-line-end (line-end-position))
(newchar
(save-excursion
(beginning-of-line)
(forward-line 0)
(cond ((not (looking-at "^[ \t]*| *\\([#!$*^_ ]\\) *|")) "#")
(newchar)
(t (cadr (member (match-string 1)
@ -2397,8 +2397,8 @@ of the new mark."
(interactive)
(and org-table-allow-automatic-line-recalculation
(not (and (memq last-command org-recalc-commands)
(eq org-last-recalc-line (line-beginning-position))))
(save-excursion (beginning-of-line 1)
(eq org-last-recalc-line (line-beginning-position))))
(save-excursion (forward-line 0)
(looking-at org-table-auto-recalculate-regexp))
(org-table-recalculate) t))
@ -3152,7 +3152,7 @@ with the prefix ARG."
(insert formula "\n")
(let ((e (point-marker)))
;; Recalculate the table.
(beginning-of-line 0) ; move to the inserted line
(forward-line -1) ; move to the inserted line
(skip-chars-backward " \r\n\t")
(unwind-protect
(org-call-with-arg #'org-table-recalculate (or arg t))
@ -3697,7 +3697,7 @@ With prefix ARG, apply the new formulas to the table."
"Pretty-print and re-indent Lisp expressions in the Formula Editor."
(interactive)
(let ((pos (point)) beg end ind)
(beginning-of-line 1)
(forward-line 0)
(cond
((looking-at "[ \t]")
(goto-char pos)
@ -3723,7 +3723,7 @@ With prefix ARG, apply the new formulas to the table."
(untabify (point-min) (point-max))
(goto-char (1+ (point-min)))
(while (re-search-forward "^." nil t)
(beginning-of-line 1)
(forward-line 0)
(insert ind))
(goto-char (point-max))
(org-delete-backward-char 1)))
@ -3903,7 +3903,7 @@ When non-nil, return the overlay narrowing the field."
;; However, fixing it requires to check every row, which may be
;; slow on large tables. Moreover, the hindrance of this
;; pathological case is very limited.
(beginning-of-line)
(forward-line 0)
(search-forward "|")
(let ((separator (if (org-at-table-hline-p) "+" "|"))
(column 1)
@ -4973,7 +4973,7 @@ When LOCAL is non-nil, show references for the table at point."
(save-excursion
(end-of-line)
(re-search-backward "^\\S-" nil t)
(beginning-of-line)
(forward-line 0)
(when (looking-at "\\(\\$[0-9a-zA-Z]+\\|@[0-9]+\\$[0-9]+\\|[a-zA-Z]+\
\\([0-9]+\\|&\\)\\) *=")
(setq dest
@ -5336,7 +5336,7 @@ With prefix arg, also recompute table."
(interactive "P")
(let ((case-fold-search t) (pos (point)) action)
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(setq action (cond
((looking-at "[ \t]*#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
((looking-at "[ \t]*|") pos)
@ -5353,7 +5353,7 @@ With prefix arg, also recompute table."
(run-hooks 'orgtbl-after-send-table-hook)))
((eq action 'recalc)
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(skip-chars-backward " \r\n\t")
(if (org-at-table-p)
(org-call-with-arg 'org-table-recalculate t))))
@ -5439,7 +5439,7 @@ a radio table."
(save-excursion
(goto-char (org-table-begin))
(let (rtn)
(beginning-of-line 0)
(forward-line -1)
(while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
(let ((name (org-no-properties (match-string 1)))
(transform (intern (match-string 2)))
@ -5447,7 +5447,7 @@ a radio table."
(read (concat "(" (match-string 3) ")")))))
(push (list :name name :transform transform :params params)
rtn)
(beginning-of-line 0)))
(forward-line -1)))
rtn)))
(defun orgtbl-send-replace-tbl (name text)
@ -5463,7 +5463,7 @@ a radio table."
(let ((beg (line-beginning-position 2)))
(unless (re-search-forward end-re nil t)
(user-error "Cannot find end of receiver location at %d" beg))
(beginning-of-line)
(forward-line 0)
(delete-region beg (point))
(insert text "\n")))
(unless location-flag
@ -5568,22 +5568,22 @@ First element has index 0, or I0 if given."
(let* ((case-fold-search t)
(re1 (concat "^" (regexp-quote comment-start) orgtbl-line-start-regexp))
(re2 (concat "^" orgtbl-line-start-regexp))
(commented (save-excursion (beginning-of-line 1)
(commented (save-excursion (forward-line 0)
(cond ((looking-at re1) t)
((looking-at re2) nil)
(t (user-error "Not at an org table")))))
(re (if commented re1 re2))
beg end)
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(while (and (not (eq (point) (point-min)))
(looking-at re))
(beginning-of-line 0))
(unless (eq (point) (point-min)) (beginning-of-line 2))
(forward-line -1))
(unless (eq (point) (point-min)) (forward-line 1))
(setq beg (point))
(while (and (not (eq (point) (point-max)))
(looking-at re))
(beginning-of-line 2))
(forward-line 1))
(setq end (point)))
(comment-region beg end (if commented '(4) nil))))

View File

@ -275,7 +275,7 @@ it in the buffer."
(itemp (goto-char pos) (error "This is not a timer list"))
;; Else, start a new list.
(t
(beginning-of-line)
(forward-line 0)
(org-indent-line)
(insert "- ")
(org-timer (when arg '(4)))

View File

@ -5510,7 +5510,7 @@ by a #."
'(display t invisible t intangible t))
;; Handle short captions
(save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at (rx (group (zero-or-more (any " \t"))
"#+caption"
(optional "[" (zero-or-more any) "]")
@ -6430,7 +6430,7 @@ unconditionally."
"Make the number of empty lines before current exactly N.
So this will delete or add empty lines."
(let ((column (current-column)))
(beginning-of-line)
(forward-line 0)
(unless (bobp)
(let ((start (save-excursion
(skip-chars-backward " \r\t\n")
@ -6568,7 +6568,7 @@ unchecked check box."
(run-hook-with-args-until-success
'org-todo-get-default-hook new-mark-x nil)
new-mark-x)))
(beginning-of-line 1)
(forward-line 0)
(and (looking-at org-outline-regexp) (goto-char (match-end 0))
(if org-treat-insert-todo-heading-as-state-change
(org-todo new-mark)
@ -6654,7 +6654,7 @@ headings in the region."
"Fix cursor position and indentation after demoting/promoting."
(let ((pos (point)))
(when (save-excursion
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search nil)) (looking-at org-todo-line-regexp))
(or (eq pos (match-end 1)) (eq pos (match-end 2))))
(cond ((eobp) (insert " "))
@ -6676,7 +6676,7 @@ Returns 0 for the first headline in the buffer, and nil if before the
first headline."
(and (org-current-level)
(or (and (/= (line-beginning-position) (point-min))
(save-excursion (beginning-of-line 0) (org-current-level)))
(save-excursion (forward-line -1) (org-current-level)))
0)))
(defun org-reduced-level (l)
@ -6883,7 +6883,7 @@ Assume point is at a heading or an inlinetask beginning."
;; Ignore contents of example blocks and source
;; blocks if their indentation is meant to be
;; preserved. Jump to block's closing line.
(beginning-of-line)
(forward-line 0)
(or (and (looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)")
(let ((e (org-element-at-point)))
(and (org-element-type-p
@ -6892,7 +6892,7 @@ Assume point is at a heading or an inlinetask beginning."
(org-element-property :preserve-indent e))
(goto-char (org-element-end e))
(progn (skip-chars-backward " \r\t\n")
(beginning-of-line)
(forward-line 0)
t))))
(forward-line))))))))
;; Shift lines but footnote definitions, inlinetasks boundaries
@ -6908,7 +6908,7 @@ Assume point is at a heading or an inlinetask beginning."
((looking-at-p "[ \t]*$") (forward-line))
(t
(indent-line-to (+ (current-indentation) diff))
(beginning-of-line)
(forward-line 0)
(or (and (looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)")
(let ((e (org-element-at-point)))
(and (org-element-type-p
@ -6917,7 +6917,7 @@ Assume point is at a heading or an inlinetask beginning."
(org-element-property :preserve-indent e))
(goto-char (org-element-end e))
(progn (skip-chars-backward " \r\t\n")
(beginning-of-line)
(forward-line 0)
t))))
(forward-line)))))))))
@ -7709,7 +7709,7 @@ function is being called interactively."
(or (org-at-heading-p) (outline-next-heading))
(setq start (point))
(goto-char (point-max))
(beginning-of-line 1)
(forward-line 0)
(when (looking-at ".*?\\S-")
;; File ends in a non-white line
(end-of-line 1)
@ -8734,7 +8734,7 @@ If not found, stay at current position and return nil."
"Create a dynamic block section, with parameters taken from PLIST.
PLIST must contain a :name entry which is used as the name of the block."
(when (string-match "\\S-" (buffer-substring (line-beginning-position)
(line-end-position)))
(line-end-position)))
(end-of-line 1)
(newline))
(let ((col (current-column))
@ -8745,7 +8745,7 @@ PLIST must contain a :name entry which is used as the name of the block."
(setq plist (cddr plist))
(insert " " (prin1-to-string (pop plist)))))
(insert "\n\n" (make-string col ?\ ) "#+END:\n")
(beginning-of-line -2)))
(forward-line -3)))
(defun org-prepare-dblock ()
"Prepare dynamic block for refresh.
@ -8758,7 +8758,7 @@ the property list including an extra property :name with the block name."
(params (append (list :name name)
(read (concat "(" (match-string 3) ")")))))
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(skip-chars-forward " \t")
(setq params (plist-put params :indentation-column (current-column))))
(unless (re-search-forward org-dblock-end-re nil t)
@ -8865,7 +8865,7 @@ the correct writing function."
(forward-line 1)
(while (not (looking-at org-dblock-end-re))
(insert indent)
(beginning-of-line 2))
(forward-line 1))
(when (looking-at org-dblock-end-re)
(and (looking-at "[ \t]+")
(replace-match ""))
@ -9092,7 +9092,7 @@ When foo is written as FOO, upcase the #+BEGIN/END as well."
(when region? (goto-char region-start))
(let ((column (current-indentation)))
(if (save-excursion (skip-chars-backward " \t") (bolp))
(beginning-of-line)
(forward-line 0)
(insert "\n"))
(save-excursion
(indent-to column)
@ -9442,8 +9442,9 @@ When called through ELisp, arg is also interpreted in the following way:
;; Fixup cursor location if close to the keyword.
(when (and (outline-on-heading-p)
(not (bolp))
(save-excursion (beginning-of-line 1)
(looking-at org-todo-line-regexp))
(save-excursion
(forward-line 0)
(looking-at org-todo-line-regexp))
(< (point) (+ 2 (or (match-end 2) (match-end 1)))))
(goto-char (or (match-end 2) (match-end 1)))
(and (looking-at " ")
@ -9632,15 +9633,15 @@ all statistics cookies in the buffer."
(re-search-forward
"^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) \\[[- X]\\]" end t))
(not (save-excursion
(re-search-forward
":COOKIE_DATA:.*\\<todo\\>" end t))))
(re-search-forward
":COOKIE_DATA:.*\\<todo\\>" end t))))
(org-update-checkbox-count)
(if (and l2 (> l2 l1))
(progn
(goto-char end)
(org-update-parent-todo-statistics))
(goto-char pos)
(beginning-of-line 1)
(forward-line 0)
(while (re-search-forward
"\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)"
(line-end-position) t)
@ -9668,7 +9669,7 @@ statistics everywhere."
checkbox-beg cookie-present)
(catch 'exit
(save-excursion
(beginning-of-line 1)
(forward-line 0)
(setq ltoggle (funcall outline-level))
;; Three situations are to consider:
@ -10317,7 +10318,7 @@ nil."
(or (let ((cached (org-element-at-point nil 'cached)))
(and cached (org-element-type-p cached 'planning)))
(org-with-wide-buffer
(beginning-of-line)
(forward-line 0)
(and (looking-at-p org-planning-line-re)
(eq (point)
(ignore-errors
@ -10503,11 +10504,11 @@ narrowing."
(org-end-of-meta-data org-log-state-notes-insert-after-drawers)
(let ((endpos (point)))
(skip-chars-forward " \t\n")
(beginning-of-line)
(forward-line 0)
(unless org-log-states-order-reversed
(org-skip-over-state-notes)
(skip-chars-backward " \t\n")
(beginning-of-line 2))
(forward-line 1))
;; When current headline is at the end of buffer and does not
;; end with trailing newline the above can move to the
;; beginning of the headline.
@ -10993,7 +10994,7 @@ Return the priority value."
(org-get-at-bol 'priority)
(save-excursion
(save-match-data
(beginning-of-line)
(forward-line 0)
(and (looking-at org-heading-regexp)
(org-get-priority (match-string 0))))))))
(message "Priority is %d" (if pri pri -1000))))
@ -11860,7 +11861,7 @@ Returns the new tags string, or nil to not change the current settings."
;; updating the overlay text.
;; FIXME: What if we are setting file tags?
(save-excursion
(beginning-of-line)
(forward-line 0)
(if (looking-at org-tag-line-re)
(setq ov-start (match-beginning 1)
ov-end (match-end 1)
@ -12089,7 +12090,7 @@ Returns the new tags string, or nil to not change the current settings."
;; Continue setting tags in the loop.
;; Update the currently active tags indication in the completion buffer.
(goto-char (point-min))
(beginning-of-line 2)
(forward-line 1)
(delete-region (point) (line-end-position))
(org-fast-tag-insert "Current" current-tags current-face)
;; Update the active tags displayed in the overlay in Org buffer.
@ -12396,7 +12397,7 @@ FORCE is non-nil, or return nil."
(defun org-at-property-drawer-p ()
"Non-nil when point is at the first line of a property drawer."
(org-with-wide-buffer
(beginning-of-line)
(forward-line 0)
(and (looking-at org-property-drawer-re)
(or (bobp)
(progn
@ -12416,7 +12417,7 @@ FORCE is non-nil, or return nil."
"Non-nil when point is inside a property drawer.
See `org-property-re' for match data, if applicable."
(save-excursion
(beginning-of-line)
(forward-line 0)
(and (looking-at org-property-re)
(let ((property-drawer (save-match-data (org-get-property-block))))
(and property-drawer
@ -13114,7 +13115,7 @@ Point is left between drawer's boundaries."
(unwind-protect
(progn
(goto-char rbeg)
(beginning-of-line)
(forward-line 0)
(when (save-excursion
(re-search-forward org-outline-regexp-bol rend t))
(user-error "Drawers cannot contain headlines"))
@ -13122,7 +13123,7 @@ Point is left between drawer's boundaries."
;; non-blank line in region. Insert drawer's opening
;; there, then indent it.
(org-skip-whitespace)
(beginning-of-line)
(forward-line 0)
(insert ":" drawer ":\n")
(forward-line -1)
(indent-for-tab-command)
@ -13387,7 +13388,7 @@ completion."
(org-at-property-p)
(replace-match (concat " :" key ": " nval) t t)
(org-indent-line)
(beginning-of-line 1)
(forward-line 0)
(skip-chars-forward " \t")
(when (equal prop org-effort-property)
(when (string= org-clock-current-task heading)
@ -16896,10 +16897,10 @@ this function returns t, nil otherwise."
(catch 'exit
(unless (org-region-active-p)
(setq beg (line-beginning-position))
(beginning-of-line 2)
(forward-line 1)
(while (and (not (eobp)) ;; this is like `next-line'
(org-invisible-p (1- (point))))
(beginning-of-line 2))
(forward-line 1))
(setq end (point))
(goto-char beg)
(goto-char (line-end-position))
@ -16936,7 +16937,7 @@ for more information."
;; Search previous subtree.
(progn
(goto-char beg)
(beginning-of-line)
(forward-line 0)
(not (re-search-backward (format "^\\*\\{%s\\} " level) nil t))))
(user-error "Cannot move past superior level or buffer limit"))
;; Drag first subtree above below the selected.
@ -17677,7 +17678,7 @@ ignoring region."
end (line-end-position (if arg 2 1))))
(if (save-excursion
(goto-char beg)
(beginning-of-line)
(forward-line 0)
(and (< (line-end-position) end)
(let ((case-fold-search nil))
(looking-at org-complex-heading-regexp))))
@ -18528,7 +18529,7 @@ and :keyword."
(line-end-position))
clist)
(when (progn
(beginning-of-line 1)
(forward-line 0)
(looking-at org-todo-line-tags-regexp))
(push (org-point-in-group p 1 :headline-stars) clist)
(push (org-point-in-group p 2 :todo-keyword) clist)
@ -18728,7 +18729,7 @@ Returns the number of empty lines passed."
(skip-chars-backward " \t\n\r")
(unless (eobp)
(forward-line -1)))
(beginning-of-line 2)
(forward-line 1)
(goto-char (min (point) pos))
(count-lines (point) pos)))
@ -18776,7 +18777,7 @@ the end. If a numeric prefix UP is given, move up into the
hierarchy of headlines by UP levels before marking the subtree."
(interactive "P")
(org-with-limited-levels
(cond ((org-at-heading-p) (beginning-of-line))
(cond ((org-at-heading-p) (forward-line 0))
((org-before-first-heading-p) (user-error "Not in a subtree"))
(t (outline-previous-visible-heading 1))))
(when up (while (and (> up 0) (org-up-heading-safe)) (cl-decf up)))
@ -18891,7 +18892,7 @@ ELEMENT."
(org-element-parent previous) t))))))))))
;; Otherwise, move to the first non-blank line above.
(t
(beginning-of-line)
(forward-line 0)
(let ((pos (point)))
(skip-chars-backward " \r\t\n")
(cond
@ -18940,7 +18941,7 @@ ELEMENT."
"Align node property at point.
Alignment is done according to `org-property-format', which see."
(when (save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at org-property-re))
(org-combine-change-calls (match-beginning 0) (match-end 0)
(let ((newtext (concat (match-string 4)
@ -18995,7 +18996,7 @@ list structure. Instead, use \\<org-mode-map>`\\[org-shiftmetaleft]' or \
Also align node properties according to `org-property-format'."
(interactive)
(let* ((element (save-excursion (beginning-of-line) (org-element-at-point-no-context)))
(let* ((element (save-excursion (forward-line 0) (org-element-at-point-no-context)))
(type (org-element-type element)))
(unless (or (org-at-heading-p) ; headline has no indent ever.
;; Do not indent first element after headline data.
@ -19063,7 +19064,7 @@ assumed to be significant there."
(save-excursion
(goto-char start)
(skip-chars-forward " \r\t\n")
(unless (eobp) (beginning-of-line))
(unless (eobp) (forward-line 0))
(let ((indent-to
(lambda (ind pos)
;; Set IND as indentation for all lines between point and
@ -19103,10 +19104,10 @@ assumed to be significant there."
;; specially later.
((or (memq type '(paragraph table table-row))
(not (or (org-element-contents-begin element)
(memq type '(example-block src-block)))))
(memq type '(example-block src-block)))))
(when (eq type 'node-property)
(org--align-node-property)
(beginning-of-line))
(forward-line 0))
(funcall indent-to ind (min element-end end)))
;; Elements consisting of three parts: before the
;; contents, the contents, and after the contents. The
@ -19270,7 +19271,7 @@ matches in paragraphs or comments, use it."
(unless (org-at-heading-p)
(let* ((p (line-beginning-position))
(element (save-excursion
(beginning-of-line)
(forward-line 0)
(org-element-at-point)))
(type (org-element-type element))
(post-affiliated (org-element-post-affiliated element)))
@ -19278,7 +19279,7 @@ matches in paragraphs or comments, use it."
(cl-case type
(comment
(save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at "[ \t]*")
(concat (match-string 0) "# ")))
(footnote-definition "")
@ -19289,7 +19290,7 @@ matches in paragraphs or comments, use it."
;; unless the paragraph is at the beginning of an item.
(let ((parent (org-element-parent element)))
(save-excursion
(beginning-of-line)
(forward-line 0)
(cond ((org-element-type-p parent 'item)
(make-string (org-list-item-body-column
(org-element-begin parent))
@ -19315,7 +19316,7 @@ matches in paragraphs or comments, use it."
(skip-chars-backward " \r\t\n")
(line-beginning-position))))
(when (and (>= p cbeg) (< p cend))
(if (save-excursion (beginning-of-line) (looking-at "[ \t]+"))
(if (save-excursion (forward-line 0) (looking-at "[ \t]+"))
(match-string 0)
""))))))))))
@ -19403,7 +19404,7 @@ a footnote definition, try to fill the first paragraph within."
(save-excursion (end-of-line)
(re-search-backward "^[ \t]*$" beg 'move)
(line-beginning-position))
(save-excursion (beginning-of-line)
(save-excursion (forward-line 0)
(re-search-forward "^[ \t]*$" end 'move)
(line-beginning-position))
justify))))
@ -19427,7 +19428,7 @@ a footnote definition, try to fill the first paragraph within."
(when (> end begin)
(let ((fill-prefix
(save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at "[ \t]*#")
(let ((comment-prefix (match-string 0)))
(goto-char (match-end 0))
@ -19548,7 +19549,7 @@ region only contains such lines."
;; elements or at the beginning of a headline or an inlinetask,
;; and before any one-line elements (e.g., a clock).
(progn
(beginning-of-line)
(forward-line 0)
(let* ((element (org-element-at-point))
(type (org-element-type element)))
(cond
@ -19578,7 +19579,7 @@ region only contains such lines."
(end (copy-marker
(save-excursion
(goto-char (region-end))
(unless (eolp) (beginning-of-line))
(unless (eolp) (forward-line 0))
(if (save-excursion (re-search-backward "\\S-" begin t))
(progn (skip-chars-backward " \r\t\n") (point))
(point)))))
@ -19682,7 +19683,8 @@ Throw an error if no block is found."
(count (or arg 1))
(origin (point))
last-element)
(if backward (beginning-of-line) (end-of-line))
(if backward (forward-line 0)
(let ((inhibit-field-text-motion t)) (end-of-line)))
(while (and (> count 0) (funcall search-fn re nil t))
(let ((element (save-excursion
(goto-char (match-beginning 0))
@ -19754,7 +19756,7 @@ major mode."
(line-beginning-position))
(point))))
(org-babel-do-in-edit-buffer (call-interactively 'comment-dwim))
(beginning-of-line)
(forward-line 0)
(if (looking-at "\\s-*$") (delete-region (point) (line-end-position))
(open-line 1))
(org-indent-line)
@ -20023,7 +20025,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
;; characters if line starts with such of these (e.g., with
;; a link at column 0). Really move to the beginning of the
;; current visible line.
(beginning-of-line))
(forward-line 0))
(cond
;; No special behavior. Point is already at the beginning of
;; a line, logical or visual.
@ -20087,7 +20089,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
;; At a headline, with tags.
((and special
(save-excursion
(beginning-of-line)
(forward-line 0)
(let ((case-fold-search nil))
(looking-at org-complex-heading-regexp)))
(match-end 5))
@ -20269,7 +20271,7 @@ interactive command with similar behavior."
(goto-char beg)
(when (and (bolp) subtreep
(not (setq swallowp
(org-yank-folding-would-swallow-text beg end))))
(org-yank-folding-would-swallow-text beg end))))
(org-with-limited-levels
(or (looking-at org-outline-regexp)
(re-search-forward org-outline-regexp-bol end t))
@ -20285,7 +20287,7 @@ interactive command with similar behavior."
(goto-char end)
(skip-chars-forward " \t\n\r")
(beginning-of-line 1)
(forward-line 0)
(push-mark beg 'nomsg)))
((and subtreep org-yank-adjusted-subtrees)
(let ((beg (line-beginning-position)))
@ -20311,7 +20313,7 @@ interactive command with similar behavior."
(defun org-back-to-heading (&optional invisible-ok)
"Go back to beginning of heading or inlinetask."
(beginning-of-line)
(forward-line 0)
(or (and (org-at-heading-p (not invisible-ok))
(not (and (featurep 'org-inlinetask)
(fboundp 'org-inlinetask-end-p)
@ -20353,7 +20355,7 @@ Respect narrowing."
"Return t if point is on a (possibly invisible) heading line.
If INVISIBLE-NOT-OK is non-nil, an invisible heading line is not ok."
(save-excursion
(beginning-of-line)
(forward-line 0)
(and (or (not invisible-not-ok) (not (org-fold-folded-p)))
(looking-at outline-regexp))))
@ -20393,7 +20395,7 @@ Optional argument ELEMENT contains element at point."
"Return t if cursor is in a commented line."
(save-excursion
(save-match-data
(beginning-of-line)
(forward-line 0)
(looking-at org-comment-regexp))))
(defun org-at-keyword-p nil
@ -20422,7 +20424,7 @@ empty."
(and (looking-at "[ \t]*$")
org-todo-line-regexp
(save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at org-todo-line-regexp)
(string= (match-string 3) "")))))
@ -20656,7 +20658,7 @@ non-nil it will also look at invisible ones."
(cl-decf count)
(when (= l level) (setq result (point)))))))
(goto-char result))
(beginning-of-line))))
(forward-line 0))))
(defun org-backward-heading-same-level (arg &optional invisible-ok)
"Move backward to the ARG'th subheading at same level as this one.
@ -20670,7 +20672,7 @@ With ARG, repeats or can move backward if negative."
(interactive "p")
(let ((regexp (concat "^" (org-get-limited-outline-regexp))))
(if (< arg 0)
(beginning-of-line)
(forward-line 0)
(end-of-line))
(while (and (< arg 0) (re-search-backward regexp nil :move))
(unless (bobp)
@ -20685,7 +20687,7 @@ With ARG, repeats or can move backward if negative."
(skip-chars-forward " \t\n")
(end-of-line))
(cl-decf arg))
(if (> arg 0) (goto-char (point-max)) (beginning-of-line))))
(if (> arg 0) (goto-char (point-max)) (forward-line 0))))
(defun org-previous-visible-heading (arg)
"Move to the previous visible heading.
@ -21147,11 +21149,11 @@ Move to the previous element at the same level, when possible."
(let ((c (current-column)))
(if (< 0 arg)
(progn
(beginning-of-line 2)
(forward-line 1)
(transpose-lines 1)
(beginning-of-line 0))
(forward-line -1))
(transpose-lines 1)
(beginning-of-line -1))
(forward-line -2))
(org-move-to-column c))))
(defun org-drag-line-backward (arg)

View File

@ -1849,7 +1849,7 @@ produce code that uses these same face definitions."
(delete-region (point-min) (match-beginning 0)))
(when (re-search-forward "</style>" nil t)
(delete-region (1+ (match-end 0)) (point-max)))
(beginning-of-line 1)
(forward-line 0)
(when (looking-at " +") (replace-match ""))
(goto-char (point-min)))

View File

@ -4287,7 +4287,7 @@ produced."
(and (search-forward-regexp (regexp-opt org-latex-compilers)
(line-end-position 2)
t)
(progn (beginning-of-line) (looking-at-p "%"))
(progn (forward-line 0) (eq (char-after) ?%))
(match-string 0)))
;; Cannot find the compiler inserted by
;; `org-latex-template' -> `org-latex--insert-compiler'.

View File

@ -3302,7 +3302,7 @@ locally for the subtree through node properties."
(option (unless (assoc option options)
(push (cons option (eval (nth 3 entry) t)) options))))))
;; Move to an appropriate location in order to insert options.
(unless subtreep (beginning-of-line))
(unless subtreep (forward-line 0))
;; First (multiple) OPTIONS lines. Never go past fill-column.
(when options
(let ((items
@ -3379,7 +3379,7 @@ not have `buffer-file-name' assigned."
(unless (org-in-commented-heading-p)
(let ((element (save-match-data (org-element-at-point))))
(when (org-element-type-p element 'keyword)
(beginning-of-line)
(forward-line 0)
;; Extract arguments from keyword's value.
(let* ((value (org-element-property :value element))
(parameters (org-export-parse-include-value value dir))
@ -3599,7 +3599,7 @@ Return a string of lines to be included in the format expected by
(narrow-to-region (point) (point-max))))
(when lines
(org-skip-whitespace)
(beginning-of-line)
(forward-line 0)
(let* ((lines (split-string lines "-"))
(lbeg (string-to-number (car lines)))
(lend (string-to-number (cadr lines)))
@ -3734,7 +3734,7 @@ is to happen."
;; override blank lines in included file.
(goto-char (point-min))
(org-skip-whitespace)
(beginning-of-line)
(forward-line 0)
(delete-region (point-min) (point))
(goto-char (point-max))
(skip-chars-backward " \r\t\n")
@ -7048,7 +7048,7 @@ appropriate for `tabulated-list-print'."
(if (not source) (error "Source unavailable, please refresh buffer")
(let ((source-name (if (stringp source) source (buffer-name source))))
(if (save-excursion
(beginning-of-line)
(forward-line 0)
(looking-at-p (concat ".* +" (regexp-quote source-name) "$")))
source
;; SOURCE is not consistent with current line. The stack