From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Patch to fix indent error when current line is in SRC block Date: Sat, 13 Sep 2008 20:07:10 +0200 Message-ID: <2D0F4F30-A408-47C8-AC03-8F9054892758@uva.nl> References: <8563p6x0sh.fsf@modprobe.cn> Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KebHG-00051G-3Q for emacs-orgmode@gnu.org; Sat, 13 Sep 2008 15:59:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KebHE-0004zR-Dv for emacs-orgmode@gnu.org; Sat, 13 Sep 2008 15:59:29 -0400 Received: from [199.232.76.173] (port=39446 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KebHE-0004z6-0i for emacs-orgmode@gnu.org; Sat, 13 Sep 2008 15:59:28 -0400 Received: from ey-out-1920.google.com ([74.125.78.149]:60390) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KebHD-0001M3-IK for emacs-orgmode@gnu.org; Sat, 13 Sep 2008 15:59:28 -0400 Received: by ey-out-1920.google.com with SMTP id 4so610318eyg.24 for ; Sat, 13 Sep 2008 12:59:26 -0700 (PDT) In-Reply-To: <8563p6x0sh.fsf@modprobe.cn> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "S.P.Tseng" Cc: emacs-orgmode@gnu.org Hi Tseng, thank you, I am accepting the patch. - Carsten On Sep 8, 2008, at 2:46 PM, S.P.Tseng wrote: > > I add function 'org-edit-src-find-region-and-lang' to the begin of the > 'org-indent-line-function'. When current line is in SRC block do > nothing. > > So, you can use below code to indent the whole buffer. > ,---- > | (defun my-iwb () > | "indent whole buffer" > | (interactive) > | (delete-trailing-whitespace) > | (indent-region (point-min) (point-max) nil) > | (untabify (point-min) (point-max))) > `---- > > --- > lisp/org.el | 141 +++++++++++++++++++++++++++++ > +----------------------------- > 1 files changed, 71 insertions(+), 70 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 26e8117..1ac78b0 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -1647,7 +1647,7 @@ end of the second format." > org-mode generates a time duration." > :group 'org-time > :type 'string) > - > + > (defcustom org-deadline-warning-days 14 > "No. of days before expiration during which a deadline becomes > active. > This variable governs the display in sparse trees and in the agenda. > @@ -2512,7 +2512,7 @@ Otherwise, return nil." > (<= org-clock-marker (point-at-eol))) > ;; The clock is running here > (setq org-clock-start-time > - (apply 'encode-time > + (apply 'encode-time > (org-parse-time-string (match-string 1)))) > (org-update-mode-line))) > (t > @@ -2683,8 +2683,8 @@ collapsed state." > ;; Autoload ID code > > (org-autoload "org-id" > - '(org-id-get-create org-id-new org-id-copy org-id-get > - org-id-get-with-outline-path-completion > + '(org-id-get-create org-id-new org-id-copy org-id-get > + org-id-get-with-outline-path-completion > org-id-get-with-outline-drilling > org-id-goto org-id-find)) > > @@ -5572,7 +5572,7 @@ the language, a switch telling of the content > should be in a single line." > (string-match "\\ (match-string 1 m)) > (t "fundamental")))) > - > + > (defun org-edit-src-exit () > "Exit special edit and protect problematic lines." > (interactive) > @@ -7959,7 +7959,7 @@ operation has put the subtree." > (defun org-olpath-completing-read (prompt collection &rest args) > "Read an outline path like a file name." > (let ((thetable collection)) > - (apply > + (apply > 'completing-read prompt > (lambda (string predicate &optional flag) > (let (rtn r s f (l (length string))) > @@ -8116,7 +8116,7 @@ This function can be used in a hook." > > (defcustom org-structure-template-alist > '( > - ("s" "#+begin_src ?\n\n#+end_src" > + ("s" "#+begin_src ?\n\n#+end_src" > "\n\n") > ("e" "#+begin_example\n?\n#+end_example" > "\n?\n") > @@ -8179,7 +8179,7 @@ expands them." > (t (newline)))) > (setq start (point)) > (if (string-match "%file" rpl) > - (setq rpl (replace-match > + (setq rpl (replace-match > (concat > "\"" > (save-match-data > @@ -8188,7 +8188,7 @@ expands them." > t t rpl))) > (insert rpl) > (if (re-search-backward "\\?" start t) (delete-char 1)))) > - > + > > (defun org-complete (&optional arg) > "Perform completion on word at point. > @@ -8587,7 +8587,7 @@ For calling through lisp, arg is also > interpreted in the following way: > (condition-case nil > (outline-forward-same-level 1) > (error (end-of-line 1))))) > - (replace-match > + (replace-match > (if is-percent > (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all))) > (format "[%d/%d]" cnt-done cnt-all))) > @@ -8609,7 +8609,7 @@ when there is a statistics cookie in the > headline! > (let (org-log-done org-log-states) ; turn off logging > (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\")))) > ") > - > + > (defun org-local-logging (value) > "Get logging settings from a property VALUE." > (let* (words w a) > @@ -10195,12 +10195,12 @@ the scanner. The following items can be > given here: > ((eq match t) (setq matcher t)) > ((eq match nil) (setq matcher t)) > (t (setq matcher (if match (org-make-tags-matcher match) t)))) > - > + > (when (eq scope 'tree) > (org-back-to-heading t) > (org-narrow-to-subtree) > (setq scope nil)) > - > + > (if (not scope) > (progn > (org-prepare-agenda-buffers > @@ -10489,7 +10489,7 @@ If yes, return this value. If not, return > the current value of the variable." > (move-marker org-entry-property-inherited-from (point)) > (throw 'ex tmp)) > (or (org-up-heading-safe) (throw 'ex nil))))) > - (or tmp > + (or tmp > (cdr (assoc property org-file-properties)) > (cdr (assoc property org-global-properties)) > (cdr (assoc property org-global-properties-fixed)))))) > @@ -12021,11 +12021,11 @@ If EXCLUDE-TMP is non-nil, ignore > temporary buffers." > (lambda (b) (string-match "\*Org .*Export" (buffer-name b)))) > ((eq predicate 'agenda) > (lambda (b) > - (with-current-buffer b > + (with-current-buffer b > (and (eq major-mode 'org-mode) > (setq bfn (buffer-file-name b)) > (member (file-truename bfn) agenda-files))))) > - (t (lambda (b) (with-current-buffer b > + (t (lambda (b) (with-current-buffer b > (or (eq major-mode 'org-mode) > (string-match "\*Org .*Export" > (buffer-name b))))))))) > @@ -12243,7 +12243,7 @@ When a buffer is unmodified, it is just > killed. When modified, it is saved > (append org-done-keywords-for-agenda org-done-keywords)) > (setq org-todo-keyword-alist-for-agenda > (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) > - (setq org-tag-alist-for-agenda > + (setq org-tag-alist-for-agenda > (append org-tag-alist-for-agenda org-tag-alist)) > > (save-excursion > @@ -14108,59 +14108,60 @@ which make use of the date at the cursor." > (defun org-indent-line-function () > "Indent line like previous, but further if previous was headline > or item." > (interactive) > - (let* ((pos (point)) > - (itemp (org-at-item-p)) > - column bpos bcol tpos tcol bullet btype bullet-type) > - ;; Find the previous relevant line > - (beginning-of-line 1) > - (cond > - ((looking-at "#") (setq column 0)) > - ((looking-at "\\*+ ") (setq column 0)) > - (t > - (beginning-of-line 0) > - (while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]")) > - (beginning-of-line 0)) > - (cond > - ((looking-at "\\*+[ \t]+") > - (if (not org-adapt-indentation) > - (setq column 0) > - (goto-char (match-end 0)) > - (setq column (current-column)))) > - ((org-in-item-p) > - (org-beginning-of-item) > -; (looking-at "[ \t]*\\(\\S-+\\)[ \t]*") > - (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \ > \)?") > - (setq bpos (match-beginning 1) tpos (match-end 0) > - bcol (progn (goto-char bpos) (current-column)) > - tcol (progn (goto-char tpos) (current-column)) > - bullet (match-string 1) > - bullet-type (if (string-match "[0-9]" bullet) "n" bullet)) > - (if (> tcol (+ bcol org-description-max-indent)) > - (setq tcol (+ bcol 5))) > - (if (not itemp) > - (setq column tcol) > - (goto-char pos) > - (beginning-of-line 1) > - (if (looking-at "\\S-") > - (progn > - (looking-at "[ \t]*\\(\\S-+\\)[ \t]*") > - (setq bullet (match-string 1) > - btype (if (string-match "[0-9]" bullet) "n" bullet)) > - (setq column (if (equal btype bullet-type) bcol tcol))) > - (setq column (org-get-indentation))))) > - (t (setq column (org-get-indentation)))))) > - (goto-char pos) > - (if (<= (current-column) (current-indentation)) > - (org-indent-line-to column) > - (save-excursion (org-indent-line-to column))) > - (setq column (current-column)) > - (beginning-of-line 1) > - (if (looking-at > - "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\ > \)") > - (replace-match (concat "\\1" (format org-property-format > - (match-string 2) (match-string 3))) > - t nil)) > - (org-move-to-column column))) > + (unless (org-edit-src-find-region-and-lang) > + (let* ((pos (point)) > + (itemp (org-at-item-p)) > + column bpos bcol tpos tcol bullet btype bullet-type) > + ;; Find the previous relevant line > + (beginning-of-line 1) > + (cond > + ((looking-at "#") (setq column 0)) > + ((looking-at "\\*+ ") (setq column 0)) > + (t > + (beginning-of-line 0) > + (while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]")) > + (beginning-of-line 0)) > + (cond > + ((looking-at "\\*+[ \t]+") > + (if (not org-adapt-indentation) > + (setq column 0) > + (goto-char (match-end 0)) > + (setq column (current-column)))) > + ((org-in-item-p) > + (org-beginning-of-item) > + ; (looking-at "[ \t]*\\(\\S- > +\\)[ \t]*") > + (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\ > \|.*? :: \\)?") > + (setq bpos (match-beginning 1) tpos (match-end 0) > + bcol (progn (goto-char bpos) (current-column)) > + tcol (progn (goto-char tpos) (current-column)) > + bullet (match-string 1) > + bullet-type (if (string-match "[0-9]" bullet) "n" > bullet)) > + (if (> tcol (+ bcol org-description-max-indent)) > + (setq tcol (+ bcol 5))) > + (if (not itemp) > + (setq column tcol) > + (goto-char pos) > + (beginning-of-line 1) > + (if (looking-at "\\S-") > + (progn > + (looking-at "[ \t]*\\(\\S-+\\)[ \t]*") > + (setq bullet (match-string 1) > + btype (if (string-match "[0-9]" bullet) > "n" bullet)) > + (setq column (if (equal btype bullet-type) > bcol tcol))) > + (setq column (org-get-indentation))))) > + (t (setq column (org-get-indentation)))))) > + (goto-char pos) > + (if (<= (current-column) (current-indentation)) > + (org-indent-line-to column) > + (save-excursion (org-indent-line-to column))) > + (setq column (current-column)) > + (beginning-of-line 1) > + (if (looking-at > + "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\ > \|$\\)\\)") > + (replace-match (concat "\\1" (format org-property-format > + (match-string 2) > (match-string 3))) > + t nil)) > + (org-move-to-column column)))) > > (defun org-set-autofill-regexps () > (interactive) > -- > 1.5.6.5 > > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode