diff --git a/ecb-analyse.el b/ecb-analyse.el index 46dca1fd..33bd98eb 100644 --- a/ecb-analyse.el +++ b/ecb-analyse.el @@ -392,8 +392,7 @@ should be displayed with. LIST is a list of tags for this bucket. NODETYPE is an integer which will be added as type to the nodes created for the elements of LIST." (when list - (save-excursion - (set-buffer ecb-analyse-buffer-name) + (with-current-buffer ecb-analyse-buffer-name (let* ((bucket-name-formatted (ecb-merge-face-into-text (ecb-format-bucket-name bucket-name) ecb-analyse-bucket-node-face)) @@ -532,8 +531,7 @@ ECB-analyse-window is not visible in current layout." (defun ecb-analyse-show-tag-info-in-temp-buffer (info-string) "Display INFO-STRING in a temp-buffer in the edit-area." (with-output-to-temp-buffer "*Tag Information*" - (save-excursion - (set-buffer "*Tag Information*") + (with-current-buffer "*Tag Information*" (insert info-string))) ;; Make it small (shrink-window-if-larger-than-buffer diff --git a/ecb-autogen.el b/ecb-autogen.el index 48c1de10..414486f6 100644 --- a/ecb-autogen.el +++ b/ecb-autogen.el @@ -146,8 +146,7 @@ does nothing." ;; XEmacs adds autom. the provide statement but for GNU Emacs we must do ;; this: (when (not ecb-running-xemacs) - (save-excursion - (set-buffer (find-file-noselect (expand-file-name ecb-autogen-file))) + (with-current-buffer (find-file-noselect (expand-file-name ecb-autogen-file)) (goto-char (point-min)) (when (not (re-search-forward (format "^(provide '%s)" ecb-autoload-feature) nil t)) diff --git a/ecb-common-browser.el b/ecb-common-browser.el index 164105dc..b986f6a3 100644 --- a/ecb-common-browser.el +++ b/ecb-common-browser.el @@ -2158,8 +2158,7 @@ the returned string: 'tree-buffer-image-start which holds 0 as value and value." (let ((image nil) (ret nil)) - (save-excursion - (set-buffer name-of-buffer) + (with-current-buffer name-of-buffer (setq image (and icon-name (tree-buffer-find-image icon-name))) (setq ret (if image diff --git a/ecb-compilation.el b/ecb-compilation.el index 5bb943dc..2feae952 100644 --- a/ecb-compilation.el +++ b/ecb-compilation.el @@ -220,8 +220,7 @@ either (if (ecb-compilation-registered-buffer-p (buffer-name buffer)) buffer ;;else test if this is a valid buffer by mode - (if (save-excursion - (set-buffer buffer) + (if (with-current-buffer buffer (member major-mode (ecb-compilation-major-modes))) buffer ;;else test if this is a regular compilation buffer diff --git a/ecb-eshell.el b/ecb-eshell.el index 52ff497b..ad9ecfad 100644 --- a/ecb-eshell.el +++ b/ecb-eshell.el @@ -272,8 +272,7 @@ ECB and if either this function is called interactively or ecb-eshell-buffer-list))) (my-reference-directory default-directory) (my-eshell-directory (and (bufferp my-eshell-buffer) - (save-excursion - (set-buffer my-eshell-buffer) + (with-current-buffer my-eshell-buffer default-directory)))) (when (and (bufferp my-eshell-buffer) (stringp my-reference-directory) @@ -281,8 +280,7 @@ ECB and if either this function is called interactively or (not (ecb-string= (ecb-fix-filename my-reference-directory) (ecb-fix-filename my-eshell-directory)))) (ecb-eshell-save-buffer-history - (save-excursion - (set-buffer my-eshell-buffer) + (with-current-buffer my-eshell-buffer ;; make sure we have a clean eshell-command-line (goto-char (point-max)) (eshell-bol) @@ -359,8 +357,7 @@ enlarge the compile-window over half of the frame-height and also not below (ecb-normalize-number ecb-compile-window-height (1- (frame-height)))) (ecb-enlarged-compilation-window-max-height - (max (min (save-excursion - (set-buffer (window-buffer ecb-compile-window)) + (max (min (with-current-buffer (window-buffer ecb-compile-window) ;; we want to see the old command line too and 2 ;; must be added because we have a modeline and one ;; empty line cause of the (recenter -2) in diff --git a/ecb-file-browser.el b/ecb-file-browser.el index 47aea4e8..d1e1102e 100644 --- a/ecb-file-browser.el +++ b/ecb-file-browser.el @@ -2377,8 +2377,7 @@ added.") (y-or-n-p "Remove history entry for this buffer?"))) ;; we must do this even when the history is not visible!! ;; the history should be always up-to-date - (save-excursion - (set-buffer ecb-history-buffer-name) + (with-current-buffer ecb-history-buffer-name (tree-buffer-remove-node node)) ;; if we have removed a node then we must ignore the related buffer ;; when rebuilding the history - otherwise the node would be added @@ -2408,8 +2407,7 @@ bucket)." (defun ecb-history-content-all-dead-buffers-alist () "Return alist with items \( . ) for dead buffers entries of the history-buffer." - (save-excursion - (set-buffer ecb-history-buffer-name) + (with-current-buffer ecb-history-buffer-name (delq nil (tree-node-map-subtree (tree-buffer-get-root) (function @@ -2532,8 +2530,7 @@ Returns t if the current history filter has been applied otherwise nil." (if ecb-running-xemacs 0))) (mode (symbol-name (if (ecb-buffer-obj (car elem)) - (save-excursion - (set-buffer (ecb-buffer-obj (car elem))) + (with-current-buffer (ecb-buffer-obj (car elem)) major-mode) ;; for dead buffers of the ;; history we use auto-mode-alist @@ -2562,8 +2559,7 @@ Returns t if the current history filter has been applied otherwise nil." ;; toplevel bucket of the history-buffer. This is the state before ;; rebuilding the history! (curr-bucket-expand-status-alist - (save-excursion - (set-buffer ecb-history-buffer-name) + (with-current-buffer ecb-history-buffer-name (delq nil (mapcar (function (lambda (node) (when (= (tree-node->type node) @@ -2579,8 +2575,7 @@ Returns t if the current history filter has been applied otherwise nil." ;; additonal-dead-history-buffer-alist ;; indirect-buffer-base ;; aggregated-indirect-buffers-alist) - (save-excursion - (set-buffer ecb-history-buffer-name) + (with-current-buffer ecb-history-buffer-name (tree-buffer-clear-tree) (dolist (bucket-elem aggregated-alist-with-buckets) (let* ((best-matching-sp (if (eq ecb-history-make-buckets 'directory-with-source-path) @@ -2726,8 +2721,7 @@ Returns t if the current history filter has been applied otherwise nil." (tree-buffer-update) (tree-buffer-highlight-node-by-data/name (ecb-path-selected-source))) (prog1 - (if (and (save-excursion - (set-buffer ecb-history-buffer-name) + (if (and (with-current-buffer ecb-history-buffer-name (tree-buffer-empty-p)) (not (ecb-history-filter-reset-p))) (progn @@ -2769,8 +2763,7 @@ indirect-buffer." ;; display the methods in the METHOD-buffer. We can not go back to ;; the edit-window because then the METHODS buffer would be ;; immediately updated with the methods of the edit-window. - (save-excursion - (set-buffer (ecb-source-get-buffer source)) + (with-current-buffer (ecb-source-get-buffer source) (ecb-path-selected-source-set (ecb-source-get-filename source) (buffer-name)) (ecb-update-methods-buffer--internal 'scroll-to-begin nil t t)) @@ -3352,6 +3345,25 @@ the SOURCES-cache." (require 'vc-bzr) 'BZR)) +;; Mercurial support +;; TODO: Klaus Berndl : if this works we should add it to +;; `ecb-vc-supported-backends'. + +(defun ecb-vc-dir-managed-by-HG (directory) + "Return 'GIT if DIRECTORY is managed by Mercurial. nil if not. +Because with Mercurial only the top-most directory of a source-tree has a subdir +.hg this function tries recursively upwards if there is a .hg-subdir." + ;; With XEmacs we must first load the vc-hooks which contain the function + ;; `vc-find-root' + (when ecb-running-xemacs + (ignore-errors (vc-load-vc-hooks))) + (and (locate-library "vc-hg") + (fboundp 'vc-find-root) + (vc-find-root directory ".hg") + (require 'vc) + (require 'vc-hg) + 'HG)) + ;; Git support (defun ecb-vc-dir-managed-by-GIT (directory) @@ -4482,8 +4494,7 @@ edit-windows. Otherwise return nil." ;; current buffer is always the history-buffer - we have to set ;; the buffer representing data (buf) as current buffer - otherwise ;; ecb-kill-buffer-hook would not run correctly - (save-excursion - (set-buffer buf) + (with-current-buffer buf (kill-buffer buf) (ecb-add-buffers-to-history-new))))) diff --git a/ecb-layout.el b/ecb-layout.el index 7348fa5b..68a01bf1 100644 --- a/ecb-layout.el +++ b/ecb-layout.el @@ -777,8 +777,7 @@ then set always nil!" (unless ecb-running-xemacs (let ((l (ecb-canonical-ecb-windows-list))) (dolist (w l) - (save-excursion - (set-buffer (window-buffer w)) + (with-current-buffer (window-buffer w) (setq window-size-fixed (if (and (not ecb-running-gnu-emacs-version-22) ecb-compile-window-height) nil @@ -6138,8 +6137,7 @@ Emacs)." (if (and (ecb-compile-window-live-p) (member ecb-compile-window-temporally-enlarge '(after-display both)) - (or (save-excursion - (set-buffer (window-buffer ecb-compile-window)) + (or (with-current-buffer (window-buffer ecb-compile-window) (equal major-mode 'compilation-mode)) (if ecb-running-xemacs temp-buffer-shrink-to-fit diff --git a/ecb-method-browser.el b/ecb-method-browser.el index 21efcd09..fb44f375 100644 --- a/ecb-method-browser.el +++ b/ecb-method-browser.el @@ -2066,8 +2066,7 @@ onto the whole tag-table are performed by `ecb-apply-tag-table-filters'.") &optional tag-class) "Filter the Methods-buffer by a tag-class." (let* ((curr-semantic-symbol->name-assoc-list - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (ecb--semantic-symbol->name-assoc-list))) (choice (or tag-class (ecb-query-string "Tag-class filter:" @@ -2253,13 +2252,11 @@ used; if point does not stay on a tag then nil is returned." "Display only the current-type and its contents in the methods-buffer. The argument INVERSE is ignored here." (let* ((curr-type-tag (or (and (ecb--semantic-tag-p tag) - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (ecb-get-type-tag-of-tag tag))) (cond ((ecb-point-in-edit-window-number) (if (ecb--semantic-active-p) - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (ecb-get-type-tag-of-tag (ecb-get-real-curr-tag))))) ((equal (current-buffer) (ecb-buffer-obj ecb-methods-buffer-name)) @@ -2268,8 +2265,7 @@ argument INVERSE is ignored here." (tree-node->data (ecb-get-type-node-of-node node))))) (t (ecb-error "ECB can not identify the current-type-tag!"))))) (curr-tag-type-name-hierachy (and curr-type-tag - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (ecb-get-type-name-hierarchy-of-current-tag curr-type-tag))))) (if (and curr-type-tag curr-tag-type-name-hierachy) @@ -2420,13 +2416,11 @@ applied default-tag-filters." (defun ecb-methods-filter-internal (inverse &optional filter-type) "FILTER-TYPE has to be one of the symbols 'regexp, 'protection, 'tag-class, 'curr-type, 'function, 'no-filter or 'delete-last." - (if (save-excursion - (set-buffer ecb-methods-buffer-name) + (if (with-current-buffer ecb-methods-buffer-name (tree-buffer-empty-p)) (message "There is nothing to filter in an empty Methods-buffer!") (let* ((source-buffer (ecb-get-source-buffer-for-tag-filter)) - (semantic-source-p (save-excursion - (set-buffer source-buffer) + (semantic-source-p (with-current-buffer source-buffer (ecb--semantic-active-p))) (choice (or filter-type (intern (ecb-query-string @@ -2466,8 +2460,7 @@ should be displayed in the modeline of the methods-buffer. If REMOVE-LAST is not nil then the topmost filter will be removed and all other arguments unless SOURCE-BUFFER arguments are ignored. Returns t if the filter has been applied otherwise nil." - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (if (and (not remove-last) (member filtertype '(protection tag-class curr-type)) (not (ecb--semantic-active-p))) @@ -2503,8 +2496,7 @@ otherwise nil." (setq ecb-methods-user-filter-alist (cons (cons source-buffer filters) ecb-methods-user-filter-alist))))) (when (buffer-live-p source-buffer) - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (if (ecb--semantic-active-p) ;; For semantic-sources we do not use `ecb-rebuild-methods-buffer)' ;; because this would always reparse the source-buffer even if not @@ -2514,8 +2506,7 @@ otherwise nil." (ecb-rebuild-methods-buffer-with-tagcache (ecb-fetch-semantic-tags))) (ecb-rebuild-methods-buffer-fully))) - (if (save-excursion - (set-buffer ecb-methods-buffer-name) + (if (with-current-buffer ecb-methods-buffer-name (tree-buffer-empty-p)) (progn (ecb-methods-filter-apply nil nil nil "" "" source-buffer t) @@ -2872,8 +2863,7 @@ partial reparse and update-mechanism." (let* ((id (ecb-overlay-get (ecb--semantic-tag-overlay tag-for-update) 'ECB-tree-node-id)) (node (when id - (save-excursion - (set-buffer ecb-methods-buffer-name) + (with-current-buffer ecb-methods-buffer-name (tree-node-search-subtree-by-id (tree-buffer-get-root) id)))) (data-parent (and node @@ -2892,8 +2882,7 @@ partial reparse and update-mechanism." (ecb-partial-reparse-debug "We update node for tag:%s with new name:%s" (ecb--semantic-tag-name tag-for-update) new-tag-name) - (save-excursion - (set-buffer ecb-methods-buffer-name) + (with-current-buffer ecb-methods-buffer-name (tree-buffer-update-node node new-tag-name 'use-old-value @@ -2943,8 +2932,7 @@ partial reparse and update-mechanism." "Return not nil if FILENAME is already displayed in a buffer and if semantic is active for this buffer." (and (get-file-buffer filename) - (save-excursion - (set-buffer (get-file-buffer filename)) + (with-current-buffer (get-file-buffer filename) (ecb--semantic-active-p)))) @@ -3127,8 +3115,7 @@ TABLE." (defun ecb-methods-get-data-store (key) "Get the value for KEY from the tree-buffer-data-store of the Methods-buffer." - (save-excursion - (set-buffer ecb-methods-buffer-name) + (with-current-buffer ecb-methods-buffer-name (cdr (assoc key (tree-buffer-get-data-store))))) @@ -3314,8 +3301,7 @@ to be rescanned/reparsed and therefore the Method-buffer will be rebuild too." ;; cache can not work because the buffer-string is a "copy" of the ;; tree-buffer and therefore the cached buffer-string can not be updated ;; automatically. - (save-excursion - (set-buffer ecb-methods-buffer-name) + (with-current-buffer ecb-methods-buffer-name ;; we store in the tree-buffer the buffer and the major-mode for which ;; the tree-buffer has been build. In no other place the data-store ;; will be set! @@ -3786,8 +3772,7 @@ file types which are parsed by imenu or etags \(see ;; expanded to max level... (when ecb-expand-methods-switch-off-auto-expand (ecb-toggle-auto-expand-tag-tree -1)) - (ecb-expand-methods-node-internal (save-excursion - (set-buffer ecb-methods-buffer-name) + (ecb-expand-methods-node-internal (with-current-buffer ecb-methods-buffer-name (tree-buffer-get-root)) level force-all t t))) @@ -3935,8 +3920,7 @@ This function is fully fitting the needs of the option ;; included file (unless destination (when (equal 'include (ecb--semantic-tag-class node-tag)) - (save-excursion - (set-buffer (ecb-path-selected-source 'buffer)) + (with-current-buffer (ecb-path-selected-source 'buffer) (let ((file (ecb--semantic-dependency-tag-file node-tag))) (when (and file (ecb-file-exists-p file)) (setq destination (list (ecb-source-make file) @@ -4303,8 +4287,7 @@ Returns current point." (defun ecb-methods-menu-activate-hs () "Activates `hs-minor-mode' in the buffer of `ecb-path-selected-source'. If this fails then nil is returned otherwise t." - (save-excursion - (set-buffer (get-file-buffer (ecb-path-selected-source 'file))) + (with-current-buffer (get-file-buffer (ecb-path-selected-source 'file)) (if (or (not (boundp 'hs-minor-mode)) (not hs-minor-mode)) (if (fboundp 'hs-minor-mode) @@ -4464,8 +4447,7 @@ edit-windows. Otherwise return nil." ;; we must not use here (ecb-methods-get-data-store ;; 'semantic-symbol->name-assoc-list) because we do not want the ;; function-prototypes... - (save-excursion - (set-buffer (ecb-methods-get-data-store 'source-buffer)) + (with-current-buffer (ecb-methods-get-data-store 'source-buffer) (ecb--semantic-symbol->name-assoc-list))) (prot-list '("private" "protected" "public")) (prot-menu-elems nil) @@ -4732,8 +4714,7 @@ moved over it." ;; we ca not use format here because XEmacs-format removes all ;; text-properties! (insert (concat (make-string indent ? ) - (save-excursion - (set-buffer source-buffer) + (with-current-buffer source-buffer (ecb--semantic-format-tag-uml-prototype tag parent t)) ", tag-class: " (format "%s" (ecb--semantic-tag-class tag)) diff --git a/ecb-mode-line.el b/ecb-mode-line.el index 79911c70..b9936fdd 100644 --- a/ecb-mode-line.el +++ b/ecb-mode-line.el @@ -326,8 +326,7 @@ as \"W-\"." (defun ecb-mode-line-update-buffer (buffer-name new-mode-line-format) "Update the given buffer...." (if (ecb-buffer-obj buffer-name) - (save-excursion - (set-buffer buffer-name) + (with-current-buffer buffer-name (setq mode-line-format new-mode-line-format) (if ecb-running-xemacs (redraw-modeline) diff --git a/ecb-navigate.el b/ecb-navigate.el index 358e7a6a..d0686728 100644 --- a/ecb-navigate.el +++ b/ecb-navigate.el @@ -189,8 +189,7 @@ case no position saving is done." (let ((tag-start (ecb-nav-get-tag-start item))) (if (and tag-start (marker-buffer tag-start)) (progn - (save-excursion - (set-buffer (marker-buffer tag-start)) + (with-current-buffer (marker-buffer tag-start) (ecb-nav-set-pos item (- (point) tag-start))) (ecb-nav-set-window-start item diff --git a/ecb-speedbar.el b/ecb-speedbar.el index 26ee9a34..06812841 100644 --- a/ecb-speedbar.el +++ b/ecb-speedbar.el @@ -410,8 +410,7 @@ future this could break." ecb-speedbar-buffer-name ecb-speedbar-buffer-sync t "Update the speedbar so that it's synced up with the current file." (let ((speedbar-default-directory - (save-excursion - (set-buffer visible-buffer) + (with-current-buffer visible-buffer (ecb-fix-filename default-directory))) (ecb-default-directory (ecb-fix-filename default-directory))) (when (and (or (not (ecb-string= speedbar-default-directory diff --git a/ecb-symboldef.el b/ecb-symboldef.el index 7806d151..919872be 100644 --- a/ecb-symboldef.el +++ b/ecb-symboldef.el @@ -250,8 +250,7 @@ EDIT-BUFFER is that buffer FSYMBOL is used." ;; describe-function-1 to print all its output to this buffer. (let ((standard-output (get-buffer-create ecb-symboldef-temp-buffer-name)) (doc-string nil)) - (save-excursion - (set-buffer standard-output) + (with-current-buffer standard-output ;;(insert (symbol-name symbol)) (describe-function-1 fsymbol) (setq doc-string (buffer-string))) @@ -276,20 +275,21 @@ EDIT-BUFFER is that buffer VSYMBOL is used." ;; 3. setting temp-buffer-setup-hook to nil ;; 3. Binding standart-output to a temporally buffer-object ;; 4. running describe-variable - (save-excursion - (set-buffer edit-buffer) + (with-current-buffer edit-buffer (let ((standard-output (get-buffer-create ecb-symboldef-temp-buffer-name)) (temp-buffer-setup-hook nil) ;; this does not call temp-buffer-show-hook!!! (temp-buffer-show-function (function (lambda (b) nil)))) (flet ((help-buffer () ecb-symboldef-temp-buffer-name) - (print-help-return-message (&optional function) nil) + ;; (print-help-return-message (&optional function) nil) ;; for XEmacs (help-buffer-name () ecb-symboldef-temp-buffer-name)) - (describe-variable vsymbol)) + ;; we can not use flet for redefining print-help-return-message + ;; because the byte-compailer would complain about this. + (labels ((print-help-return-message (&optional function) nil)) + (describe-variable vsymbol))) )) - (save-excursion - (set-buffer ecb-symboldef-temp-buffer-name) + (with-current-buffer ecb-symboldef-temp-buffer-name (when (member 'eieio-help-mode-augmentation-maybee temp-buffer-show-hook) (let ((major-mode 'help-mode)) (eieio-help-mode-augmentation-maybee))) @@ -344,8 +344,7 @@ list containing point. If that doesn't give a function, return nil." ;; - display function around ;; - display conditions for function symbols (length, regexp to match) (when (setq fsymbol - (save-excursion - (set-buffer edit-buffer) + (with-current-buffer edit-buffer (ecb-symboldef-function-at-point))) (unless ecb-running-xemacs ;; With XEmacs the symbol itself is already contained in the @@ -503,8 +502,7 @@ list containing point. If that doesn't give a function, return nil." (defun ecb-symboldef-find-tag-by-semanticdb (symbol-name edit-buffer) "Function to find a semantic-tag by SYMBOL-NAME. Returns nil if not found otherwise a list \(tag-buffer tag-begin tag-end)" - (save-excursion - (set-buffer edit-buffer) + (with-current-buffer edit-buffer (let* ((mytag-list (ecb--semanticdb-brute-deep-find-tags-by-name symbol-name nil t)) (mytag (if mytag-list @@ -555,14 +553,14 @@ with semanticdb and then - if no success - with current etags-file." (hilight-point-max nil)) (setq truncate-lines t) (when tag-buf - (save-excursion - (set-buffer tag-buf) - (goto-char tag-point) - (forward-line (- num-tag-lines)) - (setq extend-point-min (point)) - (forward-line num-tag-lines) - (forward-line num-tag-lines) - (setq extend-point-max (point))) + (with-current-buffer tag-buf + (save-excursion + (goto-char tag-point) + (forward-line (- num-tag-lines)) + (setq extend-point-min (point)) + (forward-line num-tag-lines) + (forward-line num-tag-lines) + (setq extend-point-max (point)))) (insert (ecb-buffer-substring extend-point-min extend-point-max tag-buf)) (goto-char (+ (- tag-point extend-point-min) 1)) (setq hilight-point-min (point)) diff --git a/ecb-util.el b/ecb-util.el index be8cc06e..06f8f4ab 100644 --- a/ecb-util.el +++ b/ecb-util.el @@ -1665,8 +1665,7 @@ BUFFER \(not read-only an evaluation-time of BODY) and make afterwards BUFFER read-only. Note: All this is done with `save-excursion' so after BODY that buffer is current which was it before calling this macro." `(if (buffer-live-p ,buffer) - (save-excursion - (set-buffer ,buffer) + (with-current-buffer ,buffer (unwind-protect (progn (setq buffer-read-only nil) @@ -1796,8 +1795,7 @@ nil whereas in the latter case the current-buffer is assumed." (or (and file (file-readable-p file)) (and (not ecb-running-xemacs) (if filename - (save-excursion - (set-buffer (find-file-noselect filename)) + (with-current-buffer (find-file-noselect filename) (ecb-current-buffer-archive-extract-p)) (ecb-current-buffer-archive-extract-p)))))) @@ -2020,6 +2018,20 @@ nothing happens and nil is returned." (select-window window) nil))) + +;; (defmacro ecb-exec-in-window (buffer-or-name &rest body) +;; "Evaluates BODY in that window which displays the buffer BUFFER-OR-NAME +;; which can be either a buffer-object or a buffer-name. If that window is not +;; visible then BODY is not evaluated and the symbol 'window-not-visible is +;; returned. Otherwise the return value of BODY is returned. Runs encapsulated in +;; `save-selected-window' and `save-excursion'." +;; `(save-selected-window +;; (if (not (ecb-window-select ,buffer-or-name)) +;; 'window-not-visible +;; (save-excursion +;; (set-buffer ,buffer-or-name) +;; ,@body)))) + (defmacro ecb-exec-in-window (buffer-or-name &rest body) "Evaluates BODY in that window which displays the buffer BUFFER-OR-NAME which can be either a buffer-object or a buffer-name. If that window is not @@ -2029,8 +2041,7 @@ returned. Otherwise the return value of BODY is returned. Runs encapsulated in `(save-selected-window (if (not (ecb-window-select ,buffer-or-name)) 'window-not-visible - (save-excursion - (set-buffer ,buffer-or-name) + (with-current-buffer ,buffer-or-name ,@body)))) (put 'ecb-exec-in-window 'lisp-indent-function 1) diff --git a/ecb.el b/ecb.el index 35adfbfb..e97f7ffd 100644 --- a/ecb.el +++ b/ecb.el @@ -1353,8 +1353,7 @@ value of VAR is as before storing a NEW-VALUE for variable-symbol VAR." ;; menus - dealing with the menu for XEmacs is really a pain... (when ecb-running-xemacs (let ((dummy-buf-name " *dummytogetglobalmap*")) - (save-excursion - (set-buffer (get-buffer-create dummy-buf-name)) + (with-current-buffer (get-buffer-create dummy-buf-name) (add-submenu nil ecb-minor-menu) (kill-buffer dummy-buf-name))) (save-excursion @@ -1437,8 +1436,7 @@ value of VAR is as before storing a NEW-VALUE for variable-symbol VAR." (null (ecb-buffer-file-name (window-buffer edit-window)))) (ecb-set-selected-directory - (ecb-fix-filename (save-excursion - (set-buffer (window-buffer edit-window)) + (ecb-fix-filename (with-current-buffer (window-buffer edit-window) default-directory))))) (error (ecb-clean-up-after-activation-failure diff --git a/tree-buffer.el b/tree-buffer.el index 5672efe7..81dab3de 100644 --- a/tree-buffer.el +++ b/tree-buffer.el @@ -1421,8 +1421,7 @@ to test NODE-DATA-1 and NODE-DATA-2 for equality." (frame-width))) (click-col (+ (/ (* 10 x-point) pixels-per-10-col) (if include-fringe-scrollbar - (length (save-excursion - (set-buffer (tree-buffer-event-buffer e)) + (length (with-current-buffer (tree-buffer-event-buffer e) (tree-buffer-spec->sticky-indent-string tree-buffer-spec))) 0)))) @@ -1630,13 +1629,12 @@ nil is returned." (defun tree-buffer-help-echo-fn (win obj pos) "This function is the value of the `help-echo' property of each -tree-node. This is only used with GNU Emacs 21!" +tree-node. This is only used with GNU Emacs >= 21!" (let* ((window win) (position pos) (buffer (window-buffer window)) node) - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (setq node (tree-buffer-get-node-at-point position)) (and (tree-buffer-spec->node-mouse-over-fn tree-buffer-spec) node @@ -2622,16 +2620,14 @@ functionality is done with the `help-echo'-property and the function `tree-buffer-help-echo-fn'!" (when tree-buffer-running-xemacs (dolist (buf tree-buffers) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (add-hook 'mode-motion-hook 'tree-buffer-follow-mouse))))) (defun tree-buffer-deactivate-follow-mouse () "Complementary function to `tree-buffer-activate-follow-mouse'." (when tree-buffer-running-xemacs (dolist (buf tree-buffers) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (remove-hook 'mode-motion-hook 'tree-buffer-follow-mouse))))) ;; pressed keys