comparison etc/sample.init.el @ 464:5aa1854ad537 r21-2-47

Import from CVS: tag r21-2-47
author cvs
date Mon, 13 Aug 2007 11:45:51 +0200
parents 0784d089fdc9
children 52626a2f02ef
comparison
equal deleted inserted replaced
463:a158004111cd 464:5aa1854ad537
271 271
272 ;; I considered having this retain the current column after killing 272 ;; I considered having this retain the current column after killing
273 ;; the line, but that messes up the common idiom `f8 move-cursor f4'. 273 ;; the line, but that messes up the common idiom `f8 move-cursor f4'.
274 274
275 (defun Init-kill-entire-line (&optional arg) 275 (defun Init-kill-entire-line (&optional arg)
276 "Kill the entire line.
277 With prefix argument, kill that many lines from point. Negative
278 arguments kill lines backward.
279
280 When calling from a program, nil means \"no arg\",
281 a number counts as a prefix arg."
276 (interactive "*P") 282 (interactive "*P")
277 (let ((kill-whole-line t)) 283 (let ((kill-whole-line t))
278 (beginning-of-line) 284 (beginning-of-line)
279 (call-interactively 'kill-line))) 285 (call-interactively 'kill-line)))
280 286
647 ;;;;;;;;;;;;;;;;;;;;;;;; 653 ;;;;;;;;;;;;;;;;;;;;;;;;
648 654
649 ;; Useful programming-related keystrokes. 655 ;; Useful programming-related keystrokes.
650 656
651 (defun describe-foo-at-point () 657 (defun describe-foo-at-point ()
658 "Show the documentation of the Elisp function and variable near point.
659 This checks in turn:
660
661 -- for a function name where point is
662 -- for a variable name where point is
663 -- for a surrounding function call
664 "
652 (interactive) 665 (interactive)
653 (let (sym) 666 (let (sym)
654 ;; sigh, function-at-point is too clever. we want only the first half. 667 ;; sigh, function-at-point is too clever. we want only the first half.
655 (cond ((setq sym (ignore-errors 668 (cond ((setq sym (ignore-errors
656 (with-syntax-table emacs-lisp-mode-syntax-table 669 (with-syntax-table emacs-lisp-mode-syntax-table
745 (define-key list-mode-map 'kp-subtract 'kill-current-buffer) 758 (define-key list-mode-map 'kp-subtract 'kill-current-buffer)
746 (define-key list-mode-map '(shift kp-subtract) 759 (define-key list-mode-map '(shift kp-subtract)
747 'kill-current-buffer-and-window) 760 'kill-current-buffer-and-window)
748 761
749 (defun kill-current-buffer () 762 (defun kill-current-buffer ()
763 "Kill the current buffer (prompting if it is modified)."
750 (interactive) 764 (interactive)
751 (kill-buffer (current-buffer))) 765 (kill-buffer (current-buffer)))
752 766
753 (defun kill-current-buffer-and-window () 767 (defun kill-current-buffer-and-window ()
768 "Kill the current buffer (prompting if it is modified) and its window."
754 (interactive) 769 (interactive)
755 (kill-buffer (current-buffer)) 770 (kill-buffer (current-buffer))
756 (delete-window)) 771 (delete-window))
757 772
758 (defun grep-c-files () 773 (defvar grep-all-files-history nil)
759 (interactive) 774
775 (defvar grep-all-files-omitted-expressions
776 '("*~" "#*" ".#*" ",*" "*.elc" "*.obj" "*.o" "*.exe" "*.dll" "*.lib" "*.a"
777 "*.dvi" "*.class" "*.bin")
778 "List of expressions matching files to be omitted in `grep-all-files-...'.
779 Each entry should be a simple name or a shell wildcard expression.")
780
781 (defvar grep-all-files-omitted-directories '("CVS" "RCS" "SCCS")
782 "List of directories not to recurse into in `grep-all-files-...'.
783 Each entry should be a simple name or a shell wildcard expression.")
784
785 (defun construct-grep-all-files-command (find-segment grep-segment)
786 (let ((omit-annoying
787 (mapconcat #'(lambda (wildcard)
788 (concat "-name '" wildcard "' -or "))
789 grep-all-files-omitted-expressions
790 "")))
791 (cond ((eq grep-find-use-xargs 'gnu)
792 (format "find . %s %s -type f -print0 | xargs -0 -e %s"
793 find-segment omit-annoying grep-segment))
794 (grep-find-use-xargs
795 (format "find . %s %s -type f -print | xargs %s"
796 find-segment omit-annoying grep-segment))
797 (t
798 (format "find . %s %s -type f -exec %s {} /dev/null \\;"
799 find-segment omit-annoying grep-segment)))))
800
801 (defun grep-all-files-in-current-directory (command)
802 "Run `grep' in all non-annoying files in the current directory.
803 `Non-annoying' excludes backup files, autosave files, CVS merge files, etc.
804 More specifically, this is controlled by `grep-all-files-omitted-expressions'.
805
806 This function does not recurse into subdirectories. If you want this,
807 use \\[grep-all-files-in-current-directory-and-below]."
808 (interactive
809 (progn
810 (require 'compile)
811 (list (read-shell-command "Run grep (like this): "
812 grep-command 'grep-all-files-history))))
760 (require 'compile) 813 (require 'compile)
761 (let ((grep-command 814 (grep (construct-grep-all-files-command
762 (cons (concat grep-command " *.[chCH]" 815 "-name . -or -type d -prune -or" command)))
763 ; i wanted to also use *.cc and *.hh. 816
764 ; see long comment below under Perl. 817 (defun grep-all-files-in-current-directory-and-below ()
765 ) 818 "Run `grep' in all non-annoying files in the current directory and below.
766 (length grep-command)))) 819 `Non-annoying' excludes backup files, autosave files, CVS merge files, etc.
767 (call-interactively 'grep))) 820 More specifically, this is controlled by `grep-all-files-omitted-expressions'.
768 821
769 (defun grep-lisp-files () 822 This function recurses into subdirectories. If you do not want this,
770 (interactive) 823 use \\[grep-all-files-in-current-directory]."
824 (interactive
825 (progn
826 (require 'compile)
827 (list (read-shell-command "Run grep (like this): "
828 grep-command 'grep-all-files-history))))
771 (require 'compile) 829 (require 'compile)
772 (let ((grep-command 830 (grep (construct-grep-all-files-command
773 (cons (concat grep-command " *.el" 831 ;; prune all specified directories.
774 ; i wanted to also use *.cc and *.hh. 832 (mapconcat #'(lambda (wildcard)
775 ; see long comment below under Perl. 833 (concat "-name '" wildcard "' -prune -or "))
776 ) 834 grep-all-files-omitted-directories
777 (length grep-command)))) 835 "")
778 (call-interactively 'grep))) 836 command)))
779
780 ;; This repeatedly selects larger and larger balanced expressions
781 ;; around the cursor. Once you have such an expression marked, you
782 ;; can expand to the end of the following expression with C-M-SPC and
783 ;; to the beginning of the previous with M-left.
784 837
785 (defun clear-select () 838 (defun clear-select ()
839 "Repeatedly select ever larger balanced expressions around the cursor.
840 Once you have such an expression marked, you can expand to the end of
841 the following expression with \\[mark-sexp] and to the beginning of the
842 previous with \\[backward-sexp]."
786 (interactive "_") ;this means "preserve the active region after this command" 843 (interactive "_") ;this means "preserve the active region after this command"
787 (backward-up-list 1) 844 (backward-up-list 1)
788 (let ((end (save-excursion (forward-sexp) (point)))) 845 (let ((end (save-excursion (forward-sexp) (point))))
789 (push-mark end nil t))) 846 (push-mark end nil t)))
790 847
791 ;; #### no kp-divide because it doesn't (currently) work on MS Windows 848 ;; #### no kp-divide because it doesn't (currently) work on MS Windows
792 ;; -- always reports as /. #### this should be fixable. 849 ;; -- always reports as /. #### this should be fixable.
793 (global-set-key 'kp-add 'query-replace) 850 (global-set-key 'kp-add 'query-replace)
794 (global-set-key '(shift kp-add) 'query-replace-regexp) 851 (global-set-key '(shift kp-add) 'query-replace-regexp)
795 (global-set-key '(control kp-add) 'grep-c-files) 852 (global-set-key '(control kp-add) 'grep-all-files-in-current-directory)
796 (global-set-key '(meta kp-add) 'grep-lisp-files) 853 (global-set-key '(meta kp-add) 'grep-all-files-in-current-directory-and-below)
797 (global-set-key 'clear 'clear-select) 854 (global-set-key 'clear 'clear-select)
798 ;; Note that you can use a "lambda" expression (an anonymous function) 855 ;; Note that you can use a "lambda" expression (an anonymous function)
799 ;; in place of a function name. This function would be called 856 ;; in place of a function name. This function would be called
800 ;; `pop-local-mark' and lets you repeatedly cycle back through recent 857 ;; `pop-local-mark' and lets you repeatedly cycle back through recent
801 ;; marks (marks are set whenever you begin a selection, begin a 858 ;; marks (marks are set whenever you begin a selection, begin a
802 ;; successful search, are about to jump to the beginning or end of the 859 ;; successful search, are about to jump to the beginning or end of the
803 ;; buffer, etc.). 860 ;; buffer, etc.).
804 (global-set-key 'kp-enter (lambda () (interactive) (set-mark-command t))) 861 (global-set-key 'kp-enter (lambda () (interactive) (set-mark-command t)))
805 (global-set-key '(shift kp-enter) 'repeat-complex-command) 862 (global-set-key '(shift kp-enter) 'repeat-complex-command)
806 (global-set-key 'pause 'repeat-complex-command) ;; useful on Windows-stlye kbds 863 (global-set-key 'pause 'repeat-complex-command) ;; useful on Windows-style kbds
807 (global-set-key '(control kp-enter) 'eval-expression) 864 (global-set-key '(control kp-enter) 'eval-expression)
808 865
809 ;;;;;;;;;;;;;;;;;;;;;;;; 866 ;;;;;;;;;;;;;;;;;;;;;;;;
810 867
811 ;; Misc. 868 ;; Misc.
887 ;; Substitute your info here. 944 ;; Substitute your info here.
888 ;(setq user-mail-address "ben@xemacs.org") 945 ;(setq user-mail-address "ben@xemacs.org")
889 ;(setq user-full-name "Ben Wing") 946 ;(setq user-full-name "Ben Wing")
890 ;(setq smtpmail-smtp-server "pop.tcsn.uswest.net") 947 ;(setq smtpmail-smtp-server "pop.tcsn.uswest.net")
891 948
892 ;; Make Alt+accelerator traverse to the menu in new enough XEmacs 949 ;; Make Meta+accelerator traverse to the menu in new enough XEmacs
893 ;; versions. Note that this only overrides Meta bindings that would 950 ;; versions. Note that this only overrides Meta bindings that would
894 ;; actually invoke a menu, and that none of the most common commands 951 ;; actually invoke a menu, and the most common commands that are
895 ;; are overridden. You can use ESC+key to access the overridden 952 ;; overridden have preferred alternative bindings using the arrow
896 ;; ones if necessary. 953 ;; keys. You can always access the overridden ones using
954 ;; Shift+Meta+Key. (Note that "Alt" and "Meta" normally refer to the
955 ;; same key, except on some Sun keyboards [where "Meta" is actually
956 ;; labelled with a diamond] or if you have explicitly made them
957 ;; different under X Windows using `xmodmap'.)
958 ;;
959 ;; More specifically, the following bindings are overridden:
960 ;;
961 ;; M-f (use C-right or Sh-M-f instead)
962 ;; M-e (use M-C-right or Sh-M-e instead)
963 ;; M-v (use Prior aka PgUp or Sh-M-v instead)
964 ;; M-m (use Sh-M-m instead)
965 ;; M-t (use Sh-M-t instead)
966 ;; M-o (normally undefined)
967 ;; M-b (use C-left or Sh-M-b instead)
968 ;; M-h (use M-e h or Sh-M-h instead)
969 ;; in Lisp mode, M-l (use Sh-M-l instead)
970 ;; in C mode, M-c (use Sh-M-c instead)
971
897 (setq menu-accelerator-enabled 'menu-force) 972 (setq menu-accelerator-enabled 'menu-force)
898 973
899 ;; Make Cygwin `make' work inside a shell buffer. 974 ;; Make Cygwin `make' work inside a shell buffer.
900 (setenv "MAKE_MODE" "UNIX")) 975 (setenv "MAKE_MODE" "UNIX"))
901 976