[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [RFC] Rewrite indentation functions
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [RFC] Rewrite indentation functions |
Date: |
Sun, 04 May 2014 21:45:15 +0200 |
Eric Abrahamsen <address@hidden> writes:
> Perhaps we need a new version of patch 3?
Here it is.
Regards,
--
Nicolas Goaziou
>From 66d0ab7d1025969e5fd383b93ffe1fb1b05a83a8 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
Date: Mon, 28 Apr 2014 18:38:31 +0200
Subject: [PATCH 3/3] Rewrite `org-indent-drawer' and `org-indent-block'
* lisp/org.el (org-indent-block, org-indent-drawer): Rewrite functions.
---
lisp/org.el | 75 ++++++++++++++++++++++++++++---------------------------------
1 file changed, 34 insertions(+), 41 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index af34d99..e8d6fa9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -22382,47 +22382,6 @@ Also align node properties according to
`org-property-format'."
(org--align-node-property)
(org-move-to-column column)))))))))
-(defun org-indent-drawer ()
- "Indent the drawer at point."
- (interactive)
- (let ((p (point))
- (e (and (save-excursion (re-search-forward ":END:" nil t))
- (match-end 0)))
- (folded
- (save-excursion
- (end-of-line)
- (when (overlays-at (point))
- (member 'invisible (overlay-properties
- (car (overlays-at (point)))))))))
- (when folded (org-cycle))
- (indent-for-tab-command)
- (while (and (move-beginning-of-line 2) (< (point) e))
- (indent-for-tab-command))
- (goto-char p)
- (when folded (org-cycle)))
- (message "Drawer at point indented"))
-
-(defun org-indent-block ()
- "Indent the block at point."
- (interactive)
- (let ((p (point))
- (case-fold-search t)
- (e (and (save-excursion (re-search-forward "#\\+end_?\\(?:[a-z]+\\)?"
nil t))
- (match-end 0)))
- (folded
- (save-excursion
- (end-of-line)
- (when (overlays-at (point))
- (member 'invisible (overlay-properties
- (car (overlays-at (point)))))))))
- (when folded (org-cycle))
- (indent-for-tab-command)
- (while (and (move-beginning-of-line 2) (< (point) e))
- (indent-for-tab-command))
- (goto-char p)
- (when folded (org-cycle)))
- (message "Block at point indented"))
-
(defun org-indent-region (start end)
"Indent each non-blank line in the region.
Called from a program, START and END specify the region to
@@ -22520,6 +22479,40 @@ assumed to be significant there."
(set-marker element-end nil))))
(set-marker end nil))))
+(defun org-indent-drawer ()
+ "Indent the drawer at point."
+ (interactive)
+ (unless (save-excursion
+ (beginning-of-line)
+ (org-looking-at-p org-drawer-regexp))
+ (user-error "Not at a drawer"))
+ (let ((element (org-element-at-point)))
+ (unless (memq (org-element-type element) '(drawer property-drawer))
+ (user-error "Not at a drawer"))
+ (org-with-wide-buffer
+ (org-indent-region (org-element-property :begin element)
+ (org-element-property :end element))))
+ (message "Drawer at point indented"))
+
+(defun org-indent-block ()
+ "Indent the block at point."
+ (interactive)
+ (unless (save-excursion
+ (beginning-of-line)
+ (let ((case-fold-search t))
+ (org-looking-at-p "[ \t]*#\\+\\(begin\\|end\\)_")))
+ (user-error "Not at a block"))
+ (let ((element (org-element-at-point)))
+ (unless (memq (org-element-type element)
+ '(comment-block center-block example-block export-block
+ quote-block special-block src-block
+ verse-block))
+ (user-error "Not at a block"))
+ (org-with-wide-buffer
+ (org-indent-region (org-element-property :begin element)
+ (org-element-property :end element))))
+ (message "Block at point indented"))
+
;;; Filling
--
1.9.2
- Re: [O] [RFC] Rewrite indentation functions, Nicolas Goaziou, 2014/05/01
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/02
- Re: [O] [RFC] Rewrite indentation functions, Nicolas Goaziou, 2014/05/02
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/02
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/03
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/03
- Re: [O] [RFC] Rewrite indentation functions, Nicolas Goaziou, 2014/05/03
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/03
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/03
- Re: [O] [RFC] Rewrite indentation functions,
Nicolas Goaziou <=
- Re: [O] [RFC] Rewrite indentation functions, Eric Abrahamsen, 2014/05/03
- Re: [O] [RFC] Rewrite indentation functions, Nicolas Goaziou, 2014/05/05
Re: [O] [RFC] Rewrite indentation functions, Bastien, 2014/05/06