Refactoring.

This commit is contained in:
Nicolas Goaziou 2010-07-19 09:16:13 +02:00
parent c3bbbc0926
commit 2b5b8cf8a2
1 changed files with 12 additions and 14 deletions

View File

@ -415,7 +415,7 @@ function ends."
(save-excursion (save-excursion
;; Move to eol so that current line can be matched by ;; Move to eol so that current line can be matched by
;; `org-item-re'. ;; `org-item-re'.
(let* ((limit (or (save-excursion (outline-previous-heading)) (point-min))) (let* ((limit (save-excursion (outline-previous-heading)))
(actual-pos (goto-char (point-at-eol))) (actual-pos (goto-char (point-at-eol)))
(last-item-start (save-excursion (last-item-start (save-excursion
(org-search-backward-unenclosed (org-item-re) limit t))) (org-search-backward-unenclosed (org-item-re) limit t)))
@ -520,13 +520,12 @@ A checkbox is blocked if all of the following conditions are fulfilled:
"Go to the beginning of the current hand-formatted item. "Go to the beginning of the current hand-formatted item.
If the cursor is not in an item, throw an error. Return point." If the cursor is not in an item, throw an error. Return point."
(interactive) (interactive)
(if (org-in-item-p) (if (not (org-in-item-p))
(if (org-at-item-p) (error "Not in an item")
(progn (beginning-of-line 1) ;; Possibly match the current line.
(point)) (end-of-line)
(org-search-backward-unenclosed (org-item-re) nil t) (org-search-backward-unenclosed (org-item-re) nil t)
(goto-char (point-at-bol))) (goto-char (point-at-bol))))
(error "Not in an item")))
(defun org-end-of-item () (defun org-end-of-item ()
"Go to the end of the current hand-formatted item. "Go to the end of the current hand-formatted item.
@ -805,7 +804,7 @@ If NO-SUBTREE is set, only indent the item itself, not its children."
(/= (point-at-bol) (org-list-top-point))) (/= (point-at-bol) (org-list-top-point)))
(error "Cannot outdent beyond top level item")) (error "Cannot outdent beyond top level item"))
(while (< (point) end) (while (< (point) end)
(beginning-of-line 1) (beginning-of-line)
(skip-chars-forward " \t") (setq ind1 (current-column)) (skip-chars-forward " \t") (setq ind1 (current-column))
(delete-region (point-at-bol) (point)) (delete-region (point-at-bol) (point))
(or (eolp) (org-indent-to-column (+ ind1 delta))) (or (eolp) (org-indent-to-column (+ ind1 delta)))
@ -875,11 +874,11 @@ Assumes cursor in item line."
(progn (org-outdent-item 1) (progn (org-outdent-item 1)
(if (equal org-tab-ind-state (org-get-indentation)) (if (equal org-tab-ind-state (org-get-indentation))
(org-outdent-item 1)) (org-outdent-item 1))
(end-of-line 1)) (end-of-line))
(error (error
(progn (progn
(while (< (org-get-indentation) org-tab-ind-state) (while (< (org-get-indentation) org-tab-ind-state)
(progn (org-indent-item 1) (end-of-line 1))) (progn (org-indent-item 1) (end-of-line)))
(setq this-command 'org-cycle)))) (setq this-command 'org-cycle))))
(setq org-tab-ind-state (org-get-indentation)) (setq org-tab-ind-state (org-get-indentation))
(org-indent-item 1)) (org-indent-item 1))
@ -1169,7 +1168,7 @@ the whole buffer."
(if recursive (if recursive
(<= curr-ind next-ind) (<= curr-ind next-ind)
(= curr-ind next-ind))) (= curr-ind next-ind)))
(save-excursion (end-of-line) (setq eline (point))) (setq eline (point-at-eol))
(if (org-search-forward-unenclosed re-box eline t) (if (org-search-forward-unenclosed re-box eline t)
(if (member (match-string 2) '("[ ]" "[-]")) (if (member (match-string 2) '("[ ]" "[-]"))
(setq c-off (1+ c-off)) (setq c-off (1+ c-off))
@ -1463,8 +1462,7 @@ this list."
(setq beg (point)) (setq beg (point))
(unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t) (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t)
(error "Cannot find end of insertion region")) (error "Cannot find end of insertion region"))
(beginning-of-line 1) (delete-region beg (point-at-bol))
(delete-region beg (point))
(goto-char beg) (goto-char beg)
(insert txt "\n"))) (insert txt "\n")))
(message "List converted and installed at receiver location")))) (message "List converted and installed at receiver location"))))