This commit was generated by cvs2svn to compensate for changes in r5197,
[chise/xemacs-chise.git.1] / etc / sample.init.el
index da2e18c..ef6ec7f 100644 (file)
@@ -226,14 +226,6 @@ argument are optional. Only the Non-nil arguments are used in the test."
 ;        ;;
 ;        ))
 
-(defun Init-safe-require (feat)
-"Try to REQUIRE the specified feature.  Errors occurring are silenced.
-\(Perhaps in the future there will be a way to get at the error.)
-Returns t if the feature was successfully required."
-  (condition-case nil
-      (progn (require feat) t)
-    (error nil)))
-
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;                          Key Definitions                         ;;
@@ -281,12 +273,6 @@ Returns t if the feature was successfully required."
 ;; the line, but that messes up the common idiom `f8 move-cursor f4'.
 
 (defun Init-kill-entire-line (&optional arg)
-"Kill the entire line.
-With prefix argument, kill that many lines from point.  Negative
-arguments kill lines backward.
-
-When calling from a program, nil means \"no arg\",
-a number counts as a prefix arg."
   (interactive "*P")
   (let ((kill-whole-line t))
     (beginning-of-line)
@@ -623,11 +609,14 @@ backward, and defaults to 1.  Buffers whose name begins with a space
 
 ;; Make sure we get Windows-like shifted-motion key selection behavior
 ;; on recent XEmacs versions.
-(cond ((boundp 'shifted-motion-keys-select-region)
-       (setq shifted-motion-keys-select-region t))
-      ;; otherwise, try the pc-select package -- 
-      ((Init-safe-require 'pc-select)
-       (pc-select-mode 1)))
+(if (boundp 'shifted-motion-keys-select-region)
+    (setq shifted-motion-keys-select-region t)
+  ;; otherwise, try the pc-select package -- 
+  (condition-case nil
+      (progn
+       (require 'pc-select)
+       (pc-select-mode 1))
+    (error nil)))
 
 ;; The following commented-out code rearranges the keymap in an
 ;; unconventional but extremely useful way for programmers.  Parens
@@ -660,13 +649,6 @@ backward, and defaults to 1.  Buffers whose name begins with a space
 ;; Useful programming-related keystrokes.
 
 (defun describe-foo-at-point ()
-  "Show the documentation of the Elisp function and variable near point.
-This checks in turn:
-
--- for a function name where point is
--- for a variable name where point is
--- for a surrounding function call
-"
   (interactive)
   (let (sym)
     ;; sigh, function-at-point is too clever.  we want only the first half.
@@ -765,86 +747,42 @@ This lets you figure out where time is being spent when executing Lisp code."
   'kill-current-buffer-and-window)
 
 (defun kill-current-buffer ()
-  "Kill the current buffer (prompting if it is modified)."
   (interactive)
   (kill-buffer (current-buffer)))
 
 (defun kill-current-buffer-and-window ()
-  "Kill the current buffer (prompting if it is modified) and its window."
   (interactive)
   (kill-buffer (current-buffer))
   (delete-window))
 
-(defvar grep-all-files-history nil)
-
-(defvar grep-all-files-omitted-expressions
-  '("*~" "#*" ".#*" ",*" "*.elc" "*.obj" "*.o" "*.exe" "*.dll" "*.lib" "*.a"
-    "*.dvi" "*.class" "*.bin")
-  "List of expressions matching files to be omitted in `grep-all-files-...'.
-Each entry should be a simple name or a shell wildcard expression.")
-
-(defvar grep-all-files-omitted-directories '("CVS" "RCS" "SCCS")
-  "List of directories not to recurse into in `grep-all-files-...'.
-Each entry should be a simple name or a shell wildcard expression.")
-
-(defun construct-grep-all-files-command (find-segment grep-segment)
-  (let ((omit-annoying
-        (mapconcat #'(lambda (wildcard)
-                       (concat "-name '" wildcard "' -or "))
-                   grep-all-files-omitted-expressions
-                   "")))
-    (cond ((eq grep-find-use-xargs 'gnu)
-          (format "find . %s %s -type f -print0 | xargs -0 -e %s"
-                  find-segment omit-annoying grep-segment))
-         (grep-find-use-xargs
-          (format "find . %s %s -type f -print | xargs %s"
-                  find-segment omit-annoying grep-segment))
-         (t
-          (format "find . %s %s -type f -exec %s {} /dev/null \\;"
-                  find-segment omit-annoying grep-segment)))))
-
-(defun grep-all-files-in-current-directory (command)
-  "Run `grep' in all non-annoying files in the current directory.
-`Non-annoying' excludes backup files, autosave files, CVS merge files, etc.
-More specifically, this is controlled by `grep-all-files-omitted-expressions'.
-
-This function does not recurse into subdirectories.  If you want this,
-use \\[grep-all-files-in-current-directory-and-below]."
-  (interactive
-   (progn
-     (require 'compile)
-     (list (read-shell-command "Run grep (like this): "
-                              grep-command 'grep-all-files-history))))
+(defun grep-c-files ()
+  (interactive)
   (require 'compile)
-  (grep (construct-grep-all-files-command
-        "-name . -or -type d -prune -or" command)))
-
-(defun grep-all-files-in-current-directory-and-below (command)
-  "Run `grep' in all non-annoying files in the current directory and below.
-`Non-annoying' excludes backup files, autosave files, CVS merge files, etc.
-More specifically, this is controlled by `grep-all-files-omitted-expressions'.
-
-This function recurses into subdirectories.  If you do not want this,
-use \\[grep-all-files-in-current-directory]."
-  (interactive
-   (progn
-     (require 'compile)
-     (list (read-shell-command "Run grep (like this): "
-                              grep-command 'grep-all-files-history))))
+  (let ((grep-command
+        (cons (concat grep-command " *.[chCH]"
+                                       ; i wanted to also use *.cc and *.hh.
+                                       ; see long comment below under Perl.
+                      )
+              (length grep-command))))
+    (call-interactively 'grep)))
+
+(defun grep-lisp-files ()
+  (interactive)
   (require 'compile)
-  (grep (construct-grep-all-files-command
-        ;; prune all specified directories.
-        (mapconcat #'(lambda (wildcard)
-                       (concat "-name '" wildcard "' -prune -or "))
-                   grep-all-files-omitted-directories
-                   "")
-        command)))
+  (let ((grep-command
+        (cons (concat grep-command " *.el"
+                                       ; i wanted to also use *.cc and *.hh.
+                                       ; see long comment below under Perl.
+                      )
+              (length grep-command))))
+    (call-interactively 'grep)))
+
+;; This repeatedly selects larger and larger balanced expressions
+;; around the cursor.  Once you have such an expression marked, you
+;; can expand to the end of the following expression with C-M-SPC and
+;; to the beginning of the previous with M-left.
 
 (defun clear-select ()
-  "Repeatedly select ever larger balanced expressions around the cursor.
-Once you have such an expression marked, you can expand to the end of
-the following expression with \\[mark-sexp] and to the beginning of the
-previous with \\[backward-sexp]."
   (interactive "_") ;this means "preserve the active region after this command"
   (backward-up-list 1)
   (let ((end (save-excursion (forward-sexp) (point))))
@@ -854,8 +792,8 @@ previous with \\[backward-sexp]."
 ;; -- always reports as /. #### this should be fixable.
 (global-set-key 'kp-add 'query-replace)
 (global-set-key '(shift kp-add) 'query-replace-regexp)
-(global-set-key '(control kp-add) 'grep-all-files-in-current-directory)
-(global-set-key '(meta kp-add) 'grep-all-files-in-current-directory-and-below)
+(global-set-key '(control kp-add) 'grep-c-files)
+(global-set-key '(meta kp-add) 'grep-lisp-files)
 (global-set-key 'clear 'clear-select)
 ;; Note that you can use a "lambda" expression (an anonymous function)
 ;; in place of a function name.  This function would be called
@@ -865,7 +803,7 @@ previous with \\[backward-sexp]."
 ;; buffer, etc.).
 (global-set-key 'kp-enter (lambda () (interactive) (set-mark-command t)))
 (global-set-key '(shift kp-enter) 'repeat-complex-command)
-(global-set-key 'pause 'repeat-complex-command) ;; useful on Windows-style kbds
+(global-set-key 'pause 'repeat-complex-command) ;; useful on Windows-stlye kbds
 (global-set-key '(control kp-enter) 'eval-expression)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;
@@ -934,8 +872,11 @@ previous with \\[backward-sexp]."
 ;;; rather than append -- standard behavior under all window systems
 ;;; nowadays.
 
-(if (fboundp 'pending-delete-mode)
-    (pending-delete-mode 1))
+(pending-delete-mode 1)
+
+;;; enable region selection with shift+arrows (on by default in 21.5
+;;; and up)
+(setq shifted-motion-keys-select-region t)
 
 ;;; NOTE: In this context, `windows-nt' actually refers to all MS
 ;;; Windows operating systems!
@@ -948,33 +889,15 @@ previous with \\[backward-sexp]."
   ;(setq user-full-name "Ben Wing")
   ;(setq smtpmail-smtp-server "pop.tcsn.uswest.net")
 
-  ;; Make Meta+accelerator traverse to the menu in new enough XEmacs
+  ;; Make Alt+accelerator traverse to the menu in new enough XEmacs
   ;; versions.  Note that this only overrides Meta bindings that would
-  ;; actually invoke a menu, and the most common commands that are
-  ;; overridden have preferred alternative bindings using the arrow
-  ;; keys.  You can always access the overridden ones using
-  ;; Shift+Meta+Key. (Note that "Alt" and "Meta" normally refer to the
-  ;; same key, except on some Sun keyboards [where "Meta" is actually
-  ;; labelled with a diamond] or if you have explicitly made them
-  ;; different under X Windows using `xmodmap'.)
-  ;;
-  ;; More specifically, the following bindings are overridden:
-  ;;
-  ;; M-f               (use C-right or Sh-M-f instead)
-  ;; M-e               (use M-C-right or Sh-M-e instead)
-  ;; M-v               (use Prior aka PgUp or Sh-M-v instead)
-  ;; M-m               (use Sh-M-m instead)
-  ;; M-t               (use Sh-M-t instead)
-  ;; M-o               (normally undefined)
-  ;; M-b               (use C-left or Sh-M-b instead)
-  ;; M-h               (use M-e h or Sh-M-h instead)
-  ;; in Lisp mode, M-l (use Sh-M-l instead)
-  ;; in C mode, M-c    (use Sh-M-c instead)
-
+  ;; actually invoke a menu, and that none of the most common commands
+  ;; are overridden.  You can use ESC+key to access the overridden
+  ;; ones if necessary.
   (setq menu-accelerator-enabled 'menu-force)
 
   ;; Make Cygwin `make' work inside a shell buffer.
-  (if (boundp 'setenv) (setenv "MAKE_MODE" "UNIX")))
+  (setenv "MAKE_MODE" "UNIX"))
 
 ;; This shows how to set up the XEmacs side of tags. (To create the
 ;; TAGS table, use the `etags' program found in the XEmacs bin
@@ -1025,20 +948,16 @@ previous with \\[backward-sexp]."
 ;; has a NetAudio or ESD server, or on the console of a Linux, Sparc,
 ;; HP, or SGI machine.  Otherwise, you just get the standard beep.)
 
-(cond ((and (fboundp 'load-default-sounds)
-           (or (and (getenv "DISPLAY") 
-                    (string-match ":0" (getenv "DISPLAY")))
-               (and (eq (console-type) 'mswindows)
-                    (device-sound-enabled-p))))
-       (condition-case nil
-          (progn
-            (load-default-sounds)
-            ;; On Windows, at least, the sound "quiet-beep", which is normally
-            ;; given the symbolic name `quiet' and is used for Quit and such,
-            ;; is just totally disgusting.  So make this name correspond to a
-            ;; more innocuous sound.
-            (load-sound-file "drum-beep" 'quiet 80))
-        (error nil)))
+(cond ((or (and (getenv "DISPLAY") 
+               (string-match ":0" (getenv "DISPLAY")))
+          (and (eq (console-type) 'mswindows)
+               (device-sound-enabled-p)))
+       (load-default-sounds)
+       ;; On Windows, at least, the sound "quiet-beep", which is normally
+       ;; given the symbolic name `quiet' and is used for Quit and such,
+       ;; is just totally disgusting.  So make this name correspond to a
+       ;; more innocuous sound.
+       (load-sound-file "drum-beep" 'quiet 80))
       (t
        (setq bell-volume 40)
        (setq sound-alist
@@ -1188,15 +1107,49 @@ previous with \\[backward-sexp]."
 ;;; When this is loaded, the pathname syntax /user@host:/remote/path
 ;;; refers to files accessible through ftp.
 ;;;
-(Init-safe-require 'dired)
+(require 'dired)
+;; compatible ange-ftp/efs initialization derived from code
+;; from John Turner <turner@lanl.gov>
+;;
+;; The environment variable EMAIL_ADDRESS is used as the password
+;; for access to anonymous ftp sites, if it is set.  If not, one is
+;; constructed using the environment variables USER and DOMAINNAME
+;; (e.g. turner@lanl.gov), if set.
+
+(condition-case nil
+    (progn
+      (require 'efs-auto)
+      (if (getenv "USER")
+         (setq efs-default-user (getenv "USER")))
+      (if (getenv "EMAIL_ADDRESS")
+         (setq efs-generate-anonymous-password (getenv "EMAIL_ADDRESS"))
+       (if (and (getenv "USER")
+                (getenv "DOMAINNAME"))
+           (setq efs-generate-anonymous-password
+                 (concat (getenv "USER")"@"(getenv "DOMAINNAME")))))
+      (setq efs-auto-save 1))
+  (error
+   (require 'ange-ftp)
+   (if (getenv "USER")
+       (setq ange-ftp-default-user (getenv "USER")))
+   (if (getenv "EMAIL_ADDRESS")
+       (setq ange-ftp-generate-anonymous-password (getenv "EMAIL_ADDRESS"))
+     (if (and (getenv "USER")
+             (getenv "DOMAINNAME"))
+        (setq ange-ftp-generate-anonymous-password
+              (concat (getenv "USER")"@"(getenv "DOMAINNAME")))))
+   (setq ange-ftp-auto-save 1)
+   ))
 
-(or (Init-safe-require 'efs-auto) (Init-safe-require 'ange-ftp))
 
 ;;; ********************
 ;;; Load the default-dir.el package which installs fancy handling of
 ;;; the initial contents in the minibuffer when reading file names.
-;; #### but it seems to cause some breakage.
-;(Init-safe-require 'default-dir))
+
+;(condition-case nil
+;    (require 'default-dir)
+;  (error nil))
+
 
 ;;; ********************
 ;;; Put all of your autosave files in one place, instead of scattering
@@ -1207,9 +1160,9 @@ previous with \\[backward-sexp]."
 ;;; is fast fast fast!)
 ;;;
 ;;; Unfortunately, the code that implements this (auto-save.el) is
-;;; broken on Windows prior to 21.4.
+;;; broken on Windows in 21.4 and earlier.
 (unless (and (eq system-type 'windows-nt)
-            (not (emacs-version>= 21 4)))
+            (not (emacs-version>= 21 5)))
   (setq auto-save-directory (expand-file-name "~/.autosave/")
        auto-save-directory-fallback auto-save-directory
        auto-save-hash-p nil
@@ -1219,6 +1172,9 @@ previous with \\[backward-sexp]."
        ;; for better interactive response.
        auto-save-interval 2000
        )
+  ;; We load this afterwards because it checks to make sure the
+  ;; auto-save-directory exists (creating it if not) when it's loaded.
+  (require 'auto-save)
   )
 
 
@@ -1242,7 +1198,7 @@ previous with \\[backward-sexp]."
 ;;; because there are no other commands whose first three words begin with
 ;;; the letters `b', `c', and `a' respectively.
 ;;;
-(Init-safe-require 'completer)
+(load-library "completer")
 
 
 ;;; ********************
@@ -1256,7 +1212,7 @@ previous with \\[backward-sexp]."
                                   ; tell it not to assume that "binary" files
                                   ; are encrypted and require a password.
       )
-(Init-safe-require 'crypt)
+(require 'crypt)
 
 
 ;;; ********************
@@ -1264,11 +1220,9 @@ previous with \\[backward-sexp]."
 ;;; makes filling (e.g. using M-q) much much smarter about paragraphs
 ;;; that are indented and/or are set off with semicolons, dashes, etc.
 
-(Init-safe-require 'filladapt)
+(require 'filladapt)
 (setq-default filladapt-mode t)
-(when (fboundp 'turn-off-filladapt-mode)
-  (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
-  (add-hook 'outline-mode-hook 'turn-off-filladapt-mode))
+(add-hook 'c-mode-hook 'turn-off-filladapt-mode)
 
 
 ;;; ********************
@@ -1295,7 +1249,7 @@ previous with \\[backward-sexp]."
 ;       (setq font-lock-use-default-fonts nil)
 ;       (setq font-lock-use-default-colors nil)
 
-       (Init-safe-require 'font-lock)
+       (require 'font-lock)
 
 ;       ;; Mess around with the faces a bit.  Note that you have
 ;       ;; to change the font-lock-use-default-* variables *before*
@@ -1331,12 +1285,10 @@ previous with \\[backward-sexp]."
 ;;; accurate as using full font-lock or fast-lock, but it's *much*
 ;;; faster.  No more annoying pauses when you load files.
 
-(if (fboundp 'turn-on-lazy-lock)
-    (add-hook 'font-lock-mode-hook 'turn-on-lazy-lock))
-
+(add-hook 'font-lock-mode-hook 'turn-on-lazy-lock)
 ;; I personally don't like "stealth mode" (where lazy-lock starts
 ;; fontifying in the background if you're idle for 30 seconds)
-;; because it takes too long to wake up again.
+;; because it takes too long to wake up again on my piddly Sparc 1+.
 (setq lazy-lock-stealth-time nil)
 
 
@@ -1350,7 +1302,8 @@ previous with \\[backward-sexp]."
 ;;; Send bug reports, enhancements etc to:
 ;;; David Hughes <ukchugd@ukpmr.cs.philips.nl>
 ;;;
-(cond ((and running-xemacs (Init-safe-require 'func-menu))
+(cond (running-xemacs
+       (require 'func-menu)
        (global-set-key '(shift f12) 'function-menu)
        (add-hook 'find-file-hooks 'fume-add-menubar-entry)
        (global-set-key "\C-cl" 'fume-list-functions)
@@ -1401,16 +1354,16 @@ previous with \\[backward-sexp]."
 ;;; resize-minibuffer-mode makes the minibuffer automatically
 ;;; resize as necessary when it's too big to hold its contents.
 
-(when (fboundp 'resize-minibuffer-mode)
-  (resize-minibuffer-mode)
-  (setq resize-minibuffer-window-exactly nil))
+(autoload 'resize-minibuffer-mode "rsz-minibuf" nil t)
+(resize-minibuffer-mode)
+(setq resize-minibuffer-window-exactly nil)
 
 
 ;;; ********************
 ;;; scroll-in-place is a package that keeps the cursor on the same line (and in the same column) when scrolling by a page using PgUp/PgDn.
 
-(if (Init-safe-require 'scroll-in-place)
-    (turn-on-scroll-in-place))
+(require 'scroll-in-place)
+(turn-on-scroll-in-place)
 
 
 ;;; ********************