diff options
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/bibtex.el | 35 | ||||
-rw-r--r-- | lisp/textmodes/fill.el | 8 | ||||
-rw-r--r-- | lisp/textmodes/flyspell.el | 70 | ||||
-rw-r--r-- | lisp/textmodes/ispell.el | 63 | ||||
-rw-r--r-- | lisp/textmodes/page-ext.el | 5 | ||||
-rw-r--r-- | lisp/textmodes/picture.el | 35 | ||||
-rw-r--r-- | lisp/textmodes/reftex-cite.el | 50 | ||||
-rw-r--r-- | lisp/textmodes/reftex-index.el | 3 | ||||
-rw-r--r-- | lisp/textmodes/reftex-ref.el | 56 | ||||
-rw-r--r-- | lisp/textmodes/reftex-sel.el | 74 | ||||
-rw-r--r-- | lisp/textmodes/reftex-toc.el | 53 | ||||
-rw-r--r-- | lisp/textmodes/remember.el | 14 | ||||
-rw-r--r-- | lisp/textmodes/rst.el | 102 | ||||
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 1 | ||||
-rw-r--r-- | lisp/textmodes/table.el | 5 | ||||
-rw-r--r-- | lisp/textmodes/tex-mode.el | 1 | ||||
-rw-r--r-- | lisp/textmodes/texinfmt.el | 16 | ||||
-rw-r--r-- | lisp/textmodes/texinfo.el | 161 | ||||
-rw-r--r-- | lisp/textmodes/texnfo-upd.el | 64 |
19 files changed, 391 insertions, 425 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 0662acf2c50..75dd4f80153 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -1,7 +1,8 @@ ;;; bibtex.el --- BibTeX mode for GNU Emacs ;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, -;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Free Software Foundation, Inc. ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de> ;; Bengt Martensson <bengt@mathematik.uni-Bremen.de> @@ -3835,16 +3836,16 @@ Return t if test was successful, nil otherwise." (with-current-buffer (get-buffer-create err-buf) (setq default-directory dir) (unless (eq major-mode 'compilation-mode) (compilation-mode)) - (toggle-read-only -1) - (delete-region (point-min) (point-max)) - (insert "BibTeX mode command `bibtex-validate'\n" - (if syntax-error - "Maybe undetected errors due to syntax errors. Correct and validate again.\n" - "\n")) - (dolist (err error-list) - (insert (format "%s:%d: %s\n" file (car err) (cdr err)))) - (set-buffer-modified-p nil) - (toggle-read-only 1) + (let ((inhibit-read-only t)) + (delete-region (point-min) (point-max)) + (insert "BibTeX mode command `bibtex-validate'\n" + (if syntax-error + "Maybe undetected errors due to syntax errors. \ +Correct and validate again.\n" + "\n")) + (dolist (err error-list) + (insert (format "%s:%d: %s\n" file (car err) (cdr err)))) + (set-buffer-modified-p nil)) (goto-char (point-min)) (forward-line 2)) ; first error message (display-buffer err-buf) @@ -3896,12 +3897,11 @@ Return t if test was successful, nil otherwise." (let ((err-buf "*BibTeX validation errors*")) (with-current-buffer (get-buffer-create err-buf) (unless (eq major-mode 'compilation-mode) (compilation-mode)) - (toggle-read-only -1) - (delete-region (point-min) (point-max)) - (insert "BibTeX mode command `bibtex-validate-globally'\n\n") - (dolist (err (sort error-list 'string-lessp)) (insert err)) - (set-buffer-modified-p nil) - (toggle-read-only 1) + (let ((inhibit-read-only t)) + (delete-region (point-min) (point-max)) + (insert "BibTeX mode command `bibtex-validate-globally'\n\n") + (dolist (err (sort error-list 'string-lessp)) (insert err)) + (set-buffer-modified-p nil)) (goto-char (point-min)) (forward-line 2)) ; first error message (display-buffer err-buf) @@ -4778,5 +4778,4 @@ Return the URL or nil if none can be generated." (provide 'bibtex) -;; arch-tag: ee2be3af-caad-427f-b42a-d20fad630d04 ;;; bibtex.el ends here diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index be3fd5a1789..2dd7b1e2c95 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -1,7 +1,8 @@ ;;; fill.el --- fill commands for Emacs -*- coding: utf-8 -*- -;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1999, 2001, 2002, -;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1999, 2001, +;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: wp @@ -137,7 +138,7 @@ The fill column to use for a line is the first column at which the column number equals or exceeds the local fill-column - right-margin difference." (save-excursion (if fill-column - (let* ((here (progn (beginning-of-line) (point))) + (let* ((here (line-beginning-position)) (here-col 0) (eol (progn (end-of-line) (point))) margin fill-col change col) @@ -1517,5 +1518,4 @@ Also, if CITATION-REGEXP is non-nil, don't fill header lines." "") string)) -;; arch-tag: 727ad455-1161-4fa9-8df5-0f74b179216d ;;; fill.el ends here diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 8a73a0f818e..5dbcb2d7d77 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -380,7 +380,8 @@ like <img alt=\"Some thing.\">." (defun flyspell-generic-progmode-verify () "Used for `flyspell-generic-check-word-predicate' in programming modes." - (let ((f (get-text-property (point) 'face))) + ;; (point) is next char after the word. Must check one char before. + (let ((f (get-text-property (- (point) 1) 'face))) (memq f flyspell-prog-text-faces))) ;;;###autoload @@ -494,9 +495,9 @@ in your .emacs file. :keymap flyspell-mode-map :group 'flyspell (if flyspell-mode - (condition-case () + (condition-case err (flyspell-mode-on) - (error (message "Enabling Flyspell mode gave an error") + (error (message "Error enabling Flyspell mode:\n%s" (cdr err)) (flyspell-mode -1))) (flyspell-mode-off))) @@ -1013,11 +1014,13 @@ Mostly we check word delimiters." ;;*---------------------------------------------------------------------*/ ;;* flyspell-word ... */ ;;*---------------------------------------------------------------------*/ -(defun flyspell-word (&optional following) +(defun flyspell-word (&optional following known-misspelling) "Spell check a word. If the optional argument FOLLOWING, or, when called interactively `ispell-following-word', is non-nil, checks the following (rather -than preceding) word when the cursor is not over a word." +than preceding) word when the cursor is not over a word. If +optional argument KNOWN-MISSPELLING is non nil considers word a +misspelling and skips redundant spell-checking step." (interactive (list ispell-following-word)) (ispell-set-spellchecker-params) ; Initialize variables and dicts alists (save-excursion @@ -1078,29 +1081,35 @@ than preceding) word when the cursor is not over a word." (setq flyspell-word-cache-end end) (setq flyspell-word-cache-word word) ;; now check spelling of word. - (ispell-send-string "%\n") - ;; put in verbose mode - (ispell-send-string (concat "^" word "\n")) - ;; we mark the ispell process so it can be killed - ;; when emacs is exited without query - (set-process-query-on-exit-flag ispell-process nil) - ;; Wait until ispell has processed word. Since this code is often - ;; executed from post-command-hook but the ispell process may not - ;; be responsive, it's important to make sure we re-enable C-g. - (with-local-quit - (while (progn - (accept-process-output ispell-process) - (not (string= "" (car ispell-filter)))))) - ;; (ispell-send-string "!\n") - ;; back to terse mode. - ;; Remove leading empty element - (setq ispell-filter (cdr ispell-filter)) - ;; ispell process should return something after word is sent. - ;; Tag word as valid (i.e., skip) otherwise - (or ispell-filter - (setq ispell-filter '(*))) - (if (consp ispell-filter) - (setq poss (ispell-parse-output (car ispell-filter)))) + (if (not known-misspelling) + (progn + (ispell-send-string "%\n") + ;; put in verbose mode + (ispell-send-string (concat "^" word "\n")) + ;; we mark the ispell process so it can be killed + ;; when emacs is exited without query + (set-process-query-on-exit-flag ispell-process nil) + ;; Wait until ispell has processed word. Since this + ;; code is often executed from post-command-hook but + ;; the ispell process may not be responsive, it's + ;; important to make sure we re-enable C-g. + (with-local-quit + (while (progn + (accept-process-output ispell-process) + (not (string= "" (car ispell-filter)))))) + ;; (ispell-send-string "!\n") + ;; back to terse mode. + ;; Remove leading empty element + (setq ispell-filter (cdr ispell-filter)) + ;; ispell process should return something after word is sent. + ;; Tag word as valid (i.e., skip) otherwise + (or ispell-filter + (setq ispell-filter '(*))) + (if (consp ispell-filter) + (setq poss (ispell-parse-output (car ispell-filter))))) + ;; Else, this was a known misspelling to begin with, and + ;; we should forge an ispell return value. + (setq poss (list word 0 '() '()))) (let ((res (cond ((eq poss t) ;; correct (setq flyspell-word-cache-result t) @@ -1433,7 +1442,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'." t nil)))) (setq keep nil) - (flyspell-word) + (flyspell-word nil t) ;; Search for next misspelled word will begin from ;; end of last validated match. (setq buffer-scan-pos (point)))) @@ -1465,7 +1474,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'." (goto-char (point-min)) ;; Localwords parsing copied from ispell.el. (while (search-forward ispell-words-keyword nil t) - (let ((end (save-excursion (end-of-line) (point))) + (let ((end (point-at-eol)) string) ;; buffer-local words separated by a space, and can contain ;; any character other than a space. Not rigorous enough. @@ -2354,5 +2363,4 @@ This function is meant to be added to `flyspell-incorrect-hook'." (provide 'flyspell) -;; arch-tag: 05d915b9-e9cf-44fb-9137-fc28f5eaab2a ;;; flyspell.el ends here diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index c773aadd3d8..9a494897b74 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -1,7 +1,8 @@ ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2 ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, -;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Free Software Foundation, Inc. ;; Author: Ken Stevens <k.stevens@ieee.org> ;; Maintainer: Ken Stevens <k.stevens@ieee.org> @@ -983,19 +984,32 @@ Assumes that value contains no whitespace." (car (split-string (buffer-string))))) (defun ispell-aspell-find-dictionary (dict-name) - ;; This returns nil if the data file does not exist. - ;; Can someone please explain the return value format when the - ;; file does exist -- rms? - (let* ((lang ;; Strip out variant, etc. - (and (string-match "^[[:alpha:]_]+" dict-name) - (match-string 0 dict-name))) + "For aspell dictionary DICT-NAME, return a list of parameters if an + associated data file is found or nil otherwise. List format is + that of `ispell-dictionary-base-alist' elements." + ;; Make sure `ispell-aspell-data-dir' is defined + (or ispell-aspell-data-dir + (setq ispell-aspell-data-dir + (ispell-get-aspell-config-value "data-dir"))) + ;; Try finding associated datafile + (let* ((datafile1 + (concat ispell-aspell-data-dir "/" + ;; Strip out variant, country code, etc. + (and (string-match "^[[:alpha:]]+" dict-name) + (match-string 0 dict-name)) ".dat")) + (datafile2 + (concat ispell-aspell-data-dir "/" + ;; Strip out anything but xx_YY. + (and (string-match "^[[:alpha:]_]+" dict-name) + (match-string 0 dict-name)) ".dat")) (data-file - (concat (or ispell-aspell-data-dir - (setq ispell-aspell-data-dir - (ispell-get-aspell-config-value "data-dir"))) - "/" lang ".dat")) + (if (file-readable-p datafile1) + datafile1 + (if (file-readable-p datafile2) + datafile2))) otherchars) - (condition-case () + + (if data-file (with-temp-buffer (insert-file-contents data-file) ;; There is zero or one line with special characters declarations. @@ -1023,9 +1037,7 @@ Assumes that value contains no whitespace." ;; Here we specify the encoding to use while communicating with ;; aspell. This doesn't apply to command line arguments, so ;; just don't pass words to spellcheck as arguments... - 'utf-8)) - (file-error - nil)))) + 'utf-8))))) (defun ispell-aspell-add-aliases (alist) "Find aspell's dictionary aliases and add them to dictionary ALIST. @@ -2728,9 +2740,11 @@ Keeps argument list for future ispell invocations for no async support." (if extended-char-mode ; ~ extended character mode (ispell-send-string (concat extended-char-mode "\n")))) (if ispell-async-processp - (if (fboundp 'set-process-query-on-exit-flag) ;; not XEmacs + (if (featurep 'emacs) (set-process-query-on-exit-flag ispell-process nil) - (process-kill-without-query ispell-process)))))) + (if (fboundp 'set-process-query-on-exit-flag) + (set-process-query-on-exit-flag ispell-process nil) + (process-kill-without-query ispell-process))))))) ;;;###autoload (defun ispell-kill-ispell (&optional no-error) @@ -2898,8 +2912,7 @@ Return nil if spell session is quit, (min skip-region-start ispell-region-end) (marker-position ispell-region-end)))) (let* ((ispell-start (point)) - (ispell-end (save-excursion - (end-of-line) (min (point) reg-end))) + (ispell-end (min (point-at-eol) reg-end)) (string (ispell-get-line ispell-start ispell-end in-comment))) (if in-comment ; account for comment chars added @@ -3801,7 +3814,7 @@ Includes Latex/Nroff modes and extended character mode." (goto-char (point-max)) ;; Uses last occurrence of ispell-parsing-keyword (if (search-backward ispell-parsing-keyword nil t) - (let ((end (save-excursion (end-of-line) (point))) + (let ((end (point-at-eol)) string) (search-forward ispell-parsing-keyword) (while (re-search-forward " *\\([^ \"]+\\)" end t) @@ -3837,7 +3850,7 @@ Both should not be used to define a buffer-local dictionary." (if (search-backward ispell-dictionary-keyword nil t) (progn (search-forward ispell-dictionary-keyword) - (setq end (save-excursion (end-of-line) (point))) + (setq end (point-at-eol)) (if (re-search-forward " *\\([^ \"]+\\)" end t) (setq ispell-local-dictionary (match-string-no-properties 1)))))) @@ -3845,7 +3858,7 @@ Both should not be used to define a buffer-local dictionary." (if (search-backward ispell-pdict-keyword nil t) (progn (search-forward ispell-pdict-keyword) - (setq end (save-excursion (end-of-line) (point))) + (setq end (point-at-eol)) (if (re-search-forward " *\\([^ \"]+\\)" end t) (setq ispell-local-pdict (match-string-no-properties 1))))))) @@ -3869,7 +3882,7 @@ Both should not be used to define a buffer-local dictionary." (while (search-forward ispell-words-keyword nil t) (or ispell-buffer-local-name (setq ispell-buffer-local-name (buffer-name))) - (let ((end (save-excursion (end-of-line) (point))) + (let ((end (point-at-eol)) (ispell-casechars (ispell-get-casechars)) string) ;; buffer-local words separated by a space, and can contain @@ -3885,6 +3898,9 @@ Both should not be used to define a buffer-local dictionary." ;;; returns optionally adjusted region-end-point. +;; If comment-padright is defined, newcomment must be loaded. +(declare-function comment-add "newcomment" (arg)) + (defun ispell-add-per-file-word-list (word) "Add WORD to the per-file word list." (or ispell-buffer-local-name @@ -3959,5 +3975,4 @@ Both should not be used to define a buffer-local dictionary." ; LocalWords: uuencoded unidiff sc nn VM SGML eval IspellPersDict unsplitable ; LocalWords: lns XEmacs HTML casechars Multibyte -;; arch-tag: 4941b9f9-3b7c-4a76-a4ed-5fa8b6010ef5 ;;; ispell.el ends here diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el index 05065cd4427..548223e4f2c 100644 --- a/lisp/textmodes/page-ext.el +++ b/lisp/textmodes/page-ext.el @@ -671,7 +671,7 @@ Used by `pages-directory' function." (setq position (make-marker)) (set-marker position (point)) (let ((start (point)) - (end (save-excursion (end-of-line) (point))) + (end (line-end-position)) inserted-at) ;; change to directory buffer (set-buffer standard-output) @@ -783,7 +783,7 @@ directory." (delete-other-windows)) (save-excursion (goto-char (point-min)) - (delete-region (point) (save-excursion (end-of-line) (point))) + (delete-region (point) (line-end-position)) (insert "=== Address List Directory: use `C-c C-c' to go to page under cursor. ===") (set-buffer-modified-p nil) @@ -801,5 +801,4 @@ to the same line in the pages buffer." (provide 'page-ext) -;; arch-tag: 2f311550-c6e0-4458-9c12-7f039c058bdb ;;; page-ext.el ends here diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el index 89e1020db98..98add4cfd28 100644 --- a/lisp/textmodes/picture.el +++ b/lisp/textmodes/picture.el @@ -226,16 +226,30 @@ Do \\[command-apropos] picture-movement to see commands which control motion." (picture-motion (- arg))) (defun picture-mouse-set-point (event) - "Move point to the position clicked on, making whitespace if necessary." + "Move point to the position of EVENT, making whitespace if necessary." (interactive "e") - (let* ((pos (posn-col-row (event-start event))) - (x (car pos)) - (y (cdr pos)) - (current-row (count-lines (window-start) (line-beginning-position)))) - (unless (equal x (current-column)) - (picture-forward-column (- x (current-column)))) - (unless (equal y current-row) - (picture-move-down (- y current-row))))) + (let ((position (event-start event))) + (unless (posn-area position) ; Ignore EVENT unless in text area + (let* ((window (posn-window position)) + (frame (if (framep window) window (window-frame window))) + (pair (posn-x-y position)) + (start-pos (window-start window)) + (start-pair (posn-x-y (posn-at-point start-pos))) + (dx (- (car pair) (car start-pair))) + (dy (- (cdr pair) (cdr start-pair))) + (char-ht (frame-char-height frame)) + (spacing (when (display-graphic-p frame) + (or (with-current-buffer (window-buffer window) + line-spacing) + (frame-parameter frame 'line-spacing)))) + rows cols) + (cond ((floatp spacing) + (setq spacing (truncate (* spacing char-ht)))) + ((null spacing) + (setq spacing 0))) + (goto-char start-pos) + (picture-move-down (/ dy (+ char-ht spacing))) + (picture-forward-column (/ dx (frame-char-width frame))))))) ;; Picture insertion and deletion. @@ -438,7 +452,7 @@ If no such character is found, move to beginning of line." (move-to-column target)) (if (re-search-forward (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]") - (save-excursion (end-of-line) (point)) + (line-end-position) 'move) (setq target (1- (current-column))) (setq target nil))) @@ -775,5 +789,4 @@ Runs `picture-mode-exit-hook' at the end." (provide 'picture) -;; arch-tag: e452d08d-a470-4fbf-896e-ea276698d1ca ;;; picture.el ends here diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index 79797b4791b..2c8a14a3808 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el @@ -358,27 +358,30 @@ (message "Scanning thebibliography environment in %s" file) (with-current-buffer buf - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward - "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t) - (beginning-of-line 2) - (setq start (point)) - (if (re-search-forward - "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t) - (progn - (beginning-of-line 1) - (setq end (point)))) - (when (and start end) - (setq entries - (append entries - (mapcar 'reftex-parse-bibitem - (delete "" - (split-string - (buffer-substring-no-properties start end) - "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))) - (goto-char end))))) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (while (re-search-forward + "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t) + (beginning-of-line 2) + (setq start (point)) + (if (re-search-forward + "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t) + (progn + (beginning-of-line 1) + (setq end (point)))) + (when (and start end) + (setq entries + (append entries + (mapcar 'reftex-parse-bibitem + (delete "" + (split-string + (buffer-substring-no-properties + start end) + "[ \t\n\r]*\\\\bibitem[ \t]*\ +\\(\\[[^]]*]\\)*\[ \t]*")))))) + (goto-char end)))))) (unless entries (error "No bibitems found")) @@ -1144,9 +1147,8 @@ The sequence in the new file is the same as it was in the old database." (save-restriction (widen) (goto-char (point-min)) - (while (re-search-forward - "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\)," - nil t) + (while (re-search-forward "^[ \t]*@\\(?:\\w\\|\\s_\\)+[ \t\n\r]*\ +\[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t) (setq key (match-string 1) beg (match-beginning 0) end (progn diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el index dee7a319260..2da5897827d 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el @@ -1699,7 +1699,7 @@ it first compares the macro identifying chars and then the phrases." (let* ((lines (split-string (buffer-substring beg end) "\n")) (lines1 (sort lines 'reftex-compare-phrase-lines))) (message "Sorting lines...done") - (let ((inhibit-quit t)) ;; make sure we do not loose lines + (let ((inhibit-quit t)) ;; make sure we do not lose lines (delete-region beg end) (insert (mapconcat 'identity lines1 "\n")))) (goto-char (point-max)) @@ -2104,5 +2104,4 @@ Does not do a save-excursion." ["Save and Return" reftex-index-phrases-save-and-return t])) -;; arch-tag: 4b2362af-c156-42c1-8932-ea2823e205c1 ;;; reftex-index.el ends here diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index 23723489d13..91cc77480eb 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -180,8 +180,8 @@ This function is controlled by the settings of reftex-insert-label-flags." (string-match "^[ \t]*$" default)) (setq default prefix force-prompt t) ; need to prompt - (setq default - (concat prefix + (setq default + (concat prefix (funcall reftex-string-to-label-function default))) ;; Make it unique. @@ -227,7 +227,7 @@ This function is controlled by the settings of reftex-insert-label-flags." ((setq entry (assoc label (symbol-value reftex-docstruct-symbol))) (ding) - (if (y-or-n-p + (if (y-or-n-p (format "Label '%s' exists. Use anyway? " label)) (setq valid t))) @@ -237,9 +237,9 @@ This function is controlled by the settings of reftex-insert-label-flags." (setq label default)) ;; Insert the label into the label list - (let* ((here-I-am-info + (let* ((here-I-am-info (save-excursion - (if (and (or naked no-insert) + (if (and (or naked no-insert) (integerp (cdr macro-cell))) (goto-char (cdr macro-cell))) (reftex-where-am-I))) @@ -294,7 +294,7 @@ also applies `reftex-translate-to-ascii-function' to the string." ;; Translate the upper 128 chars in the Latin-1 charset to ASCII equivalents (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy") (emacsp (not (featurep 'xemacs)))) - (mapconcat + (mapconcat (lambda (c) (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1 (char-to-string (aref tab (- c 128)))) @@ -430,7 +430,7 @@ When called with 2 C-u prefix args, disable magic word recognition." type (car type)) (setq type (reftex-query-label-type)))) - (let* ((refstyle + (let* ((reftex-refstyle (cond ((reftex-typekey-check type reftex-vref-is-default) "\\vref") ((reftex-typekey-check type reftex-fref-is-default) "\\fref") (t "\\ref"))) @@ -452,7 +452,7 @@ When called with 2 C-u prefix args, disable magic word recognition." (setq type (nth 1 (car labels)) form (or (cdr (assoc type reftex-typekey-to-format-alist)) form)) - + (cond (no-insert ;; Just return the first label @@ -466,7 +466,7 @@ When called with 2 C-u prefix args, disable magic word recognition." sep (nth 2 (car labels)) sep1 (cdr (assoc sep reftex-multiref-punctuation)) labels (cdr labels)) - (when cut + (when cut (backward-delete-char cut) (setq cut nil)) @@ -477,9 +477,9 @@ When called with 2 C-u prefix args, disable magic word recognition." ;; do we have a special format? (setq reftex-format-ref-function (cond - ((string= refstyle "\\vref") 'reftex-format-vref) - ((string= refstyle "\\fref") 'reftex-format-fref) - ((string= refstyle "\\Fref") 'reftex-format-Fref) + ((string= reftex-refstyle "\\vref") 'reftex-format-vref) + ((string= reftex-refstyle "\\fref") 'reftex-format-fref) + ((string= reftex-refstyle "\\Fref") 'reftex-format-Fref) (t reftex-format-ref-function))) ;; ok, insert the reference (if sep1 (insert sep1)) @@ -501,7 +501,7 @@ When called with 2 C-u prefix args, disable magic word recognition." matched cell) (save-excursion (while (and (setq cell (pop words)) - (not (setq matched + (not (setq matched (re-search-backward (car cell) bound t)))))) (if matched (cons (cdr cell) (- (match-end 0) (match-end 1))) @@ -549,7 +549,7 @@ When called with 2 C-u prefix args, disable magic word recognition." (setq mode-line-format (list "---- " 'mode-line-buffer-identification " " 'global-mode-string " (" mode-name ")" - " S<" 'refstyle ">" + " S<" 'reftex-refstyle ">" " -%-")) (cond ((= 0 (buffer-size)) @@ -564,9 +564,9 @@ When called with 2 C-u prefix args, disable magic word recognition." context counter commented - (or here-I-am offset) + (or here-I-am offset) prefix - nil ; no a toc buffer + nil ; no a toc buffer )))) (here-I-am (setq offset (reftex-get-offset buf here-I-am typekey))) @@ -690,13 +690,13 @@ When called with 2 C-u prefix args, disable magic word recognition." (defun reftex-query-label-type () ;; Ask for label type - (let ((key (reftex-select-with-char + (let ((key (reftex-select-with-char reftex-type-query-prompt reftex-type-query-help 3))) (unless (member (char-to-string key) reftex-typekey-list) (error "No such label type: %s" (char-to-string key))) (char-to-string key))) -(defun reftex-show-label-location (data forward no-revisit +(defun reftex-show-label-location (data forward no-revisit &optional stay error) ;; View the definition site of a label in another window. ;; DATA is an entry from the docstruct list. @@ -718,7 +718,7 @@ When called with 2 C-u prefix args, disable magic word recognition." (throw 'exit nil)) ;; Goto the file in another window - (setq buffer + (setq buffer (if no-revisit (reftex-get-buffer-visiting file) (reftex-get-file-buffer-force @@ -784,7 +784,7 @@ When called with 2 C-u prefix args, disable magic word recognition." (when (or (not (eq major-mode 'latex-mode)) (not font-lock-mode)) (latex-mode) - (run-hook-with-args + (run-hook-with-args 'reftex-pre-refontification-functions reftex-call-back-to-this-buffer 'reftex-hidden) (turn-on-font-lock)) @@ -830,8 +830,16 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window." (reftex-access-scan-info) (let* ((wcfg (current-window-configuration)) (docstruct (symbol-value reftex-docstruct-symbol)) - (label (completing-read "Label: " docstruct - (lambda (x) (stringp (car x))) t)) + ;; If point is inside a \ref{} or \pageref{}, use that as + ;; default value. + (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*") + (reftex-this-word "-a-zA-Z0-9_*.:"))) + (label (completing-read (if default + (format "Label (default %s): " default) + "Label: ") + docstruct + (lambda (x) (stringp (car x))) t nil nil + default)) (selection (assoc label docstruct)) (where (progn (reftex-show-label-location selection t nil 'stay) @@ -839,10 +847,8 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window." (unless other-window (set-window-configuration wcfg) (switch-to-buffer (marker-buffer where)) - (goto-char where)) + (goto-char where)) (reftex-unhighlight 0))) - -;; arch-tag: 52f14032-fb76-4d31-954f-750c72415675 ;;; reftex-ref.el ends here diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el index bebeb1cd51a..bb6531d7980 100644 --- a/lisp/textmodes/reftex-sel.el +++ b/lisp/textmodes/reftex-sel.el @@ -369,22 +369,21 @@ During a selection process, these are the local bindings. (defvar reftex-last-line nil) (defvar reftex-select-marked nil) -(defun reftex-select-item (prompt help-string keymap +(defun reftex-select-item (reftex-select-prompt help-string keymap &optional offset call-back cb-flag) -;; Select an item, using PROMPT. The function returns a key indicating -;; an exit status, along with a data structure indicating which item was -;; selected. -;; HELP-STRING contains help. KEYMAP is a keymap with the available -;; selection commands. -;; OFFSET can be a label list item which will be selected at start. -;; When it is t, point will start out at the beginning of the buffer. -;; Any other value will cause restart where last selection left off. -;; When CALL-BACK is given, it is a function which is called with the index -;; of the element. -;; CB-FLAG is the initial value of that flag. - - (let* (ev data last-data (selection-buffer (current-buffer))) + ;; Select an item, using REFTEX-SELECT-PROMPT. + ;; The function returns a key indicating an exit status, along with a + ;; data structure indicating which item was selected. + ;; HELP-STRING contains help. KEYMAP is a keymap with the available + ;; selection commands. + ;; OFFSET can be a label list item which will be selected at start. + ;; When it is t, point will start out at the beginning of the buffer. + ;; Any other value will cause restart where last selection left off. + ;; When CALL-BACK is given, it is a function which is called with the index + ;; of the element. + ;; CB-FLAG is the initial value of that flag. + (let (ev reftex-select-data last-data (selection-buffer (current-buffer))) (setq reftex-select-marked nil) @@ -404,7 +403,7 @@ During a selection process, these are the local bindings. (use-local-map keymap) (add-hook 'pre-command-hook 'reftex-select-pre-command-hook nil t) (add-hook 'post-command-hook 'reftex-select-post-command-hook nil t) - (princ prompt) + (princ reftex-select-prompt) (set-marker reftex-recursive-edit-marker (point)) ;; XEmacs does not run post-command-hook here (and (featurep 'xemacs) (run-hooks 'post-command-hook)) @@ -426,19 +425,18 @@ During a selection process, these are the local bindings. (reftex-kill-buffer "*RefTeX Help*") (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-))) (message "") - (list ev data last-data))) + (list ev reftex-select-data last-data))) ;; The following variables are all bound dynamically in `reftex-select-item'. ;; The defvars are here only to silence the byte compiler. (defvar found-list) (defvar cb-flag) -(defvar data) -(defvar prompt) +(defvar reftex-select-data) +(defvar reftex-select-prompt) (defvar last-data) (defvar call-back) (defvar help-string) -(defvar refstyle) ;; The selection commands @@ -448,15 +446,15 @@ During a selection process, these are the local bindings. (defun reftex-select-post-command-hook () (let (b e) - (setq data (get-text-property (point) :data)) - (setq last-data (or data last-data)) + (setq reftex-select-data (get-text-property (point) :data)) + (setq last-data (or reftex-select-data last-data)) - (when (and data cb-flag + (when (and reftex-select-data cb-flag (not (equal reftex-last-follow-point (point)))) (setq reftex-last-follow-point (point)) - (funcall call-back data reftex-callback-fwd + (funcall call-back reftex-select-data reftex-callback-fwd (not reftex-revisit-to-follow))) - (if data + (if reftex-select-data (setq b (or (previous-single-property-change (1+ (point)) :data) (point-min)) @@ -470,7 +468,7 @@ During a selection process, these are the local bindings. (not (pos-visible-in-window-p e))) (recenter '(4))) (unless (current-message) - (princ prompt)))) + (princ reftex-select-prompt)))) (defun reftex-select-next (&optional arg) "Move to next selectable item." @@ -531,19 +529,22 @@ Useful for large TOC's." (interactive) (setq reftex-last-follow-point -1) (setq cb-flag (not cb-flag))) + +(defvar reftex-refstyle) ; from reftex-reference + (defun reftex-select-toggle-varioref () "Toggle the macro used for referencing the label between \\ref and \\vref." (interactive) - (if (string= refstyle "\\ref") - (setq refstyle "\\vref") - (setq refstyle "\\ref")) + (if (string= reftex-refstyle "\\ref") + (setq reftex-refstyle "\\vref") + (setq reftex-refstyle "\\ref")) (force-mode-line-update)) (defun reftex-select-toggle-fancyref () "Toggle the macro used for referencing the label between \\ref and \\vref." (interactive) - (setq refstyle - (cond ((string= refstyle "\\ref") "\\fref") - ((string= refstyle "\\fref") "\\Fref") + (setq reftex-refstyle + (cond ((string= reftex-refstyle "\\ref") "\\fref") + ((string= reftex-refstyle "\\fref") "\\Fref") (t "\\ref"))) (force-mode-line-update)) (defun reftex-select-show-insertion-point () @@ -560,7 +561,7 @@ Useful for large TOC's." (defun reftex-select-callback () "Show full context in another window." (interactive) - (if data (funcall call-back data reftex-callback-fwd nil) (ding))) + (if reftex-select-data (funcall call-back reftex-select-data reftex-callback-fwd nil) (ding))) (defun reftex-select-accept () "Accept the currently selected item." (interactive) @@ -569,8 +570,8 @@ Useful for large TOC's." "Accept the item at the mouse click." (interactive "e") (mouse-set-point ev) - (setq data (get-text-property (point) :data)) - (setq last-data (or data last-data)) + (setq reftex-select-data (get-text-property (point) :data)) + (setq last-data (or reftex-select-data last-data)) (throw 'myexit 'return)) (defun reftex-select-read-label () "Use minibuffer to read a label to reference, with completion." @@ -588,8 +589,8 @@ Useful for large TOC's." (cond ((or (null key) (equal key ""))) (entry - (setq data entry) - (setq last-data data) + (setq reftex-select-data entry) + (setq last-data reftex-select-data) (throw 'myexit 'return)) (t (throw 'myexit key))))) @@ -736,5 +737,4 @@ Useful for large TOC's." do (define-key reftex-select-bib-map (car x) (cdr x))) -;; arch-tag: 842078ff-0586-4e0b-957e-536e08218464 ;;; reftex-sel.el ends here diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 41ea83b077f..20903706a0e 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el @@ -545,8 +545,6 @@ Useful for large TOC's." ;; Promotion/Demotion stuff -(defvar delta) -(defvar mpos) (defvar pro-or-de) (defvar start-pos) (defvar start-line) @@ -575,7 +573,7 @@ point." (if (bolp) 1 0))))) (start-pos (point)) (pro-or-de (if (> delta 0) "de" "pro")) - beg end entries data sections nsec mpos msg) + beg end entries data sections nsec msg) (setq msg (catch 'exit (if (reftex-region-active-p) @@ -602,7 +600,9 @@ point." (reftex-toc-extract-section-number (nth (1- nsec) entries))))) ;; Run through the list and prepare the changes. - (setq entries (mapcar 'reftex-toc-promote-prepare entries)) + (setq entries (mapcar + (lambda (e) (reftex-toc-promote-prepare e delta)) + entries)) ;; Ask for permission (if (or (not reftex-toc-confirm-promotion) ; never confirm (and (integerp reftex-toc-confirm-promotion) ; confirm if many @@ -629,31 +629,26 @@ point." (defun reftex-toc-restore-region (point-line &optional mark-line) - (when mark-line - (goto-char (point-min)) - (forward-line (1- mark-line)) - (setq mpos (point))) - (when point-line - (goto-char (point-min)) - (forward-line (1- point-line))) - (if mark-line - (progn - (set-mark mpos) - (if (featurep 'xemacs) - (zmacs-activate-region) - (setq mark-active t - deactivate-mark nil))))) - -(defvar name1) -(defvar dummy) -(defvar dummy2) - -(defun reftex-toc-promote-prepare (x) + (let (mpos) + (when mark-line + (goto-char (point-min)) + (forward-line (1- mark-line)) + (setq mpos (point))) + (when point-line + (goto-char (point-min)) + (forward-line (1- point-line))) + (when mark-line + (set-mark mpos) + (if (featurep 'xemacs) + (zmacs-activate-region) + (setq mark-active t + deactivate-mark nil))))) + +(defun reftex-toc-promote-prepare (x delta) "Look at a toc entry and see if we could pro/demote it. -Expects the level change DELTA to be dynamically scoped into this function. This function prepares everything for the changes, but does not do it. The return value is a list with information needed when doing the -promotion/demotion later." +promotion/demotion later. DELTA is the level change." (let* ((data (car x)) (toc-point (cdr x)) (marker (nth 4 data)) @@ -678,7 +673,7 @@ promotion/demotion later." (error "Something is wrong! Contact maintainer!"))) ;; Section has changed, request scan and loading ;; We use a variable to delay until after the safe-exc. - ;; because otherwise we loose the region. + ;; because otherwise we lose the region. (setq load t))) ;; Scan document and load all files, this exits command (if load (reftex-toc-load-all-files-for-promotion))) ; exits @@ -689,7 +684,6 @@ promotion/demotion later." (progn (goto-char toc-point) (error "Cannot %smote special sections" pro-or-de)))) - ;; Delta is dynamically scoped into here... (newlevel (if (>= level 0) (+ delta level) (- level delta))) (dummy2 (if (or (and (>= level 0) (= newlevel -1)) (and (< level 0) (= newlevel 0))) @@ -703,7 +697,7 @@ promotion/demotion later." (defun reftex-toc-promote-action (x) "Change the level of a toc entry. -DELTA and PRO-OR-DE are assumed to be dynamically scoped into this function." +PRO-OR-DE is assumed to be dynamically scoped into this function." (let* ((data (car x)) (name (nth 1 x)) (newname (nth 2 x)) @@ -1100,5 +1094,4 @@ always show the current section in connection with the option ["Help" reftex-toc-show-help t])) -;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e ;;; reftex-toc.el ends here diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el index d4de4e49b93..ab2c27563b0 100644 --- a/lisp/textmodes/remember.el +++ b/lisp/textmodes/remember.el @@ -1,7 +1,7 @@ ;;; remember --- a mode for quickly jotting down things to remember -;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, -;; 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, +;; 2009, 2010 Free Software Foundation, Inc. ;; Author: John Wiegley <johnw@gnu.org> ;; Created: 29 Mar 1999 @@ -315,12 +315,6 @@ With a prefix or a visible region, use the region as INITIAL." (let ((remember-in-new-frame t)) (remember initial))) -(defsubst remember-time-to-seconds (time) - "Convert TIME to a floating point number." - (+ (* (car time) 65536.0) - (cadr time) - (/ (or (car (cdr (cdr time))) 0) 1000000.0))) - (defsubst remember-mail-date (&optional rfc822-p) "Return a simple date. Nothing fancy." (if rfc822-p @@ -355,8 +349,7 @@ In which case `remember-mailbox' should be the name of the mailbox. Each piece of pseudo-mail created will have an `X-Todo-Priority' field, for the purpose of appropriate splitting." (let ((who (read-string "Who is this item related to? ")) - (moment - (format "%.0f" (remember-time-to-seconds (current-time)))) + (moment (format "%.0f" (float-time))) (desc (remember-buffer-desc)) (text (buffer-string))) (with-temp-buffer @@ -535,5 +528,4 @@ the data away for latter retrieval, and possible indexing. \\{remember-mode-map}" (set-keymap-parent remember-mode-map nil)) -;; arch-tag: 59312a05-06c7-4da1-b6f7-5ea41c9d5577 ;;; remember.el ends here diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index afc4dd892c9..5bf1a7c7894 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el @@ -698,11 +698,9 @@ existing decoration, they are removed before adding the requested decoration." (interactive) - (let (marker - len) - (end-of-line) - (setq marker (point-marker)) + (let ((marker (point-marker)) + len) ;; Fixup whitespace at the beginning and end of the line (if (or (null indent) (eq style 'simple)) @@ -789,7 +787,7 @@ This function does not detect the hierarchy of decorations, it 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 decoration can be said to exist if the style is not nil. 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 @@ extracting the decoration." (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 @@ extracting the decoration." ;; 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 @@ b. a negative numerical argument, which generally inverts the (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 @@ hierarchy is similar to that used by `rst-adjust-decoration'." ;; 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 @@ in order to adapt it to our preferred style." (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 @@ section levels." "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 @@ child. This has advantages later in processing the graph." (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 @@ brings the cursor in that section." "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 @@ of (COLUMN-NUMBER . LINE) pairs." (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 @@ Also, if invoked with a negative prefix arg, the entire 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 @@ Set FIRST-ONLY to true if you want to callback on the first line 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 @@ first of a paragraph." `(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 @@ region to enumerated lists, renumbering as necessary." (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) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index bc1af67d587..47d2f7a45e0 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -100,6 +100,7 @@ This takes effect when first loading the `sgml-mode' library.") (define-key map "\C-c\C-d" 'sgml-delete-tag) (define-key map "\C-c\^?" 'sgml-delete-tag) (define-key map "\C-c?" 'sgml-tag-help) + (define-key map "\C-c]" 'sgml-close-tag) (define-key map "\C-c/" 'sgml-close-tag) ;; Redundant keybindings, for consistency with TeX mode. diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 136c5dc466c..eb2d4849a32 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -5057,7 +5057,7 @@ Focus only on the corner pattern. Further cell validity check is required." (intersection-str (regexp-quote (char-to-string table-cell-intersection-char))) (v-border (format "[%c%c]" table-cell-vertical-char table-cell-intersection-char)) (h-border (format "[%s%c]" table-cell-horizontal-chars table-cell-intersection-char)) - (limit (save-excursion (beginning-of-line) (point)))) + (limit (line-beginning-position))) (catch 'end (while t (catch 'retry-horizontal @@ -5095,7 +5095,7 @@ Focus only on the corner pattern. Further cell validity check is required." (intersection-str (regexp-quote (char-to-string table-cell-intersection-char))) (v-border (format "[%c%c]" table-cell-vertical-char table-cell-intersection-char)) (h-border (format "[%s%c]" table-cell-horizontal-chars table-cell-intersection-char)) - (limit (save-excursion (end-of-line) (point)))) + (limit (line-end-position))) (catch 'end (while t (catch 'retry-horizontal @@ -5589,5 +5589,4 @@ It returns COLUMN unless STR contains some wide characters." (provide 'table) -;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0 ;;; table.el ends here diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 70e4d1e3953..08f8257407e 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -864,6 +864,7 @@ START is the position of the \\ and DELIM is the delimiter char." ;; Redundant keybindings, for consistency with SGML mode. (define-key map "\C-c\C-t" 'latex-insert-block) + (define-key map "\C-c]" 'latex-close-block) (define-key map "\C-c/" 'latex-close-block) (define-key map "\C-c\C-e" 'latex-close-block) diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el index 577287c60bc..7c331c7809d 100644 --- a/lisp/textmodes/texinfmt.el +++ b/lisp/textmodes/texinfmt.el @@ -663,11 +663,12 @@ Do not append @refill to paragraphs containing @w{TEXT} or @*." ;; Else ;; 3. Do not refill a paragraph containing @w or @*, or ending ;; with @<newline> followed by a newline. - (if (or (>= (point) (point-max)) - (re-search-forward - "@w{\\|@\\*\\|@\n\n" - (save-excursion (forward-paragraph) (forward-line 1) (point)) - t)) + (if (or (>= (point) (point-max)) + (re-search-forward + "@w{\\|@\\*\\|@\n\n" + (save-excursion (forward-paragraph) + (line-beginning-position 2)) + t)) ;; Go to end of paragraph and do nothing. (forward-paragraph) ;; 4. Else go to end of paragraph and insert @refill @@ -944,8 +945,8 @@ insert the text with the @insertcopying command." (end (progn (re-search-forward "^@end copying[ \t]*\n") (point)))) (setq texinfo-copying-text (buffer-substring-no-properties - (save-excursion (goto-char beg) (forward-line 1) (point)) - (save-excursion (goto-char end) (forward-line -1) (point)))) + (save-excursion (goto-char beg) (line-beginning-position 2)) + (save-excursion (goto-char end) (line-beginning-position 0)))) (delete-region beg end))) (defun texinfo-insertcopying () @@ -4297,5 +4298,4 @@ For example, invoke ;;; Place `provide' at end of file. (provide 'texinfmt) -;; arch-tag: 1e8d9a2d-bca0-40a0-ac6c-dab01bc6f725 ;;; texinfmt.el ends here diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index be23a439bf3..ea691ee8ee4 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el @@ -443,7 +443,9 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") (define-key map "\C-c\C-s" 'texinfo-show-structure) (define-key map "\C-c}" 'up-list) + ;; FIXME: This is often used for "close block" aka texinfo-insert-@end. (define-key map "\C-c]" 'up-list) + (define-key map "\C-c/" 'texinfo-insert-@end) (define-key map "\C-c{" 'texinfo-insert-braces) ;; bindings for inserting strings @@ -583,11 +585,8 @@ value of `texinfo-mode-hook'." (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate)) (make-local-variable 'paragraph-start) (setq paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start)) - (make-local-variable 'sentence-end-base) - (setq sentence-end-base + (set (make-local-variable 'sentence-end-base) "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") - (make-local-variable 'adaptive-fill-mode) - (setq adaptive-fill-mode nil) (make-local-variable 'fill-column) (setq fill-column 70) (make-local-variable 'comment-start) @@ -646,7 +645,13 @@ Puts point on a blank line between them." (completing-read (format "Block name [%s]: " texinfo-block-default) texinfo-environments nil nil nil nil texinfo-block-default)) - \n "@" str \n _ \n "@end " str \n) + \n "@" str + ;; Blocks that take parameters: all the def* blocks take parameters, + ;; plus a few others. + (if (or (string-match "\\`def" str) + (member str '("table" "ftable" "vtable"))) + '(nil " " -)) + \n _ \n "@end " str \n) (defun texinfo-inside-macro-p (macro &optional bound) "Non-nil if inside a macro matching the regexp MACRO." @@ -717,163 +722,131 @@ With prefix argument or inside @code or @example, inserts a plain \"." (not (looking-at "@end")))) (texinfo-next-unmatched-end))) -(defun texinfo-insert-@end () +(define-skeleton texinfo-insert-@end "Insert the matching `@end' for the last Texinfo command that needs one." - (interactive) - (let ((string (ignore-errors (save-excursion + (backward-word 1) (texinfo-last-unended-begin) - (match-string 1))))) - (insert "@end ") - (if string (insert string "\n")))) - -;; The following insert commands accept a prefix arg N, which is the -;; number of words (actually s-exprs) that should be surrounded by -;; braces. Thus you can first paste a variable name into a .texinfo -;; buffer, then say C-u 1 C-c C-c v at the beginning of the just -;; pasted variable name to put @var{...} *around* the variable name. -;; Operate on previous word or words with negative arg. - -;; These commands use texinfo-insert-@-with-arg -(defun texinfo-insert-@-with-arg (string &optional arg) - (if arg - (progn - (setq arg (prefix-numeric-value arg)) - (if (< arg 0) - (progn - (skip-chars-backward " \t\n\r\f") - (save-excursion - (forward-sexp arg) - (insert "@" string "{")) - (insert "}")) - (skip-chars-forward " \t\n\r\f") - (insert "@" string "{") - (forward-sexp arg) - (insert "}"))) - (insert "@" string "{}") - (backward-char))) - -(defun texinfo-insert-braces () + (or (match-string 1) '-))) + \n "@end " str \n) + +(define-skeleton texinfo-insert-braces "Make a pair of braces and be poised to type inside of them. Use \\[up-list] to move forward out of the braces." - (interactive) - (insert "{}") - (backward-char)) + nil + "{" _ "}") -(defun texinfo-insert-@code (&optional arg) +(define-skeleton texinfo-insert-@code "Insert a `@code{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "code" arg)) + nil + "@code{" _ "}") -(defun texinfo-insert-@dfn (&optional arg) +(define-skeleton texinfo-insert-@dfn "Insert a `@dfn{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "dfn" arg)) + nil + "@dfn{" _ "}") -(defun texinfo-insert-@email (&optional arg) +(define-skeleton texinfo-insert-@email "Insert a `@email{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "email" arg)) + nil + "@email{" _ "}") -(defun texinfo-insert-@emph (&optional arg) +(define-skeleton texinfo-insert-@emph "Insert a `@emph{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "emph" arg)) + nil + "@emph{" _ "}") -(defun texinfo-insert-@example () +(define-skeleton texinfo-insert-@example "Insert the string `@example' in a Texinfo buffer." - (interactive) - (insert "@example\n")) + nil + \n "@example" \n) -(defun texinfo-insert-@file (&optional arg) +(define-skeleton texinfo-insert-@file "Insert a `@file{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "file" arg)) + nil + "@file{" _ "}") -(defun texinfo-insert-@item () +(define-skeleton texinfo-insert-@item "Insert the string `@item' in a Texinfo buffer. If in a table defined by @table, follow said string with a space. Otherwise, follow with a newline." - (interactive) - (insert "@item" + nil + \n "@item" (if (equal (ignore-errors (save-excursion (texinfo-last-unended-begin) (match-string 1))) "table") - ?\s - ?\n))) + " " '\n) + _ \n) -(defun texinfo-insert-@kbd (&optional arg) +(define-skeleton texinfo-insert-@kbd "Insert a `@kbd{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "kbd" arg)) + nil + "@kbd{" _ "}") -(defun texinfo-insert-@node () +(define-skeleton texinfo-insert-@node "Insert the string `@node' in a Texinfo buffer. Insert a comment on the following line indicating the order of arguments to @node. Insert a carriage return after the comment line. Leave point after `@node'." - (interactive) - (insert "@node \n@comment node-name, next, previous, up\n") - (forward-line -2) - (forward-char 6)) + nil + \n "@node " _ \n) -(defun texinfo-insert-@noindent () +(define-skeleton texinfo-insert-@noindent "Insert the string `@noindent' in a Texinfo buffer." - (interactive) - (insert "@noindent\n")) + nil + \n "@noindent" \n) -(defun texinfo-insert-@quotation () +(define-skeleton texinfo-insert-@quotation "Insert the string `@quotation' in a Texinfo buffer." - (interactive) - (insert "@quotation\n")) + \n "@quotation" \n) -(defun texinfo-insert-@samp (&optional arg) +(define-skeleton texinfo-insert-@samp "Insert a `@samp{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "samp" arg)) + nil + "@samp{" _ "}") -(defun texinfo-insert-@strong (&optional arg) +(define-skeleton texinfo-insert-@strong "Insert a `@strong{...}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "strong" arg)) + nil + "@strong{" _ "}") -(defun texinfo-insert-@table () +(define-skeleton texinfo-insert-@table "Insert the string `@table' in a Texinfo buffer." - (interactive) - (insert "@table ")) + nil + \n "@table " _ \n) -(defun texinfo-insert-@var (&optional arg) +(define-skeleton texinfo-insert-@var "Insert a `@var{}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "var" arg)) + nil + "@var{" _ "}") -(defun texinfo-insert-@uref (&optional arg) +(define-skeleton texinfo-insert-@uref "Insert a `@uref{}' command in a Texinfo buffer. A numeric argument says how many words the braces should surround. The default is not to surround any existing words with the braces." - (interactive "P") - (texinfo-insert-@-with-arg "uref" arg)) + nil + "@uref{" _ "}") (defalias 'texinfo-insert-@url 'texinfo-insert-@uref) ;;; Texinfo file structure diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el index f4fcc95908b..ff021532c50 100644 --- a/lisp/textmodes/texnfo-upd.el +++ b/lisp/textmodes/texnfo-upd.el @@ -1,7 +1,7 @@ ;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files -;; Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Robert J. Chassell ;; Maintainer: bug-texinfo@gnu.org @@ -349,9 +349,7 @@ section titles are often too short to explain a node well." (when (search-forward texinfo-master-menu-header nil t) ;; Check if @detailmenu kludge is used; ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" - (save-excursion (forward-line -3) (point)) - t) + (search-backward "\n@detailmenu" (line-beginning-position -2) t) ;; Remove detailed master menu listing (setq master-menu-p t) (goto-char (match-beginning 0)) @@ -627,9 +625,7 @@ Single argument, END-OF-MENU, is position limiting search." (point) (save-excursion (re-search-forward "\\(^\\* \\|^@ignore\\|^@end menu\\)" end-of-menu t) - (forward-line -1) - (end-of-line) ; go to end of last description line - (point))) + (line-end-position 0))) ; end of last description line "")) (defun texinfo-menu-end () @@ -719,34 +715,32 @@ complements the node name rather than repeats it as a title does." (let (beginning end node-name title) (save-excursion (beginning-of-line) - (if (search-forward "* " (save-excursion (end-of-line) (point)) t) + (if (search-forward "* " (line-end-position) t) (progn (skip-chars-forward " \t") (setq beginning (point))) (error "This is not a line in a menu")) (cond ;; "Double colon" entry line; menu entry and node name are the same, - ((search-forward "::" (save-excursion (end-of-line) (point)) t) + ((search-forward "::" (line-end-position) t) (if (looking-at "[ \t]*[^ \t\n]+") (error "Descriptive text already exists")) (skip-chars-backward ": \t") (setq node-name (buffer-substring beginning (point)))) ;; "Single colon" entry line; menu entry and node name are different. - ((search-forward ":" (save-excursion (end-of-line) (point)) t) + ((search-forward ":" (line-end-position) t) (skip-chars-forward " \t") (setq beginning (point)) ;; Menu entry line ends in a period, comma, or tab. - (if (re-search-forward "[.,\t]" - (save-excursion (forward-line 1) (point)) t) + (if (re-search-forward "[.,\t]" (line-beginning-position 2) t) (progn (if (looking-at "[ \t]*[^ \t\n]+") (error "Descriptive text already exists")) (skip-chars-backward "., \t") (setq node-name (buffer-substring beginning (point)))) ;; Menu entry line ends in a return. - (re-search-forward ".*\n" - (save-excursion (forward-line 1) (point)) t) + (re-search-forward ".*\n" (line-beginning-position 2) t) (skip-chars-backward " \t\n") (setq node-name (buffer-substring beginning (point))) (if (= 0 (length node-name)) @@ -904,9 +898,7 @@ section titles are often too short to explain a node well." (progn ;; Check if @detailmenu kludge is used; ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" - (save-excursion (forward-line -3) (point)) - t) + (search-backward "\n@detailmenu" (line-beginning-position -2) t) ;; Remove detailed master menu listing (goto-char (match-beginning 0)) (let ((end-of-detailed-menu-descriptions @@ -941,9 +933,7 @@ section titles are often too short to explain a node well." (goto-char (match-beginning 0)) ;; Check if @detailmenu kludge is used; ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" - (save-excursion (forward-line -3) (point)) - t) + (search-backward "\n@detailmenu" (line-beginning-position -2) t) (insert "\n") (delete-blank-lines) (goto-char (point-min)))) @@ -1154,8 +1144,7 @@ Only argument is a string of the general type of section." (save-excursion (goto-char (point-min)) (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) - (beginning-of-line) - (point))) + (line-beginning-position))) (t (save-excursion (re-search-backward @@ -1206,13 +1195,11 @@ The menu will be located just before this position. First argument is the position of the beginning of the section in which the menu will be located; second argument is the position of the end of that region; it limits the search." - (save-excursion (goto-char beginning) (forward-line 1) (re-search-forward "^@node" end t) - (beginning-of-line) - (point))) + (line-beginning-position))) ;;; Updating a node @@ -1331,7 +1318,7 @@ Point must be at beginning of node line. Does not move point." Starts from the current position of the cursor, and searches forward on the line for a comma and if one is found, deletes the rest of the line, including the comma. Leaves point at beginning of line." - (let ((eol-point (save-excursion (end-of-line) (point)))) + (let ((eol-point (line-end-position))) (if (search-forward "," eol-point t) (delete-region (1- (point)) eol-point))) (beginning-of-line)) @@ -1437,8 +1424,7 @@ will be at some level higher in the Texinfo file. The fourth argument "\\)") (save-excursion (goto-char beginning) - (beginning-of-line) - (point)) + (line-beginning-position)) t) 'normal 'no-pointer)) @@ -1453,7 +1439,7 @@ The argument is the kind of section, either `normal' or `no-pointer'." (end-of-line) ; this handles prev node top case (re-search-backward ; when point is already "^@node" ; at the beginning of @node line - (save-excursion (forward-line -3)) + (line-beginning-position -2) t) (setq name (texinfo-copy-node-name))) ((eq kind 'no-pointer) @@ -1483,7 +1469,7 @@ towards which the pointer is directed, one of `next', `previous', or `up'." "Remove extra commas, if any, at end of node line." (end-of-line) (skip-chars-backward ", ") - (delete-region (point) (save-excursion (end-of-line) (point)))) + (delete-region (point) (line-end-position))) ;;; Updating nodes sequentially @@ -1647,13 +1633,14 @@ node names in pre-existing `@node' lines that lack names." (skip-chars-forward " \t") (setq title (buffer-substring (point) - (save-excursion (end-of-line) (point)))))) + (line-end-position))))) ;; Insert node line if necessary. (if (re-search-backward "^@node" ;; Avoid finding previous node line if node lines are close. (or last-section-position - (save-excursion (forward-line -2) (point))) t) + (line-beginning-position -1)) + t) ;; @node is present, and point at beginning of that line (forward-word 1) ; Leave point just after @node. ;; Else @node missing; insert one. @@ -1675,7 +1662,7 @@ node names in pre-existing `@node' lines that lack names." (message "Inserted title %s ... " title))))) ;; Go forward beyond current section title. (re-search-forward texinfo-section-types-regexp - (save-excursion (forward-line 3) (point)) t) + (line-beginning-position 4) t) (setq last-section-position (point)) (forward-line 1)) @@ -1993,9 +1980,7 @@ chapter." (point-min) (save-excursion (re-search-forward "^@include") - (beginning-of-line) - (point))) - + (line-beginning-position))) ;; If found, leave point after word `menu' on the `@menu' line. (progn (texinfo-incorporate-descriptions main-menu-list) @@ -2021,9 +2006,7 @@ chapter." (goto-char (match-beginning 0)) ;; Check if @detailmenu kludge is used; ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" - (save-excursion (forward-line -3) (point)) - t) + (search-backward "\n@detailmenu" (line-beginning-position -2) t) ;; Remove detailed master menu listing (let ((end-of-detailed-menu-descriptions (save-excursion ; beginning of end menu line @@ -2057,5 +2040,4 @@ chapter." ;; Place `provide' at end of file. (provide 'texnfo-upd) -;; arch-tag: d21613a5-c32f-43f4-8af4-bfb1e7455842 ;;; texnfo-upd.el ends here |