XEmacsNull Blog

Bi-Day XEmacs Tip Blog

Friday, December 30, 2005

Topic: Using Calc

Question: How can I evaluate numeric expressions, in XEmacs? . . .

Answer: Another package to the rescue. The calc package, usually installed in most installations.

• Enter the calc mode: Alt-#, c.
• Running in HP Calculator form. You can evaluate expressions with a stack-based system: 100, enter, 200, + and so on.
• Exit calc mode: Alt-#, c.

= There is an algebraic mode, also. See next post.

Platform: Linux
Level: Basic
GlR

Wednesday, December 28, 2005

Tip: Hex File Inserting

Question: Ok, now we have all these long commands. hexl-mode, hexl-mode-exit, hexl-insert-hex-string, and hexl-insert-hex-char. (Just two hexidecimal digits.) What can we do to reduce typing them? . . .

Answer: Define some new keys for yourself. If you're going to use these often. Why not customize it, for yourself.

(1) See Topic: Defining Key Bindings, all about Key Bindings.

(2) Use Ctrl-c, ???; for whatever bindings you prefer. Such as, Ctrl-c, h; to enter Hexl mode.

  (global-set-key '[(control c)(h)] 'hexl-mode)  

Platform: Linux
Level: Amateur
GlR

Monday, December 26, 2005

Topic: Hex File Editing

Need to edit a file in Hex mode? XEmacs answers the call, also. . . .

= There is a mode for hex editing of a file. The command notes below should tell you enough, to figure it out. Just load up the file, as normal.

• Switch to Hexl mode: Alt-x, hexl-mode, enter.
= Now, you can "replace characters" just as they are on your keyboard.
• To place a hex value sequence, over this file in binary mode. (1) Make sure you are "pointed" (where) you want the hex-string placed. (2) Alt-x, hexl-insert-hex-string, enter, ????. (Your hexadecimal sequence.), then enter, when done.
• Exit Hexl mode: Alt-x, hexl-mode-exit, enter.

Platform: Linux
Level: Amateur
GlR

PS. When you switch from ASCII to Hexl mode. It'll will say, "Converting to (or from) hexl mode will drop Undo info, continue." Type y for yes! Now, you have a binary hexadecimal editor, for free, too!

Saturday, December 24, 2005

Tip: Set Pixel Map Background

Question: How do you set the background to a nicer graphic pattern? Such as, a paper background theme. . . .

