Mercurial > emacs
changeset 111625:586a15d21905
* lisp/textmodes/rst.el: Minor cleanup to improve style.
(rst-get-decoration): Eliminate unneeded assignment.
(rst-update-section, rst-promote-region, rst-straighten-decorations)
(rst-section-tree, rst-adjust): Use point-marker.
(rst-toc-mode-mouse-goto): Avoid setq.
(rst-shift-region-guts, rst-shift-region-left)
(rst-iterate-leftmost-paragraphs, rst-iterate-leftmost-paragraphs-2)
(rst-convert-bullets-to-enumeration): Use copy-marker.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 17 Nov 2010 22:02:15 -0500 |
parents | 4ed7d6375e3b |
children | 3655cc4062e4 |
files | lisp/ChangeLog lisp/textmodes/rst.el |
diffstat | 2 files changed, 53 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Wed Nov 17 21:44:44 2010 -0500 +++ b/lisp/ChangeLog Wed Nov 17 22:02:15 2010 -0500 @@ -1,5 +1,15 @@ 2010-11-18 Stefan Monnier <monnier@iro.umontreal.ca> + Minor cleanup to improve style. + * textmodes/rst.el (rst-update-section): Use point-marker. + (rst-get-decoration): Eliminate unneeded assignment. + (rst-promote-region, rst-straighten-decorations) + (rst-section-tree, rst-adjust): Use point-marker. + (rst-toc-mode-mouse-goto): Avoid setq. + (rst-shift-region-guts, rst-shift-region-left) + (rst-iterate-leftmost-paragraphs, rst-iterate-leftmost-paragraphs-2) + (rst-convert-bullets-to-enumeration): Use copy-marker. + * minibuffer.el (completion-fail-discreetly): New var. (completion--do-completion): Use it.
--- a/lisp/textmodes/rst.el Wed Nov 17 21:44:44 2010 -0500 +++ b/lisp/textmodes/rst.el Wed Nov 17 22:02:15 2010 -0500 @@ -698,12 +698,10 @@ requested decoration." (interactive) - (let (marker + (end-of-line) + (let ((marker (point-marker)) len) - (end-of-line) - (setq marker (point-marker)) - ;; Fixup whitespace at the beginning and end of the line (if (or (null indent) (eq style 'simple)) (setq indent 0)) @@ -789,7 +787,7 @@ just finds all of them in a file. You can then invoke another function to remove redundancies and inconsistencies." - (let (positions + (let ((positions ()) (curline 1)) ;; Iterate over all the section titles/decorations in the file. (save-excursion @@ -870,7 +868,7 @@ A point can be specified to go to the given location before extracting the decoration." - (let (char style indent) + (let (char style) (save-excursion (if point (goto-char point)) (beginning-of-line) @@ -879,10 +877,10 @@ (forward-line -1) (rst-line-homogeneous-nodent-p))) - (under (save-excursion - (forward-line +1) - (rst-line-homogeneous-nodent-p))) - ) + (under (save-excursion + (forward-line +1) + (rst-line-homogeneous-nodent-p))) + ) ;; Check that the line above the overline is not part of a title ;; above it. @@ -910,15 +908,11 @@ ;; Both overline and underline. (t (setq char under - style 'over-and-under)) - ) - ) - ) - ;; Find indentation. - (setq indent (save-excursion (back-to-indentation) (current-column))) - ) - ;; Return values. - (list char style indent))) + style 'over-and-under))))) + ;; Return values. + (list char style + ;; Find indentation. + (save-excursion (back-to-indentation) (current-column)))))) (defun rst-get-decorations-around (&optional alldecos) @@ -1041,7 +1035,7 @@ (interactive) (let* (;; Save our original position on the current line. - (origpt (set-marker (make-marker) (point))) + (origpt (point-marker)) ;; Parse the positive and negative prefix arguments. (reverse-direction @@ -1395,32 +1389,28 @@ ;; Create a list of markers for all the decorations which are found within ;; the region. (save-excursion - (let (m line) + (let (line) (while (and cur (< (setq line (caar cur)) region-end-line)) - (setq m (make-marker)) (goto-char (point-min)) (forward-line (1- line)) - (push (list (set-marker m (point)) (cdar cur)) marker-list) + (push (list (point-marker) (cdar cur)) marker-list) (setq cur (cdr cur)) )) ;; Apply modifications. - (let (nextdeco) - (dolist (p marker-list) - ;; Go to the decoration to promote. - (goto-char (car p)) - - ;; Rotate the next decoration. - (setq nextdeco (rst-get-next-decoration - (cadr p) hier suggestion demote)) - - ;; Update the decoration. - (apply 'rst-update-section nextdeco) - - ;; Clear marker to avoid slowing down the editing after we're done. - (set-marker (car p) nil) - )) + (dolist (p marker-list) + ;; Go to the decoration to promote. + (goto-char (car p)) + + ;; Update the decoration. + (apply 'rst-update-section + ;; Rotate the next decoration. + (rst-get-next-decoration + (cadr p) hier suggestion demote)) + + ;; Clear marker to avoid slowing down the editing after we're done. + (set-marker (car p) nil)) (setq deactivate-mark nil) - ))) + ))) @@ -1463,11 +1453,10 @@ (levels-and-markers (mapcar (lambda (deco) (cons (rst-position (cdr deco) hier) - (let ((m (make-marker))) + (progn (goto-char (point-min)) (forward-line (1- (car deco))) - (set-marker m (point)) - m))) + (point-marker)))) alldecos)) ) (dolist (lm levels-and-markers) @@ -1511,7 +1500,7 @@ "Find all the positions of prefixes in region between BEG and END. This is used to find bullets and enumerated list items. PFX-RE is a regular expression for matching the lines with items." - (let (pfx) + (let ((pfx ())) (save-excursion (goto-char beg) (while (< (point) end) @@ -1635,10 +1624,9 @@ (forward-line (1- (car deco))) (list (gethash (cons (cadr deco) (caddr deco)) levels) (rst-get-stripped-line) - (let ((m (make-marker))) + (progn (beginning-of-line 1) - (set-marker m (point))) - )) + (point-marker)))) alldecos))) (let ((lcontnr (cons nil lines))) @@ -2057,11 +2045,11 @@ "In `rst-toc' mode, go to the occurrence whose line you click on. EVENT is the input event." (interactive "e") - (let (pos) + (let ((pos (with-current-buffer (window-buffer (posn-window (event-end event))) (save-excursion (goto-char (posn-point (event-end event))) - (setq pos (rst-toc-mode-find-section)))) + (rst-toc-mode-find-section))))) (pop-to-buffer (marker-buffer pos)) (goto-char pos) (recenter 5))) @@ -2306,8 +2294,8 @@ (defun rst-shift-region-guts (find-next-fun offset-fun) "(See `rst-shift-region-right' for a description)." - (let* ((mbeg (set-marker (make-marker) (region-beginning))) - (mend (set-marker (make-marker) (region-end))) + (let* ((mbeg (copy-marker (region-beginning))) + (mend (copy-marker (region-end))) (tabs (rst-compute-bullet-tabs mbeg)) (leftmostcol (rst-find-leftmost-column (region-beginning) (region-end))) ) @@ -2386,8 +2374,8 @@ indentation is removed, up to the leftmost character in the region, and automatic filling is disabled." (interactive "P") - (let ((mbeg (set-marker (make-marker) (region-beginning))) - (mend (set-marker (make-marker) (region-end))) + (let ((mbeg (copy-marker (region-beginning))) + (mend (copy-marker (region-end))) (leftmostcol (rst-find-leftmost-column (region-beginning) (region-end))) (rst-shift-fill-region @@ -2421,8 +2409,7 @@ of each paragraph only." `(save-excursion (let ((leftcol (rst-find-leftmost-column ,beg ,end)) - (endm (set-marker (make-marker) ,end)) - ) + (endm (copy-marker ,end))) (do* (;; Iterate lines (l (progn (goto-char ,beg) (back-to-indentation)) @@ -2460,8 +2447,7 @@ `(save-excursion (let ((,leftmost (rst-find-leftmost-column ,beg ,end)) - (endm (set-marker (make-marker) ,end)) - ) + (endm (copy-marker ,end))) (do* (;; Iterate lines (l (progn (goto-char ,beg) (back-to-indentation)) @@ -2538,9 +2524,7 @@ (let* (;; Find items and convert the positions to markers. (items (mapcar (lambda (x) - (cons (let ((m (make-marker))) - (set-marker m (car x)) - m) + (cons (copy-marker (car x)) (cdr x))) (rst-find-pfx-in-region beg end rst-re-items))) (count 1)