* url-util.el (url-insert-entities-in-string):
[bpt/emacs.git] / lisp / emulation / viper-util.el
index af50b51..503265c 100644 (file)
@@ -1,16 +1,16 @@
 ;;; viper-util.el --- Utilities used by viper.el
 
 ;; Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +18,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 (require 'viper-init)
 
 
-;; A fix for NeXT Step
-;; Should go away, when NS people fix the design flaw, which leaves the
-;; two x-* functions undefined.
-(if (and (not (fboundp 'x-display-color-p)) (fboundp 'ns-display-color-p))
-    (fset 'x-display-color-p (symbol-function 'ns-display-color-p)))
-(if (and (not (fboundp 'x-color-defined-p)) (fboundp 'ns-color-defined-p))
-      (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p)))
-
 \f
 (defalias 'viper-overlay-p
   (if (featurep 'xemacs) 'extentp 'overlayp))
@@ -206,7 +196,7 @@ Otherwise return the normal value."
               color)))))))
 
 
-(defsubst viper-get-saved-cursor-color-in-replace-mode ()
+(defun viper-get-saved-cursor-color-in-replace-mode ()
   (or
    (funcall
     (if (featurep 'emacs) 'frame-parameter 'frame-property)
@@ -216,7 +206,7 @@ Otherwise return the normal value."
            (viper-frame-value viper-emacs-state-cursor-color))
        (viper-frame-value viper-vi-state-cursor-color))))
 
-(defsubst viper-get-saved-cursor-color-in-insert-mode ()
+(defun viper-get-saved-cursor-color-in-insert-mode ()
   (or
    (funcall
     (if (featurep 'emacs) 'frame-parameter 'frame-property)
@@ -226,7 +216,7 @@ Otherwise return the normal value."
            (viper-frame-value viper-emacs-state-cursor-color))
        (viper-frame-value viper-vi-state-cursor-color))))
 
-(defsubst viper-get-saved-cursor-color-in-emacs-mode ()
+(defun viper-get-saved-cursor-color-in-emacs-mode ()
   (or
    (funcall
     (if (featurep 'emacs) 'frame-parameter 'frame-property)
@@ -407,11 +397,10 @@ Otherwise return the normal value."
 ;;; Support for :e, :r, :w file globbing
 
 ;; Glob the file spec.
-;; This function is designed to work under Unix.  It might also work under VMS.
+;; This function is designed to work under Unix.
 (defun viper-glob-unix-files (filespec)
   (let ((gshell
         (cond (ex-unix-type-shell shell-file-name)
-              ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VAX VMS
               (t "sh"))) ; probably Unix anyway
        (gshell-options
         ;; using cond in anticipation of further additions
@@ -420,8 +409,7 @@ Otherwise return the normal value."
        (command (cond (viper-ms-style-os-p (format "\"ls -1 -d %s\"" filespec))
                       (t (format "ls -1 -d %s" filespec))))
        status)
-    (save-excursion
-      (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
+    (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
       (erase-buffer)
       (setq status
            (if gshell-options
@@ -478,8 +466,7 @@ Otherwise return the normal value."
 
 ;; convert MS-DOS wildcards to regexp
 (defun viper-wildcard-to-regexp (wcard)
-  (save-excursion
-    (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
+  (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
     (erase-buffer)
     (insert wcard)
     (goto-char (point-min))
@@ -499,8 +486,7 @@ Otherwise return the normal value."
 (defun viper-glob-mswindows-files (filespec)
   (let ((case-fold-search t)
        tmp tmp2)
-    (save-excursion
-      (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
+    (with-current-buffer (get-buffer-create viper-ex-tmp-buf-name)
       (erase-buffer)
       (insert filespec)
       (goto-char (point-min))
@@ -665,8 +651,7 @@ Otherwise return the normal value."
         (buf (find-file-noselect (substitute-in-file-name custom-file)))
        )
     (message "%s" (or message ""))
-    (save-excursion
-      (set-buffer buf)
+    (with-current-buffer buf
       (goto-char (point-min))
       (if (re-search-forward regexp nil t)
          (let ((reg-end (1- (match-end 0))))
@@ -689,8 +674,7 @@ Otherwise return the normal value."
 ;; match this pattern.
 (defun viper-save-string-in-file (string custom-file &optional pattern)
   (let ((buf (find-file-noselect (substitute-in-file-name custom-file))))
-    (save-excursion
-      (set-buffer buf)
+    (with-current-buffer buf
       (let (buffer-read-only)
        (goto-char (point-min))
        (if pattern (delete-matching-lines pattern))
@@ -900,8 +884,7 @@ Otherwise return the normal value."
   (if (and (markerp marker) (marker-buffer marker))
       (let ((buf (marker-buffer marker))
            (pos (marker-position marker)))
-       (save-excursion
-         (set-buffer buf)
+       (with-current-buffer buf
          (and (<= pos (point-max)) (<= (point-min) pos))))))
 
 (defsubst viper-mark-marker ()
@@ -950,10 +933,10 @@ Otherwise return the normal value."
     event))
 
 ;; Uses different timeouts for ESC-sequences and others
-(defsubst viper-fast-keysequence-p ()
+(defun viper-fast-keysequence-p ()
   (not (viper-sit-for-short
        (if (viper-ESC-event-p last-input-event)
-           viper-ESC-keyseq-timeout
+           (viper-ESC-keyseq-timeout)
          viper-fast-keyseq-timeout)
        t)))
 
@@ -1560,9 +1543,9 @@ This option is appropriate if you like Emacs-style words."
 
 
 
-;;; Local Variables:
-;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
-;;; End:
+;; Local Variables:
+;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
+;; End:
 
 ;; arch-tag: 7f023fd5-dd9e-4378-a397-9c179553b0e3
 ;;; viper-util.el ends here