Answer: Again, edit your ~/.xemacs/custom.el file. Add the following line.

  (set-face-background-pixmap 'default "/home/auser/pics/vegatative_fog.xpm")  

= This will set it globally. You won't be able to override via a command line switch.

= Where can you get Pixmap files / images? Open a Jpeg with Gimp as save as an image.xpm, to make it a pixmap formatted file. How to locate a paper graphic on Linux? Use locate paper, for one. Or go to /usr/share, and ls -lR | egrep -i paper | less. Or try find /usr/share -name '*.xpm' -print.

Platform: Linux
Level: Amateur
GlR

Thursday, December 22, 2005

Tip: Set Background Color

Question: How do you set on start-up the background color with XEmacs? . . .

Answer: You'll need to edit your ~/.xemacs/custom.el file. Add the following line.

 (set-face-background 'default  "white") ; frame background  

= This will set it globally. You won't be able to override via a command line switch. You can find your X11 colors in this post.

Platform: Linux
Level: Amateur
GlR

Tuesday, December 20, 2005

Tip: Reset Abbreviations

Question: So, I've saved all these abbreviations & I want to clear them out, to setup more new ones. . . .

= Just so, you don't have to exit XEmacs, and restart without loading your abbreviations file. There is a command to clear abbreviations.

• Clear Abbrevs: Alt-x, kill-all-abbrevs, enter.

Platform: Linux
Level: Basic
GlR

Sunday, December 18, 2005

Tip: Save Your Abbrevs

Question: Ok, so now, I've built up several abbreviations. How do I save and load these? . . .

Details: Certainly, you'll have to save them. Command follows.

• Save Abbrevs: Alt-x, write-abbrevs-file, ???
= Then, you're prompted to state a file name. Which, normally, this will default to your ~/ home directory. However, if you are editing a common set of files, in the "adir/set1" directory. I'd suggest, you type "adir/set1/.abbrev_defs" for your ".abbrev_defs" (hidden Unix file).



Why? Because, when you want to recall them, as below.

• Read Abbrevs: Alt-x,read-abbrevs-file, ???
= If you are still running inside the "adir/set1" directory. Then, you can simply type ".abbrev_defs". (Or give file completion a hint, typing .abb , and such.)

= Then, it recalls those globally defined abbreviations, for just that directory. Otherwise, you can "default" everything to your home directory. (When you "read-abbrev-file", you'll have to backspace delete to the home directory.)

Platform: Linux
Level: Amateur
GlR

Friday, December 16, 2005

Topic: Make Your Own Abbreviations

So, after all that work for custom key bindings. Now, you tell me about making an abbreviation? . . .

Answer: Well, yes, why? Because, everyone else starts with the easy stuff and goes to the hard stuff. I'd rather have you think a little. Get into deep stuff, relax, take a brake, understand it, if even only half way, then jump back to something refreshing.

= Remember, even though, this can be (and should be) used as a XEmacs tip database. The real goal is a kind of two day gradual learning program. You could call it a class. Only, I don't have pop quizzes or give multiple multiple choice questions. (Yes, Dr. Erickson actually administered such tests in our CS 174 NDSU Computer Science courses. Multiple choice might be easy. However, when each question interactively affects the others and it becomes a patchwork of answers. This isn't your plain Jane MC Exam.)

= Using the abbreviation's feature is one of XEmacs minor modes. You'll have to turn it on, in order to have it expand your definitions.

= Then, we can start defining some word-based abbreviations.

• Turn the mode on: Alt-x, abbrev-mode, enter.
• Create abbreviation for "prging" to programming.

  • Type your expansion: programming
  • Define the abbreviation (globally): Ctrl-x, a, g, ??? (See next item.)
  • Enter your abbreviate word: prging, enter.
Platform: Linux
Level: Amateur
GlR

PS. If you would rather "disable" your abbreviations, for a while? Simple turn the abbreviate mode off. Alt-x abbrev-mode, enter. It toggles, you see.

Wednesday, December 14, 2005

Topic: Important Keys

Question: Have you been working out with the Alt-?, Ctrl-k "Lookup Key Binding" function. There is a deeper reason to learn it and it's kin. . . .

Answer: Well, so far, we have been searching for functions, testing if key bindings are connected to a function and guess what? The whole family of Info Functions follow this pattern. (See, there is a reasoning to XEmacs design.)
  1. Info (Table of) Contents: Alt-?, i
  2. Lookup Key Binding: Alt-?, Ctrl-k
  3. Lookup Command: Alt-?, Ctrl-c
  4. Lookup Function: Alt-?, Ctrl-f
  5. Lookup Topic: Alt-?, Ctrl-i

So, now, you can look up tons of things.

  • Alt-?, i # Shows the info viewer.
  • Alt-?, Ctrl-k, Ctrl-x, Ctrl-c, # Shows the save-buffers-kill-emacs
  • Alt-?, Ctrl-c, save-buffers-kill-emacs # Shows the help info screen, on the above.
  • Alt-?, Ctrl-f, save-current-buffer # Shows what you would expect.
  • Alt-?, Ctrl-i. Xemacs, enter # Shows the manual.

• Did you try, Alt-?, Ctrl-f, save-buffers-kill-emacs ? It isn't there why?

Platform: Linux
Level: Amateur
GlR

Monday, December 12, 2005

Tip: Menu Jump Bookmark

Question: Can I jump by the menu system, how to bookmark-jump? . . .

= Yes, you can. Personally, I believe a user should do things, any way that is most conveniant to themselves.

Answer 1: Ctrl-x, r, b, ??? (enter name.)
Answer 2: Menu, View, Bookmark, Jump To, ??? (a list of them).

Review:
  • Ctrl-x, r, b (b for bookmark, to jump to.) Function: bookmark-jump
  • Ctrl-x, r, l (l for list.) Function: list-bookmarks
  • Ctrl-x, r, m (m for memorize.) Function: bookmark-set
  • Alt-x, bookmark-save, enter. (save bookmarks in default [global] file).Function: bookmark-save
  • Alt-x, bookmark-load, filename, enter. Function: bookmark-set
  • Alt-x, bookmark-write, filename, enter. Function: bookmark-write

= Why isn't there a Ctrl-x, r, s (save?) or Ctrl-x, r, l (load?) ? XEmacs wasn't setup this way. However, it doesn't mean you can't change it. You'll notice the "mentioning" of functions creeping in. This is intentional and "if you? are" going to become an even more capable XEmacs power user. You'll have to start learning about functions.

= Then, you can "rewrite" XEmacs to be your tool, and not XEmacs tooling you.

Platform: Linux
Level: Amateur
GlR

Saturday, December 10, 2005

Topic: Details Listed on Key Bindings

Question: Some manuals say use Ctrl-h, k; to find the function tied to a key binding. You mentioned Alt-?, Ctrl-k? . . .

= Answer: Yes, there are several key binding help commands, only three real ones - I am aware of. Here is the rundown.

  1. Ctrl-h, c, ??? (enter your key binding to check): This is the describe-key-briefly function. Just shows which function is bound to it.
  2. Ctrl-h, k, ???: This is the describe-key function. Pulls up the "formal documentation" inside XEmacs for the key binding. Perhaps, I should of pointed you at this one, first? However, I think the point is to "get using" XEmacs. You'll find almost everything can be done in some unique, different, and or alternate way.
  3. Alt-?, Ctrl-k, ???: This is the Info-goto-emacs-key-command-node function, used in earlier posts. It'll pull up the Info screen help system to detail the function around it's key binding.

= Reminder: If you want to cancel "searching" for a key binding & don't have a result yet. Ctrl-g, as always. Otherwise, when you get the info or man page screens. Ctrl-x, 1. Ctrl-x, k, enter.

Platform: Linux
Level: Amateur
GlR
  • Have you tried looking up the function for Ctrl-x, 1?
  • Whenever, I start XEmacs with more than one file. I end up using it, to run in one frame only. Now, that I know the function to call. Soon, I'll get it to run it, during start-up, check if multiple files, and tame this shrew.

Thursday, December 08, 2005

Tip: Tougher Key Bindings

Question: What if, I want to bind to Ctrl-c, b, 3? . . .

Answer: Well, again, using the (kbd function comes to our rescue. Only, this way we'll put it into a different place.

(global-set-key  (kbd "C-c b 3") " a sample ") # one
(global-set-key (kbd "C-c b 3") 'your-own-elisp-function) # two

= If you try the other way. There doesn't seem to be an easy way, to connect with a long shortcut sequence to an action.

Platform: Linux
Level: Amateur
GlR

Tuesday, December 06, 2005

Tip: Writing Lines from Bindings

Question: So, I can setup some bindings to write text. What if I want to write several lines? . . .

Problem: Using the
(global-set-key '[(control c)(n)] "str1" "str2" "str3")
doesn't work. Well, the global-set-key LISP function only expects one string as the last parameter. Or you could embed control characters in the string.

Solution 1: One way is to include a \n newline character.
"str1\nstr2\nstr3"


Solution 2: Or you can use the (kbd function and keep a cleaner look.
"str1 RET str2 RET str3 RET"


Platform: Linux
Level: Amateur
GlR

PS. Next time, I show how to do this by setting up abbreviations, instead.

Sunday, December 04, 2005

Topic: Defining Key Bindings

Question: Ok, how do I encode some custom key bindings? . . .

= There are several ways, to do this. You can setup a key binding on the fly. However, what is the use of this? If I want a key binding known and bother to set it up. I want it assigned for a longer term. ie. Globally. For the moment, I'll just cover the first most direct way, with a global duration.

= Bear in mind, though, if you "redefine" a binding which is used by your major / minor modes. You'll overwrite it.

• Safe Copy and Edit the ~/.xemacs/custom.el file. Add the following line, after the last statements.
(global-set-key '[(control c)(n)] "Your Name ")


The last member of the list ("Your Name ") is an instruction to directly type this. However, normally, you would call a LISP function. I hope to introduce a generic LISP XEmacs function. So, you can use it to derive more compact custom key bindings. Rather than manually binding them, one by one, here. (Although, placing your function somewhere and the time XEmacs spends loading functions [and libraries] will slow down you speed up time. What did you expect for infinite power? Nothing?)

Platform: Linux
Level: Amateur
GlR

PS. An example of messing up your exit function.
(global-set-key '[(control x)(control c)] 'count-words-buffer)

Now, if you Ctrl-x, Ctrl-c. You can't exit and see a word count of the current buffer. (Menu still works to exit or call Alt-x, save-buffers-kill-emacs, enter.

To restore it, even though, you can just delete the above offending global-set-key, see below.
(global-set-key '[(control x)(control c)] 'save-buffers-kill-emacs)

Friday, December 02, 2005

Tip: Save All

Question: Often, I'll edit several files at once. After changing several, how do I save some (all) buffers? . . .

If you exit XEmacs? It will prompt you and manually ask to confirm, saving each file. However, normally, use use the Save Some Buffers command.

Loading up via "xemacs day*.txt" or "xemacs -nw *.txt," for examples.

Answer 1: Ctrl-x, s, and "press y" for yes, at each prompt.

Answer 2: Menu, File, Save Some Buffers, and click the "Yes All" button.

Platform: Linux
Level: Basic
GlR