summaryrefslogtreecommitdiff
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2009-10-31 02:38:34 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2009-10-31 02:38:34 +0000
commit9a5293129d0e7b2b6333a735f054d2273572b1b3 (patch)
treea04125bf576f98c659f65f5b4a35cbfedc494652 /lisp/textmodes
parentd566f228251359ebf1f1f5ab69753089c04e5515 (diff)
downloademacs-9a5293129d0e7b2b6333a735f054d2273572b1b3.tar.gz
* textmodes/two-column.el (2C-split):
* textmodes/texnfo-upd.el (texinfo-multi-file-included-list): * textmodes/tex-mode.el (tex-set-buffer-directory): * textmodes/spell.el (spell-region, spell-string): * textmodes/reftex.el (reftex-erase-buffer): (reftex-get-file-buffer-force, reftex-kill-temporary-buffers): * textmodes/reftex-toc.el (reftex-toc-promote-action): * textmodes/reftex-sel.el (reftex-get-offset, reftex-insert-docstruct) (reftex-select-item): * textmodes/reftex-ref.el (reftex-label-info-update) (reftex-offer-label-menu): * textmodes/reftex-index.el (reftex-index-change-entry) (reftex-index-phrases-info): * textmodes/reftex-global.el (reftex-create-tags-file) (reftex-save-all-document-buffers, reftex-ensure-write-access): * textmodes/reftex-dcr.el (reftex-echo-ref, reftex-echo-cite) (reftex-view-crossref-from-bibtex): * textmodes/reftex-cite.el (reftex-bibtex-selection-callback) (reftex-extract-bib-entries-from-thebibliography) (reftex-all-used-citation-keys, reftex-create-bibtex-file): * textmodes/refbib.el (r2b-capitalize-title): (r2b-convert-buffer, r2b-help): * textmodes/page-ext.el (pages-directory) (pages-directory-goto-with-mouse): * textmodes/bibtex.el (bibtex-validate-globally): * textmodes/bib-mode.el (bib-capitalize-title): * textmodes/artist.el (artist-clear-buffer, artist-system): * progmodes/xscheme.el (global-set-scheme-interaction-buffer): (local-set-scheme-interaction-buffer, xscheme-process-filter) (verify-xscheme-buffer, xscheme-enter-interaction-mode) (xscheme-enter-debugger-mode, xscheme-debugger-mode-p) (xscheme-send-control-g-interrupt, xscheme-start-process) (xscheme-process-sentinel, xscheme-cd): * progmodes/verilog-mode.el (verilog-read-always-signals) (verilog-set-define, verilog-getopt-file) (verilog-module-inside-filename-p): * progmodes/sh-script.el: * progmodes/python.el (python-pdbtrack-get-source-buffer) (python-pdbtrack-grub-for-buffer, python-execute-file): * progmodes/octave-inf.el (inferior-octave): * progmodes/idlwave.el (idlwave-scan-user-lib-files) (idlwave-shell-compile-helper-routines, idlwave-set-local) (idlwave-display-completion-list-xemacs, idlwave-list-abbrevs) (idlwave-display-completion-list-emacs, idlwave-list-load-path-shadows) (idlwave-completion-fontify-classes, idlwave-display-calling-sequence): * progmodes/idlw-shell.el (idlwave-shell-examine-display-clear) (idlwave-shell-filter, idlwave-shell-examine-highlight) (idlwave-shell-sentinel, idlwave-shell-filter-directory) (idlwave-shell-display-line, idlwave-shell-set-bp-in-module) (idlwave-shell-examine-display, idlwave-shell-run-region) (idlwave-shell-filter-bp, idlwave-shell-save-and-action) (idlwave-shell-sources-filter, idlwave-shell-goto-next-error): * progmodes/idlw-help.el (idlwave-help-get-special-help) (idlwave-help-get-help-buffer): * progmodes/gud.el (gud-basic-call, gud-find-class) (gud-tooltip-activate-mouse-motions-if-enabled): * progmodes/gdb-mi.el (gdb-mouse-toggle-breakpoint-fringe): * progmodes/ebrowse.el (ebrowse-member-table, ebrowse-save-tree-as) (ebrowse-view-exit-fn, ebrowse-tags-list-members-in-file) (ebrowse-tags-next-file): * progmodes/ebnf2ps.el (ebnf-generate-eps, ebnf-generate-eps) (ebnf-eps-production-list, ebnf-begin-file, ebnf-log) (ebnf-eps-finish-and-write): * progmodes/cpp.el (cpp-edit-save): * progmodes/cperl-mode.el (cperl-pod-to-manpage): * progmodes/cc-defs.el (c-emacs-features): * progmodes/antlr-mode.el (antlr-invalidate-context-cache) (antlr-directory-dependencies): * progmodes/ada-xref.el (ada-gnat-parse-gpr, ada-get-ali-file-name) (ada-run-application, ada-find-in-src-path, ada-goto-parent) (ada-find-any-references, ada-make-filename-from-adaname) (ada-make-body-gnatstub): * obsolete/rnews.el (news-list-news-groups): * obsolete/resume.el (resume-suspend-hook,resume-write-buffer-to-file): * obsolete/iso-acc.el (iso-acc-minibuf-setup): * net/rcirc.el (rcirc-debug): * net/newst-treeview.el (newsticker--treeview-list-add-item) (newsticker--treeview-list-clear, newsticker-treeview-browse-url) (newsticker--treeview-list-update-faces, newsticker-treeview-save) (newsticker--treeview-item-show-text, newsticker--treeview-item-show) (newsticker--treeview-tree-update-tag,newsticker--treeview-buffer-init) (newsticker-treeview-show-item, newsticker--treeview-unfold-node) (newsticker--treeview-list-clear-highlight) (newsticker--treeview-list-update-highlight) (newsticker--treeview-list-highlight-start) (newsticker--treeview-tree-update-highlight) (newsticker--treeview-get-selected-item) (newsticker-treeview-mark-list-items-old) (newsticker--treeview-set-current-node): * net/newst-plainview.el (newsticker--buffer-set-uptodate): * net/newst-backend.el (newsticker--get-news-by-funcall) (newsticker--get-news-by-wget, newsticker--image-get) (newsticker--image-sentinel): * net/mairix.el (mairix-rmail-fetch-field, mairix-gnus-fetch-field): * net/eudcb-ph.el (eudc-ph-do-request, eudc-ph-open-session): (eudc-ph-close-session): * net/eudc.el (eudc-save-options): * language/thai-word.el (thai-update-word-table): * language/japan-util.el (japanese-string-conversion): * international/titdic-cnv.el (tsang-quick-converter) (ziranma-converter, ctlau-converter): * international/mule-cmds.el (describe-language-environment): * international/ja-dic-cnv.el (skkdic-convert-okuri-ari) (skkdic-convert-postfix, skkdic-convert-prefix): (skkdic-convert-okuri-nasi, skkdic-convert): * emacs-lisp/re-builder.el (reb-update-overlays): * emacs-lisp/pp.el (pp-to-string, pp-display-expression): * emacs-lisp/gulp.el (gulp-send-requests): * emacs-lisp/find-gc.el (trace-call-tree): * emacs-lisp/eieio-opt.el (eieio-browse, eieio-describe-class) (eieio-describe-generic): * emacs-lisp/eieio-base.el (eieio-persistent-read): * emacs-lisp/edebug.el (edebug-outside-excursion): * emacs-lisp/debug.el (debugger-make-xrefs): * emacs-lisp/cust-print.el (custom-prin1-to-string): * emacs-lisp/chart.el (chart-new-buffer): * emacs-lisp/authors.el (authors-scan-el, authors-scan-change-log): Use with-current-buffer. * textmodes/artist.el (artist-system): Don't call copy-sequence on a fresh string. * progmodes/idlw-shell.el (easymenu setup): Use dolist.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/artist.el9
-rw-r--r--lisp/textmodes/bib-mode.el11
-rw-r--r--lisp/textmodes/bibtex.el3
-rw-r--r--lisp/textmodes/page-ext.el6
-rw-r--r--lisp/textmodes/refbib.el51
-rw-r--r--lisp/textmodes/reftex-cite.el10
-rw-r--r--lisp/textmodes/reftex-dcr.el8
-rw-r--r--lisp/textmodes/reftex-global.el34
-rw-r--r--lisp/textmodes/reftex-index.el5
-rw-r--r--lisp/textmodes/reftex-ref.el6
-rw-r--r--lisp/textmodes/reftex-sel.el52
-rw-r--r--lisp/textmodes/reftex-toc.el3
-rw-r--r--lisp/textmodes/reftex.el11
-rw-r--r--lisp/textmodes/spell.el86
-rw-r--r--lisp/textmodes/tex-mode.el3
-rw-r--r--lisp/textmodes/texnfo-upd.el3
-rw-r--r--lisp/textmodes/two-column.el3
17 files changed, 133 insertions, 171 deletions
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index 6920b18045c..c69e3bc37ab 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -1801,8 +1801,7 @@ info-variant-part."
(defun artist-clear-buffer (buf)
"Clear contents of buffer BUF."
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(goto-char (point-min))
(delete-char (- (point-max) (point-min)) nil)))
@@ -1848,10 +1847,8 @@ Return a list (RETURN-CODE STDOUT STDERR)."
;; the return value
(list res
- (save-excursion
- (set-buffer tmp-stdout-buffer)
- (copy-sequence (buffer-substring (point-min)
- (point-max))))
+ (with-current-buffer tmp-stdout-buffer
+ (buffer-substring (point-min) (point-max)))
(artist-file-to-string tmp-stderr-file-name)))
;; Unwind: remove temporary files and buffers
diff --git a/lisp/textmodes/bib-mode.el b/lisp/textmodes/bib-mode.el
index d6f7003867d..d4ebe5f09c9 100644
--- a/lisp/textmodes/bib-mode.el
+++ b/lisp/textmodes/bib-mode.el
@@ -228,12 +228,11 @@ named by variable `unread-bib-file'."
(defun bib-capitalize-title (s)
"Like `capitalize', but don't capitalize stop words, except the first."
- (save-excursion
- (set-buffer (get-buffer-create "$$$Scratch$$$"))
- (erase-buffer)
- (insert s)
- (bib-capitalize-title-region (point-min) (point-max))
- (buffer-string)))
+ (with-current-buffer (get-buffer-create "$$$Scratch$$$")
+ (erase-buffer)
+ (insert s)
+ (bib-capitalize-title-region (point-min) (point-max))
+ (buffer-string)))
(provide 'bib-mode)
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 99995aed2ea..bede8184e88 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -3863,8 +3863,7 @@ Return t if test was successful, nil otherwise."
buffer-key-list current-buf current-keys error-list)
;; Check for duplicate keys within BibTeX buffer
(dolist (buffer buffer-list)
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(let (entry-type key key-list)
(goto-char (point-min))
(while (re-search-forward bibtex-entry-head nil t)
diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el
index 67a39d5cf51..3176ae28c4c 100644
--- a/lisp/textmodes/page-ext.el
+++ b/lisp/textmodes/page-ext.el
@@ -580,8 +580,7 @@ directory for only the accessible portion of the buffer."
;; `standard-output' to the buffer named as its first argument,
;; but does not switch to that buffer.
(with-output-to-temp-buffer pages-directory-buffer
- (save-excursion
- (set-buffer standard-output)
+ (with-current-buffer standard-output
(pages-directory-mode)
(insert
"==== Pages Directory: use `C-c C-c' to go to page under cursor. ====" ?\n)
@@ -736,8 +735,7 @@ to the same line in the pages buffer."
(defun pages-directory-goto-with-mouse (event)
"Go to the corresponding line under the mouse pointer in the pages buffer."
(interactive "e")
- (save-excursion
- (set-buffer (window-buffer (posn-window (event-end event))))
+ (with-current-buffer (window-buffer (posn-window (event-end event)))
(save-excursion
(goto-char (posn-point (event-end event)))
(pages-directory-goto))))
diff --git a/lisp/textmodes/refbib.el b/lisp/textmodes/refbib.el
index b0600dbaafa..fc017eb4ca2 100644
--- a/lisp/textmodes/refbib.el
+++ b/lisp/textmodes/refbib.el
@@ -170,12 +170,11 @@ This is in addition to the `r2b-capitalize-title-stop-words'.")
(defun r2b-capitalize-title (s)
"Like `capitalize', but don't capitalize stop words, except the first."
- (save-excursion
- (set-buffer (get-buffer-create "$$$Scratch$$$"))
- (erase-buffer)
- (insert s)
- (r2b-capitalize-title-region (point-min) (point-max))
- (buffer-string)))
+ (with-current-buffer (get-buffer-create "$$$Scratch$$$")
+ (erase-buffer)
+ (insert s)
+ (r2b-capitalize-title-region (point-min) (point-max))
+ (buffer-string)))
;*********************************************************
(defun r2b-reset ()
@@ -681,22 +680,19 @@ Do `\\[r2b-help]' for more info."
(defun r2b-convert-buffer (output)
- "Transform current buffer and append to buffer OUTPUT.
+ "Transform current buffer and append to buffer OUTPUT.
Do `\\[r2b-help]' for more info."
- (interactive
- (list (read-string "Output to buffer: " r2b-out-buf-name)))
- (save-excursion
- (setq r2b-log (get-buffer-create r2b-log-name))
- (set-buffer r2b-log)
- (erase-buffer))
- (widen)
- (goto-char (point-min))
- (message "Working, please be patient...")
- (sit-for 0)
- (while (r2b-convert-record output) t)
- (message "Done, results in %s, errors in %s"
- r2b-out-buf-name r2b-log-name)
- )
+ (interactive
+ (list (read-string "Output to buffer: " r2b-out-buf-name)))
+ (with-current-buffer (setq r2b-log (get-buffer-create r2b-log-name))
+ (erase-buffer))
+ (widen)
+ (goto-char (point-min))
+ (message "Working, please be patient...")
+ (sit-for 0)
+ (while (r2b-convert-record output) t)
+ (message "Done, results in %s, errors in %s"
+ r2b-out-buf-name r2b-log-name))
(defvar r2b-help-message
" Refer to Bibtex Bibliography Conversion
@@ -740,13 +736,12 @@ Please send bug reports and suggestions to
(defun r2b-help ()
- "Print help describing the `refbib' package."
- (interactive)
- (with-output-to-temp-buffer "*Help*"
- (princ r2b-help-message)
- (save-excursion
- (set-buffer standard-output)
- (help-mode))))
+ "Print help describing the `refbib' package."
+ (interactive)
+ (with-output-to-temp-buffer "*Help*"
+ (princ r2b-help-message)
+ (with-current-buffer standard-output
+ (help-mode))))
(provide 'refbib)
(provide 'refer-to-bibtex)
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index c81d20fb4e1..ed055bb2b78 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -356,8 +356,7 @@
(error "No such file %s" file))
(message "Scanning thebibliography environment in %s" file)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(save-restriction
(widen)
(goto-char (point-min))
@@ -1076,8 +1075,7 @@ While entering the regexp, completion on knows citation keys is possible.
bibfile-list item bibtype)
(catch 'exit
- (save-excursion
- (set-buffer reftex-call-back-to-this-buffer)
+ (with-current-buffer reftex-call-back-to-this-buffer
(setq bibtype (reftex-bib-or-thebib))
(cond
((eq bibtype 'bib)
@@ -1109,7 +1107,7 @@ While entering the regexp, completion on knows citation keys is possible.
(defun reftex-all-used-citation-keys ()
(reftex-access-scan-info)
(let ((files (reftex-all-document-files)) file keys kk k)
- (save-excursion
+ (save-current-buffer
(while (setq file (pop files))
(set-buffer (reftex-get-file-buffer-force file 'mark))
(save-excursion
@@ -1137,7 +1135,7 @@ The sequence in the new file is the same as it was in the old database."
(let ((keys (reftex-all-used-citation-keys))
(files (reftex-get-bibfile-list))
file key entries beg end entry)
- (save-excursion
+ (save-current-buffer
(while (setq file (pop files))
(set-buffer (reftex-get-file-buffer-force file 'mark))
(reftex-with-special-syntax-for-bib
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index 8626b25721f..0b76c723798 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -276,8 +276,7 @@ With argument, actually select the window showing the cross reference."
(message "ref(%s): %s" (nth 1 entry) (nth 2 entry)))
(let ((buf (get-buffer " *Echo Area*")))
(when buf
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(run-hooks 'reftex-display-copied-context-hook)))))))
(defun reftex-echo-cite (key files item)
@@ -313,8 +312,7 @@ With argument, actually select the window showing the cross reference."
(unless (or (null string) (equal string ""))
(message "cite: %s" string))
(when (setq buf (get-buffer " *Echo Area*"))
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(run-hooks 'reftex-display-copied-context-hook)))))
(defvar reftex-use-itimer-in-xemacs nil
@@ -373,7 +371,7 @@ Calling this function several times find successive citation locations."
;; Establish connection to reference buffer
(unless ref-buffer
(setq ref-buffer
- (save-excursion
+ (save-current-buffer
(completing-read
"Reference buffer: "
(delq nil
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index b0c4b34584c..85ee4626d16 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -40,8 +40,7 @@ The TAGS file is also immediately visited with `visit-tags-table'."
(files (reftex-all-document-files))
(cmd (format "etags %s" (mapconcat 'shell-quote-argument
files " "))))
- (save-excursion
- (set-buffer (reftex-get-file-buffer-force master))
+ (with-current-buffer (reftex-get-file-buffer-force master)
(message "Running etags to create TAGS file...")
(shell-command cmd)
(visit-tags-table "TAGS"))))
@@ -314,7 +313,7 @@ labels."
(interactive)
(let ((files (reftex-all-document-files))
file buffer)
- (save-excursion
+ (save-current-buffer
(while (setq file (pop files))
(setq buffer (reftex-get-buffer-visiting file))
(when buffer
@@ -335,8 +334,7 @@ Also checks if buffers visiting the files are in read-only mode."
(or (y-or-n-p (format "No write access to %s. Continue? " file))
(error "Abort")))
(when (and (setq buf (reftex-get-buffer-visiting file))
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
buffer-read-only))
(ding)
(or (y-or-n-p (format "Buffer %s is read-only. Continue? "
@@ -345,11 +343,11 @@ Also checks if buffers visiting the files are in read-only mode."
;;; Multi-file RefTeX Isearch
-;;; `reftex-isearch-wrap-function', `reftex-isearch-push-state-function',
-;;; `reftex-isearch-pop-state-function', `reftex-isearch-isearch-search'
-;;; functions remain here only for backward-compatibility with Emacs 22
-;;; and are obsolete since Emacs 23 that supports a single function
-;;; variable `multi-isearch-next-buffer-function'.
+;; `reftex-isearch-wrap-function', `reftex-isearch-push-state-function',
+;; `reftex-isearch-pop-state-function', `reftex-isearch-isearch-search'
+;; functions remain here only for backward-compatibility with Emacs 22
+;; and are obsolete since Emacs 23 that supports a single function
+;; variable `multi-isearch-next-buffer-function'.
(defun reftex-isearch-wrap-function ()
(if (not isearch-word)
@@ -402,14 +400,14 @@ Also checks if buffers visiting the files are in read-only mode."
(point))
(error nil))))))
-;;; This function is called when isearch reaches the end of a
-;;; buffer. For reftex what we want to do is not wrap to the
-;;; beginning, but switch to the next buffer in the logical order of
-;;; the document. This function looks through list of files in the
-;;; document (reftex-all-document-files), searches for the current
-;;; buffer and switches to the next/previous one in the logical order
-;;; of the document. If WRAPP is true then wrap the search to the
-;;; beginning/end of the file list, depending of the search direction.
+;; This function is called when isearch reaches the end of a
+;; buffer. For reftex what we want to do is not wrap to the
+;; beginning, but switch to the next buffer in the logical order of
+;; the document. This function looks through list of files in the
+;; document (reftex-all-document-files), searches for the current
+;; buffer and switches to the next/previous one in the logical order
+;; of the document. If WRAPP is true then wrap the search to the
+;; beginning/end of the file list, depending of the search direction.
(defun reftex-isearch-switch-to-next-file (crt-buf &optional wrapp)
(reftex-access-scan-info)
(let ((cb (buffer-file-name crt-buf))
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index d26365b6d70..f640710c01e 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -1012,8 +1012,7 @@ When index is restricted, select the previous section as restriction criterion."
(setq beg (match-beginning 0) end (match-end 0))
(setq old (nth 2 data))
(and (equal old new) (error "Entry unchanged"))
- (save-excursion
- (set-buffer (get-file-buffer (nth 3 data)))
+ (with-current-buffer (get-file-buffer (nth 3 data))
(goto-char beg)
(unless (looking-at (regexp-quote old))
(error "This should not happen (reftex-index-change-entry)"))
@@ -1594,7 +1593,7 @@ this function repeatedly."
(while (re-search-forward re2 nil t)
(push (cons (count-lines 1 (point)) (match-string 1)) superphrases)
(incf ntimes2))))
- (save-excursion
+ (save-current-buffer
(while (setq file (pop files))
(setq buf (reftex-get-file-buffer-force file))
(when buf
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 3ec284eacac..0a62027acbd 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -78,8 +78,7 @@ If optional BOUND is an integer, limit backward searches to that point."
file (not (eq t reftex-keep-temporary-buffers)))))
(if (not buf)
(list label typekey "" file comment "LOST LABEL. RESCAN TO FIX.")
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(save-restriction
(widen)
(goto-char 1)
@@ -538,8 +537,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
reftex-latex-syntax-table (syntax-table))
(if reftex-use-multiple-selection-buffers
(switch-to-buffer-other-window
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(reftex-make-selection-buffer-name typekey)))
(switch-to-buffer-other-window "*RefTeX Select*")
(reftex-erase-buffer))
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index f6f384fcb7d..98ce7bc92ad 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -90,28 +90,27 @@ During a selection process, these are the local bindings.
;; We do not set a local map - reftex-select-item does this.
(run-hooks 'reftex-select-bib-mode-hook))
-;;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
-;;; ;; Find the correct offset data, like insert-docstruct would, but faster.
-;;; ;; Buffer BUF knows the correct docstruct to use.
-;;; ;; Basically this finds the first docstruct entry after HERE-I-AM which
-;;; ;; is of allowed type. The optional arguments specify what is allowed.
-;;; (catch 'exit
-;;; (save-excursion
-;;; (set-buffer buf)
-;;; (reftex-access-scan-info)
-;;; (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
-;;; entry)
-;;; (while (setq entry (pop rest))
-;;; (if (or (and typekey
-;;; (stringp (car entry))
-;;; (or (equal typekey " ")
-;;; (equal typekey (nth 1 entry))))
-;;; (and toc (eq (car entry) 'toc))
-;;; (and index (eq (car entry) 'index))
-;;; (and file
-;;; (memq (car entry) '(bof eof file-error))))
-;;; (throw 'exit entry)))
-;;; nil))))
+;; (defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
+;; ;; Find the correct offset data, like insert-docstruct would, but faster.
+;; ;; Buffer BUF knows the correct docstruct to use.
+;; ;; Basically this finds the first docstruct entry after HERE-I-AM which
+;; ;; is of allowed type. The optional arguments specify what is allowed.
+;; (catch 'exit
+;; (with-current-buffer buf
+;; (reftex-access-scan-info)
+;; (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
+;; entry)
+;; (while (setq entry (pop rest))
+;; (if (or (and typekey
+;; (stringp (car entry))
+;; (or (equal typekey " ")
+;; (equal typekey (nth 1 entry))))
+;; (and toc (eq (car entry) 'toc))
+;; (and index (eq (car entry) 'index))
+;; (and file
+;; (memq (car entry) '(bof eof file-error))))
+;; (throw 'exit entry)))
+;; nil))))
(defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
;; Find the correct offset data, like insert-docstruct would, but faster.
@@ -119,8 +118,7 @@ During a selection process, these are the local bindings.
;; Basically this finds the first docstruct entry before HERE-I-AM which
;; is of allowed type. The optional arguments specify what is allowed.
(catch 'exit
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(reftex-access-scan-info)
(let* ((rest (symbol-value reftex-docstruct-symbol))
lastentry entry)
@@ -178,8 +176,7 @@ During a selection process, these are the local bindings.
prev-inserted offset from to index-tag docstruct-symbol)
;; Pop to buffer buf to get the correct buffer-local variables
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
;; Ensure access to scanning info
(reftex-access-scan-info)
@@ -413,8 +410,7 @@ During a selection process, these are the local bindings.
(recursive-edit))
(set-marker reftex-recursive-edit-marker nil)
- (save-excursion
- (set-buffer selection-buffer)
+ (with-current-buffer selection-buffer
(use-local-map nil)
(remove-hook 'pre-command-hook 'reftex-select-pre-command-hook t)
(remove-hook 'post-command-hook
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 6f7d536d6c6..0a50555d37d 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -708,8 +708,7 @@ DELTA and PRO-OR-DE are assumed to be dynamically scoped into this function."
(name (nth 1 x))
(newname (nth 2 x))
(marker (nth 4 data)))
- (save-excursion
- (set-buffer (marker-buffer marker))
+ (with-current-buffer (marker-buffer marker)
(goto-char (marker-position marker))
(if (looking-at (concat "\\([ \t]*\\\\\\)" (regexp-quote name)))
(replace-match (concat "\\1" newname))
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index d905ce66905..6bc5c0c69c0 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1822,9 +1822,8 @@ When DIE is non-nil, throw an error if file not found."
(let ((buffer-read-only nil)) (erase-buffer)))
((setq buffer (get-buffer buffer))
;; buffer exists
- (save-excursion
- (set-buffer buffer)
- (let ((buffer-read-only nil)) (erase-buffer))))))
+ (with-current-buffer buffer
+ (let ((inhibit-read-only t)) (erase-buffer))))))
(defun reftex-this-word (&optional class)
;; Grab the word around point.
@@ -2072,8 +2071,7 @@ When DIE is non-nil, throw an error if file not found."
;; Is there a hook to run?
(when (listp reftex-initialize-temporary-buffers)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(run-hooks 'reftex-initialize-temporary-buffers))))
;; Lets see if we got a license to kill :-|
@@ -2100,8 +2098,7 @@ When DIE is non-nil, throw an error if file not found."
(and (buffer-modified-p buffer)
(y-or-n-p (format "Save file %s? "
(buffer-file-name buffer)))
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(save-buffer)))
(kill-buffer buffer))
(pop reftex-buffers-to-kill)))))
diff --git a/lisp/textmodes/spell.el b/lisp/textmodes/spell.el
index aa062edffc4..2cda1a17612 100644
--- a/lisp/textmodes/spell.el
+++ b/lisp/textmodes/spell.el
@@ -93,8 +93,7 @@ for example, \"word\"."
(interactive "r")
(let ((filter spell-filter)
(buf (get-buffer-create " *temp*")))
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(widen)
(erase-buffer))
(message "Checking spelling of %s..." (or description "region"))
@@ -104,41 +103,37 @@ for example, \"word\"."
(call-process-region start end shell-file-name
nil buf nil "-c" spell-command))
(let ((oldbuf (current-buffer)))
- (save-excursion
- (set-buffer buf)
- (insert-buffer-substring oldbuf start end)
- (or (bolp) (insert ?\n))
- (if filter (funcall filter))
- (if (string= "spell" spell-command)
- (call-process-region (point-min) (point-max) "spell" t buf)
- (call-process-region (point-min) (point-max) shell-file-name
- t buf nil "-c" spell-command)))))
+ (with-current-buffer buf
+ (insert-buffer-substring oldbuf start end)
+ (or (bolp) (insert ?\n))
+ (if filter (funcall filter))
+ (if (string= "spell" spell-command)
+ (call-process-region (point-min) (point-max) "spell" t buf)
+ (call-process-region (point-min) (point-max) shell-file-name
+ t buf nil "-c" spell-command)))))
(message "Checking spelling of %s...%s"
(or description "region")
- (if (save-excursion
- (set-buffer buf)
- (> (buffer-size) 0))
+ (if (with-current-buffer buf
+ (> (buffer-size) 0))
"not correct"
"correct"))
(let (word newword
(case-fold-search t)
(case-replace t))
- (while (save-excursion
- (set-buffer buf)
- (> (buffer-size) 0))
- (save-excursion
- (set-buffer buf)
- (goto-char (point-min))
- (setq word (downcase
- (buffer-substring (point)
- (progn (end-of-line) (point)))))
- (forward-char 1)
- (delete-region (point-min) (point))
- (setq newword
- (read-string (concat "`" word
- "' not recognized; edit a replacement: ")
- word))
- (flush-lines (concat "^" (regexp-quote word) "$")))
+ (while (with-current-buffer buf
+ (> (buffer-size) 0))
+ (with-current-buffer buf
+ (goto-char (point-min))
+ (setq word (downcase
+ (buffer-substring (point)
+ (progn (end-of-line) (point)))))
+ (forward-char 1)
+ (delete-region (point-min) (point))
+ (setq newword
+ (read-string (concat "`" word
+ "' not recognized; edit a replacement: ")
+ word))
+ (flush-lines (concat "^" (regexp-quote word) "$")))
(if (not (equal word newword))
(progn
(goto-char (point-min))
@@ -152,22 +147,21 @@ for example, \"word\"."
"Check spelling of string supplied as argument."
(interactive "sSpell string: ")
(let ((buf (get-buffer-create " *temp*")))
- (save-excursion
- (set-buffer buf)
- (widen)
- (erase-buffer)
- (insert string "\n")
- (if (string= "spell" spell-command)
- (call-process-region (point-min) (point-max) "spell"
- t t)
- (call-process-region (point-min) (point-max) shell-file-name
- t t nil "-c" spell-command))
- (if (= 0 (buffer-size))
- (message "%s is correct" string)
- (goto-char (point-min))
- (while (search-forward "\n" nil t)
- (replace-match " "))
- (message "%sincorrect" (buffer-substring 1 (point-max)))))))
+ (with-current-buffer buf
+ (widen)
+ (erase-buffer)
+ (insert string "\n")
+ (if (string= "spell" spell-command)
+ (call-process-region (point-min) (point-max) "spell"
+ t t)
+ (call-process-region (point-min) (point-max) shell-file-name
+ t t nil "-c" spell-command))
+ (if (= 0 (buffer-size))
+ (message "%s is correct" string)
+ (goto-char (point-min))
+ (while (search-forward "\n" nil t)
+ (replace-match " "))
+ (message "%sincorrect" (buffer-substring 1 (point-max)))))))
;;;###autoload
(make-obsolete 'spell-string "The `spell' package is obsolete - use `ispell'."
"23.1")
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index f4aca3198ab..db873483579 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1700,8 +1700,7 @@ In the tex shell buffer this command behaves like `comint-send-input'."
(setq directory (file-name-as-directory (expand-file-name directory)))
(if (not (file-directory-p directory))
(error "%s is not a directory" directory)
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(setq default-directory directory))))
(defvar tex-send-command-modified-tick 0)
diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el
index 2550e129b19..e6f48a33801 100644
--- a/lisp/textmodes/texnfo-upd.el
+++ b/lisp/textmodes/texnfo-upd.el
@@ -1723,8 +1723,7 @@ node names in pre-existing `@node' lines that lack names."
"Return a list of the included files in OUTER-FILE."
(let ((included-file-list (list outer-file))
start)
- (save-excursion
- (set-buffer (find-file-noselect outer-file))
+ (with-current-buffer (find-file-noselect outer-file)
(widen)
(goto-char (point-min))
(while (re-search-forward "^@include" nil t)
diff --git a/lisp/textmodes/two-column.el b/lisp/textmodes/two-column.el
index c393e1d9bcd..ed51434fe85 100644
--- a/lisp/textmodes/two-column.el
+++ b/lisp/textmodes/two-column.el
@@ -407,8 +407,7 @@ First column's text sSs Second column's text
(if (y-or-n-p (concat "Overwrite associated buffer `"
(buffer-name (2C-other))
"'? "))
- (save-excursion
- (set-buffer (2C-other))
+ (with-current-buffer (2C-other)
(erase-buffer))
(signal 'quit nil)))
(let ((point (point))