Emacs notes

Main Site : CNK's space : Unix : Emacs Notes

General

To get emacs to start up with your ocnfiguration files - even if you are logged in as some other user: emacs -u username Or if you are su-ing to the other user, su -p will preserve your environment, including home directory.

Key sort cuts

To make all windows the same size (very useful when you have 3 horizantal windows): C-x +
To shrink a window so that it is just the size of the text in it: C-x -
To redo a complex command (for example a query-replace): C-x ESC ESC

Version control mode - esp RCS

Check out (or in)
C-x C-q
Check back in without committing any changes
C-x v u
Diff with the last committed version
C-x v =
If you use the prefix command, C-u, then you are prompted for a file name and then two version numbers to diff between. The default for the first version number is the most recently checked in version, for the second, the current version of the file.
NB I have the -u flag set in my .xemacs/init.el file (unified context diff)
Show the RCS/CVS log for the file
C-x v l
Figure out what files in a directory are RCS locked
C-x v d
Not really an emacs tip - but from the rcs man page, how to "tag" - associate a symbolic name with a group of files
 -nname[:[rev]] 
              Associate the symbolic name name with the branch or                            
              revision rev.  Delete the symbolic name if  both  : 
              and rev are omitted; otherwise, print an error mes- 
              sage if name is  already  associated  with  another 
              number.   If rev is symbolic, it is expanded before 
              association.  A rev consisting of a  branch  number 
              followed by a . stands for the current latest revi- 
              sion in the branch.  A : with an empty  rev  stands 
              for  the  current  latest  revision  on the default 
              branch,   normally   the   trunk.    For   example, 
              rcs -nname: RCS/*  associates name with the current 
              latest revision of all the named  RCS  files;  this                 
              contrasts  with rcs -nname:$ RCS/* which associates        
              name with the revision numbers extracted from  key- 
              word strings in the corresponding working files. 

Dired mode

After watching Josh wander around in the CITWEB config files, I finally understand why one might use dired mode. Previously I had always considered it one of those annoyances I got when I mistyped.
Getting into it
C-x d
Open file - in other window
o - if you want the cursor to move to that buffer
C-o if you want the cursor to stay in the dired buffer
Marking files
Deleting autosave files: ~, #, or . - depending on the pattern of the file names you want marked for deltion
More general marking - based on a regular expression: %m
Or regexp mark for deletion: %d
Un-marking files
Should be ESC DEL - but given how I generally have my delete/backspace keys remapped, I may need to use the full command (or map it to some other keystroke shortcut): dired-unmark-all-files
Actually with my normal .xemacs files, it looks like M-backspace works.
Querying in multiple files
Mark the files you want to query. Then hit A to search, Q to do query-replace
Changing ownership
Owner: O
Group: G
Changing file permissions
M
Copy a file
C
Move a file
R
diff a file
=d then type in the other file path
Refresh view - if the previous operation did not do it for you
g

Indenting paragraphs

Have not found out how to install Filladapt mode in emacs - it comes standard in xemacs and totally rocks! But even if you have filladapt mode, sometimes you change your mind about how you want things indented and so need to shift them over. So starting from already typed paragraphs, first we need to remove all current indentation (this step is needed so that text reflowing will work after then indenting); select the text in question, then type M-- M-9 M-9 C-x C-i. Then reselect the text and set the indenting. C-x C-i will indent all lines 1 space. If you want a different number of spaces, say 4 spaces, use the prefix command: M-4 C-x C-i

Setting comment syntax

Most of the time emacs can figure out the type of file from the file extension and set the major mode accordingly. But for config files, it often isn't obvious what the correct major mode is. For the most part, c'est la vie. However, one side effect is that you can't use M-x comment-region because you get "No comment syntax is defined". To fix that (at least for files where comments start with "#") type the following: M-: (setq comment-start “#”) RET

Extracting queries from AOLServer error logs

David Lutterkord wrote a really amazing elisp file that highlights AOLServer error logs - and even cooler, lets you extract SQL queries and move them into a SQL*Plus buffer to run them. Follow the instructions at the top of the file (nsd.el) to install and use.

Org mode for daily planning

Notes - esp keyboard shortcuts from John Wiegley's article on how to use emacs' org mod as a day planner. This article about tracking daily habits also looks interesting.

Add tasks to your list
Esc C-r (should work as the chord M-C-r but doesn't seem to from my MacBook) then when you have the task created, save it with C-u C-c C-c
Schedule a task for a specific day
C-c C-s The default you are offered is today. You can choose something from the calendar display, or type in relative dates like +1 for tomorrow, etc.
Change the state of a task
C-u t followed by the first couple letters of the state - states include STARTED, WAITING, DONE, DEFERRED
Move a task to your archive file
C-c C-x C-s Ummmmm this seems to mark it CANCELLED - not what I want for most things
To categorize stuff...
just cut and paste into the correct section of the todo.org file
To see the agenda for the week
C-c a a If you change things (like reschedule or change state) you can refresh this buffer by pressing 'r' while in it. To see just one day, move the cursor to that day, then press 'd'. To get back to the weekly view, press 'w'
To set priorities
navigate to the item and type ',' followed by a, b, or c
Change the state of the task
C-u t

Other


cnk@ugcs.caltech.edu