From: <bl...@us...> - 2008-04-19 14:11:19
|
Author: blais Date: 2008-04-19 16:10:59 +0200 (Sat, 19 Apr 2008) New Revision: 5542 Modified: trunk/docutils/tools/editors/emacs/rst.el Log: Updates from working version before moving into emacs. Modified: trunk/docutils/tools/editors/emacs/rst.el =================================================================== --- trunk/docutils/tools/editors/emacs/rst.el 2008-04-18 21:19:35 UTC (rev 5541) +++ trunk/docutils/tools/editors/emacs/rst.el 2008-04-19 14:10:59 UTC (rev 5542) @@ -256,6 +256,7 @@ (define-key map [(control c) (control h)] 'rst-display-decorations-hierarchy) ;; Homogeneize the decorations in the document. (define-key map [(control c) (control s)] 'rst-straighten-decorations) +;; (define-key map [(control c) (control s)] 'rst-straighten-deco-spacing) ;; ;; Section Movement and Selection. @@ -390,7 +391,7 @@ blocks." (set (make-local-variable 'paragraph-separate) paragraph-start) - (set (make-local-variable 'paragraph-start) + (set (make-local-variable 'paragraph-start) "\f\\|>*[ \t]*$\\|>*[ \t]*[-+*] \\|>*[ \t]*[0-9#]+\\. ") (set (make-local-variable 'adaptive-fill-mode) t) @@ -419,8 +420,8 @@ ;; jit-lock-mode replaced lazy-lock-mode in GNU Emacs 22 (let ((jit-or-lazy-lock-mode (cond + ((fboundp 'jit-lock-mode) 'jit-lock-mode) ((fboundp 'lazy-lock-mode) 'lazy-lock-mode) - ((fboundp 'jit-lock-mode) 'jit-lock-mode) ;; if neither lazy-lock nor jit-lock is supported, ;; tell user and disable rst-mode-lazy (t (when rst-mode-lazy @@ -841,7 +842,7 @@ (unless (assoc (cons char style) hierarchy-alist) (push (cons (cons char style) x) hierarchy-alist)) )) - + (mapcar 'cdr (nreverse hierarchy-alist)) )) @@ -1072,6 +1073,12 @@ (defvar rst-adjust-hook nil "Hooks to be run after running `rst-adjust'.") +(defvar rst-new-decoration-down nil + "If true, a new decoration being added will be initialized to + be one level down from the previous decoration. If nil, a new + decoration will be equal to the level of the previous + decoration.") + (defun rst-adjust-decoration (&optional toggle-style reverse-direction) "Adjust/rotate the section decoration for the section title around point. @@ -1282,7 +1289,8 @@ (setq cur (if prev (if (not reverse-direction) - (or (cadr (rst-get-decoration-match hier prev)) + (or (funcall (if rst-new-decoration-down 'cadr 'car) + (rst-get-decoration-match hier prev)) (rst-suggest-new-decoration hier prev)) prev) (copy-list (car rst-preferred-decorations)) @@ -1474,15 +1482,24 @@ ))) + + (defun rst-straighten-deco-spacing () - "Adjust the spacing before and after decorations in the entire current. -The spacing will be 'standard'." + "Adjust the spacing before and after decorations in the entire document. +The spacing will be set to two blank lines before the first two +section levels, and one blank line before any of the other +section levels." +;; FIXME: we need to take care of subtitle at some point. (interactive) (save-excursion (let* ((alldecos (rst-find-all-decorations))) - (dolist (deco alldecos) - ;; Go to the appropriate position - (prin1 deco) + + ;; Work the list from the end, so that we don't have to use markers to + ;; adjust for the changes in the document. + (dolist (deco (nreverse alldecos)) + ;; Go to the appropriate position. + (goto-line (car deco)) + (insert "@\n") ;; FIXME: todo, we ) ))) |