home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / sample-.emacs < prev    next >
Encoding:
Text File  |  1990-07-22  |  14.8 KB  |  269 lines

  1. ;From utkcs2!emory!mephisto!tut.cis.ohio-state.edu!DUCVAX.AUBURN.EDU!CAMPBELL Wed Jul 18 08:11:27 EDT 1990
  2. ;Article 3222 of gnu.emacs:
  3. ;Path: utkcs2!emory!mephisto!tut.cis.ohio-state.edu!DUCVAX.AUBURN.EDU!CAMPBELL
  4. ;>From: CAMPBELL@DUCVAX.AUBURN.EDU ("Ernest M. Campbell III")
  5. ;Newsgroups: gnu.emacs
  6. ;Subject: .emacs and ftp sites
  7. ;Message-ID: <9007171822.AA15266@life.ai.mit.edu>
  8. ;Date: 17 Jul 90 18:27:00 GMT
  9. ;Sender: daemon@tut.cis.ohio-state.edu
  10. ;Distribution: gnu
  11. ;Organization: GNUs Not Usenet
  12. ;Lines: 255
  13. ;
  14. ;I have gotten a number of requests from various people for me to forward the
  15. ;information I received to them.  I think the response I got was enough to 
  16. ;warrant posting some of it here.  I hope too many of you don't mind!  Anyhow, 
  17. ;there is indeed a large repository of elisp files at tut.cis.ohio-state.edu
  18. ;and also at cheops.cis.ohio-state.edu.  The ftp list that I recently got hold
  19. ;of can be retrieved from 'pilot.njin.net [128.6.7.38]'  There's also an ftp
  20. ;help file there.  Following is the .emacs file that I received that had the
  21. ;best documentation (no offense to the other folx who sent me files!  They 
  22. ;all had useful things in them).
  23. ;
  24. ;        Ernest Campbell
  25. ;
  26. ;-----------------------------End of Blathering--------------------------------
  27. ;>From:    IN%"tale@turing.cs.rpi.edu" 12-JUL-1990 15:14:39.43
  28. ;CC:    
  29. ;Subj:    WANTED: info on .emacs file
  30. ;
  31. ;Return-path: tale@turing.cs.rpi.edu
  32. ;Received: from turing.cs.rpi.edu by ducvax.auburn.edu; Thu, 12 Jul 90 15:05 CDT
  33. ;Received: by turing.cs.rpi.edu (4.0/1.2-RPI-CS-Dept) id AA29151; Thu, 12 Jul 90
  34. ; 15:42:00 EDT
  35. ;Date: Thu, 12 Jul 90 15:42:00 EDT
  36. ;>From: tale@turing.cs.rpi.edu
  37. ;Subject: WANTED: info on .emacs file
  38. ;To: CAMPBELL@ducvax.auburn.edu
  39. ;Message-Id: <9007121942.AA29151@turing.cs.rpi.edu>
  40. ;In-Reply-To: CAMPBELL@DUCVAX.AUBURN.EDU's message of 12 Jul 90 18:41:00 GMT
  41. ;
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ;; Sample.Emacs --- A sample .emacs initialization file
  44. ;; Author          : Gnu Maint Acct
  45. ;; Created On      : Sun May 21 22:52:23 1989
  46. ;; Last Modified By: Gnu Maint Acct
  47. ;; Last Modified On: Wed May 24 12:51:43 1989
  48. ;; Update Count    : 1
  49. ;; Status          : Overly verbose but hopefully helpful
  50. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  51. ;;; Covered by the GNU General Public License
  52.  
  53. ;;; This file contains a lot of information -- much more than most users of
  54. ;;; GNU Emacs would have in their .emacs.  It is provided so that users new
  55. ;;; to Emacs, and even seasoned users who haven't explored the extensiveness
  56. ;;; of the environment beyond simple file editing, can see how Emacs can be
  57. ;;; custom-tailored to suit an individual's tastes.
  58. ;;;
  59. ;;; Please direct any comments/suggestions about this file to gnu@pawl.rpi.edu.
  60.  
  61. ;;; The above character, a quoted Control-L, represents a page break to Emacs.
  62. ;;; Various functions (narrow-to-page, page-menu, backward-page, etc) look for
  63. ;;; that character on a line by itself to see where the internal pages of a
  64. ;;; file begin and end.  This is especially handy for movement around a large
  65. ;;; file and keeping related sections of a file together.  This sample uses
  66. ;;; it primarily in the latter manner.
  67.  
  68. ;;; Setting variables
  69. ;;; The two functions which are most commonly used in Emacs to set variables
  70. ;;; are setq and setq-default.  Setq works on an even number of arguments,
  71. ;;; taking them in pairs.  The first argument of the pair is a variable
  72. ;;; name and the second is the value to assign to the variable.  The syntax
  73. ;;; of the variable is a little peculiar to non-LISP programmers, so a
  74. ;;; little background on how LISP operates is in order.
  75. ;;;
  76. ;;; LISP is a language which relies on its functionality from passing return
  77. ;;; values of functions; when a function in parentheses gets evaluated then
  78. ;;; a (usually meaningful) value is returned.  Some functions have side-effects
  79. ;;; which really are the primary use of the function.  Examples:
  80. ;;;   (+ 1 1) has a return value of 2.  There are no side-effects.
  81. ;;;   (setq test 2) also returns 2.  The side effect is to set the variable.
  82. ;;;
  83. ;;; When assigning variables you will see that sometimes the value to be
  84. ;;; assigned is preceded by a single quote -- '.  This is shorthand in LISP
  85. ;;; for the most commonly used function, quote.  (quote ...) takes a single
  86. ;;; argument which does not get evaluated by the LISP interpreter.  In general,
  87. ;;; the values which would need to be quoted are lists (parethesized groups
  88. ;;; of data) and variable/function names or definitions which shouldn't be
  89. ;;; evaluated until some later time.  Things that don't need to be quoted are
  90. ;;; t and nil ("true" and "false" to LISP), numbers, strings, and functions
  91. ;;; which you want to use the return value of immediately.  Note that quote
  92. ;;; really only is concerned about function and variable evaluation, so quoting
  93. ;;; a string, number or boolean (t or nil) is just the same as not quoting it;
  94. ;;; they are left unquoted in practise.  More examples:
  95. ;;;   (setq number 1)
  96. ;;;   (setq test (+ number 1))    test == 2
  97. ;;;   (setq test (+ 'number 1))   error; + can't add 1 to the word number
  98. ;;;   (setq test '(+ number 1))   test == (+ number 1)
  99. ;;;   (setq test '2)              test == 2  (discouraged quoting convention)
  100. ;;;   (setq test 2)               test == 2  (better)
  101. ;;;
  102. ;;; The following variables can affect Emacs globally; they are not specific
  103. ;;; to any particular application within Emacs.  To see what various effects
  104. ;;; a variable can have depending on its setting use the describe-variable
  105. ;;; function (normally bound to C-h v) to see its documentation.
  106. (setq default-major-mode 'text-mode  ;; Set the major mode of any buffer
  107.                                      ;; which does not declare it's own mode
  108.       window-min-height 2  ;; allow a window to get as small as one line high
  109.       require-final-newline t) ;; automatically insert a newline at the end
  110.                                ;; of a saved buffer if it is not the last char
  111.  
  112. ;;; These variables are special to particular uses of Emacs, such as reading
  113. ;;; mail or running inferior shells.
  114. (setq inhibit-startup-message t  ;; don't show the initial message that Emacs
  115.                                  ;; prints when starting without a file
  116.       view-diary-entries-initially t ;; show appropriate lines from ~/diary
  117.                                      ;; when M-x calendar is run
  118.       mh-ins-buf-prefix "> "  ;; the string to use for quoting mail in replies
  119.                               ;; when using the Emacs front-end to MH.
  120.       shell-use-extn t     ;; enable a history list in shell mode
  121.       completion-auto-exit t  ;; have completing-reads exit when a unique
  122.                               ;; prefix exists and SPC or TAB is typed
  123.       gnus-auto-select-first nil ;; don't automatically show first article
  124.       gnus-auto-select-same t ;; follow subject lines in articles (like rn)
  125.       gnus-auto-select-next 'quietly) ;; go on to the next group automatically
  126.  
  127. ;;; Hooks are functions Emacs runs when a mode is initialized or a function is
  128. ;;; executed, allowing for personal tastes to redefine or add to the basic
  129. ;;; actions of the mode or function.  Not every major mode has a hook and
  130. ;;; even fewer functions have them.  Two samples are given here.
  131. (setq text-mode-hook 'turn-on-auto-fill  ;; put text-mode buffers automatically
  132.                                          ;; in word-wrap mode.
  133.       mh-inc-folder-hook ;; this complex hook gets rid of the Mail word from
  134.                          ;; the modeline when display-time is being run and
  135.                          ;; new mail is incorporated with M-x mh-rmail
  136.       '(lambda ()
  137.          (if (and (boundp 'display-time-process)
  138.                   (eq 'run (process-status display-time-process)))
  139.              (save-match-data
  140.                (setq display-time-string
  141.                      (let ((loc (string-match " Mail" display-time-string)))
  142.                        (if loc
  143.                            (concat 
  144.                             (substring display-time-string 0 loc)
  145.                             (substring display-time-string (match-end 0)))
  146.                          display-time-string)))
  147.                ;; this little trick updates the mode-line immediately
  148.                (set-buffer-modified-p (buffer-modified-p)))))
  149.  
  150. ;;; setq-default is used to set the default value of a variable that
  151. ;;; initializes itself with each new buffer.  Such a variable is called
  152. ;;; a "buffer-local variable" and setting it only affects the current
  153. ;;; buffer.  The following line tells Emacs to insert spaces rather than
  154. ;;; C-i (TAB) characters when the TAB key is typed.
  155. (setq-default indent-tabs-mode nil)
  156.  
  157. ;;; Declarations dependent on environment
  158. ;;; Emacs can also perform certain behaviour based on what your environment
  159. ;;; is.  If you are on a certain type of terminal or connecting at a certain
  160. ;;; speed then you can decide to alter the behavior of Emacs to better suit
  161. ;;; your hardware interface.
  162. ;;;
  163. ;;; The following example makes I-search (C-s or C-r) use only a one line
  164. ;;; window to show its location whenever you are connected via an ADM3A or
  165. ;;; a VT100.  These are the two terminal types most likely to be connected
  166. ;;; via modem lines to a machine running Emacs; they are least likely to
  167. ;;; be connected via high speed lines.  It is a bit of a kludge to do it
  168. ;;; this way but is included nonetheless as an example of how you can
  169. ;;; use other features of LISP to find a solution to a problem.  The
  170. ;;; variable which Emacs uses normally to keep track of baud rate can
  171. ;;; not be relied upon because telnet runs at a much higher speed than
  172. ;;; the modem connexion you are actually on when dialed in to RPI's
  173. ;;; passthru service.
  174. (let ((term (getenv "TERM")))
  175.   (if (or (string-equal "vt100" term)
  176.           (string-equal "adm3a" term))
  177.       (setq search-slow-speed 99999)))
  178.  
  179. ;;; This conditional makes summary windows higher for mail and news iff
  180. ;;; you are running in a SunView or X environment.  This is because users
  181. ;;; in a window manager environment generally keep a larger Emacs than they
  182. ;;; can use on their home computers when dialed in.
  183. (if (or (getenv "WINDOW_PARENT") (string-equal (getenv "TERM") "xterm"))
  184.     (setq mh-summary-height 5 gnus-subject-lines-height 5)
  185.   (setq mh-summary-height 3 gnus-subject-lines-height 1))
  186.  
  187. ;;; Key bindings; some are for autoloaded functions in ~gnu/emacs/local
  188. ;;; One of the most common ways to customize Emacs is add or move bindings
  189. ;;; for functions.  Emacs keeps track of keypresses and maps them against
  190. ;;; its own internal structure.  If it finds a key which is a prefix to
  191. ;;; a group of keys, it reads until it has either read enough keys to
  192. ;;; identify a function, or until it gets a unique set of keys which is
  193. ;;; undefined.  In the former case it performs the function; in the latter
  194. ;;; case it merely beeps and keeps processing key presses that are
  195. ;;; available.  Prefixes are generally named as their own keymaps, such that
  196. ;;; esc-map, ctl-x-map and ctl-x-4-map define maps which store the information
  197. ;;; for key sequences which start with ESC, C-x and C-x 4 respectively.
  198. ;;;
  199. ;;; It is generally better practise to use define-key to specify a key
  200. ;;; as part of a map than to use global-set-key.  It is also usually better
  201. ;;; to leave the bindings of commonly used functions (like C-p and C-n) alone
  202. ;;; so that you won't be thrown off when using someone else's Emacs and
  203. ;;; someone using yours won't be either.  If you feel that you really
  204. ;;; prefer the modalness of vi to the constant command-entry mode of Emacs
  205. ;;; (even regular letters are really running a command named "self-insert=
  206. ;;; command") but would like to work in the Emacs environment, then try
  207. ;;; vi mode.
  208. (global-unset-key "\e[") ;; disable default binding of M-[
  209.                          ;; This allows for Sun arrow keys to be bound
  210. (define-key global-map "\C-\\" 'fixup-whitespace)
  211. (define-key esc-map "y" 'browse-kill-ring)   ; Make a M-y yank pick from menu
  212. (define-key esc-map "&" 'background)         ; Run asyncronous shell commands
  213. (define-key help-map "a" 'fast-apropos)      ; Shuffling of apropos to use
  214. (define-key help-map "A" 'super-apropos)     ;   faster functions and/or
  215. (define-key help-map "\C-a" 'quick-apropos)  ;   broader scope
  216. (define-key ctl-x-map "\C-m" 'page-menu)     ; A menu of ^L seperated pages
  217. (define-key ctl-x-4-map "w" 'wconfig-ring-save) ; save the window configuration
  218.  
  219. ;;; Getting new features into Emacs: load and autoload
  220. ;;; Emacs gets built with a lot of default functionality for commonly used
  221. ;;; functions and modes, but sometimes there is a need to load in external
  222. ;;; Emacs LISP code to do special things; most of this is handled automat-
  223. ;;; ically by Emacs such that you will only see the messages from it when
  224. ;;; a new feature is being added.  You can add autoloads in your .emacs for
  225. ;;; features which Emacs hasn't provided though, such as whist.el and
  226. ;;; wconfig.el in ~gnu/emacs/local, as in the following examples.
  227. (autoload 'whist "whist" "Add history entries to a file" t)
  228. (autoload 'wconfig-ring-save "wconfig" "Store the current window config." t)
  229.  
  230. ;;; loading should be done only for functions which you intend to use
  231. ;;; every time you run Emacs; since additional features use more memory,
  232. ;;; take more time for Emacs to start-up and can slow down the overall
  233. ;;; performance of the machine which Emacs is being run on (if lots of
  234. ;;; features were added), it is better to use autoload.  The following
  235. ;;; are loaded directly because of actions they take when loaded.
  236. ;;;
  237. ;;; header.el checks each file you save to see whether it has a header
  238. ;;; similar to the one on this file.  If it does it first updates the
  239. ;;; information in the file before saving the file.
  240. (load "header" nil t)
  241. ;;; minibuf.el doesn't bother stopping for non-word characters when doing
  242. ;;; completing reads.  This is generally a real plus as it will consistently
  243. ;;; read as far as it can before a conflict in completion occurs.
  244. (load "minibuf" nil t)
  245.  
  246. ;;; Miscellaneous functions
  247. ;;;
  248. ;;; display-time runs a process which will update the mode-line every minute
  249. ;;; to tell you the time, load, disk-access and whether you have mail waiting
  250. ;;; for you.  On diskless suns the disk-access will always be "0", but the
  251. ;;; other information is still useful.
  252. (display-time)
  253.  
  254. ;;; Emacs has a rather handy feature where it can accept a connexion
  255. ;;; to its already running process via a socket; this enables programmes
  256. ;;; which want to call the editor to not have the long start-up time which
  257. ;;; Emacs sometimes has.  To use this, the following lines should be
  258. ;;; in .login:
  259. ;;; setenv EDITOR /appl/imagine2/emacs/etc/emacsclient
  260. ;;; setenv VISUAL /appl/imagine2/emacs/etc/emacsclient
  261. ;;; Then programmes like rn and mail which acknowledge these variables
  262. ;;; will use emacsclient to connect to your running Emacs.
  263. ;;; Caveats: the Emacs process must be running for this to work, and it
  264. ;;; must have started the server with the following line.
  265. (server-start)
  266.  
  267.  
  268.  
  269.