[ Pobierz całość w formacie PDF ]
.The word global" means that this keybinding will be in e ect in all major modes there isanother function, local-set-key, that binds a key in a single bu er.Above, I have bound C-c lto the function goto-line.The key is described using a string.The special syntax C- char "means the Control key held down while the key char is pressed.Likewise, M- char " indicatesthe Meta key.All very well, but how did I know that the function's name was goto-line"? I may know thatI want to bind C-c l to some function that prompts for a line number and then moves the cursorto that line, but how did I nd out that function's name?This is where Emacs's online help facilities come in.Once you have decided what kind offunction you are looking for, you can use Emacs to track down its exact name.Here's one quickand dirty way to do it: since Emacs gives completion on function names, just type C-h f whichis describe-function, remember , and then hit Tab without typing anything.This asks Emacsto do completion on the empty string | in other words, the completion will match every singlefunction! It may take a moment to build the completion list, since Emacs has so many internalfunctions, but it will display as much of it as ts on the screen when it's ready.At that point, hit C-g to quit out of describe-function.There will be a bu er called *Completions*",which contains the completion list you just generated.Switch to that bu er.Nowyou can use C-s,isearch, to search for likely functions.For example, it's a safe assumption that a function whichprompts for a line number and then goes to that line will contain the string line" in its name.Therefore, just start searching for the string line", and you'll nd what you're looking for eventu-ally.If you want another method, you can use C-h a, command-apropos, to show all functions whosenames match the given string.The output of command-apropos is a little harder to sort throughthan just searching a completion list, in my opinion, but you may nd that you feel di erently.Tryboth methods and see what you think.There is always the possibility that Emacs does not have any prede ned function to do whatyou're looking for.In this situation, you have to write the function yourself.I'm not going totalk about how to do that |you should look at the Emacs Lisp library for examples of functionde nitions, and read the Info pages on Emacs Lisp.If you happen to know a local Emacs guru, ask8.13.CUSTOMIZING EMACS 85her how to do it.De ning your own Emacs functions is not a big deal | to give you an idea, I havewritten 131 of them in the last year or so.It takes a little practice, but the learning curve is notsteep at all.Another thing people often do in their.emacs is set certain variables to preferred values.Forexample, put this in your.emacs and then start up a new Emacs:setq inhibit-startup-message tEmacs checks the value of the variable inhibit-startup-message to decide whether or not todisplay certain information about version and lack of warranty when it starts up.The Lisp expressionabove uses the command setq to set that variable to the value `t', which is a special Lisp value thatmeans true.The opposite of `t' is `nil', which is the designated false value in Emacs Lisp.Hereare two things that are in my.emacs that you might nd useful:setq case-fold-search nil ; gives case-insensitivity in searching;; make C programs indent the way I like them to:setq c-indent-level 2The rst expression causes searches including isearch to be case-insensitive; that is, the searchwill match upper- or lower-case versions of a character even though the search string contains onlythe lower-case version.The second expression sets the default indentation for C language statementsto be a little smaller than it is normally | this is just a personal preference; I nd that it makes Ccode more readable.The comment character in Lisp is ; "
[ Pobierz całość w formacie PDF ]