; ;;
; ))
-(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 ;;
;; 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)
;; 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
;; 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.
'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))))
;; -- 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
;; 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)
;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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!
;(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
;; 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
;;; 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
;;; 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
;; 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)
)
;;; 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")
;;; ********************
; tell it not to assume that "binary" files
; are encrypted and require a password.
)
-(Init-safe-require 'crypt)
+(require 'crypt)
;;; ********************
;;; 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)
;;; ********************
; (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*
;;; 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)
;;; 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)
;;; 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)
;;; ********************