Xah Emacs Blog

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Tips & Tricks for emacs and emacs lisp.

what's the best coding style?

Emacs: Tabs, Space, Indentation Setup#comment-1595298993

any coding style guide or concern should be ban'd. The only valid coding style advice is when it makes a algorithmic difference. Anything else, is hacker idiocy (to the extreme), and language idiocy, and the downward spiral and dead habit.

like keyboard & keybinding, the best hope is waiting for death to take care of the problem. (as Steve Jobs and Douglas Crockford said.)

the most idiotic programers, are the hacker types. The types that read hackernews, reddit, stackoverflow, (and graddaddy slashdot) etc everyday, and don't hesitate to tell you what you should do, about idioms & styles.

the only tool allowed for formatting related coding style, is one where you press a button and the entire file or directory is reformatted. (golang does it). Anything else, such as paredit, or most “lints”, is hacker idiocy.

the worst language, is a language that has lots of tricks & idioms. Perl is the dad, but went out of juice. Now Python. Ruby is designed to be sans coding style, but idiots create a style guide nevertheless.

what's the most efficient input system for alphabets that's got 10 more characters than English?

Yuri Khan, a great Russian programer, and one with extensive keyboard & keybinding modification, raised a question about how to input the 10 or so extra Russian letters. (he also uses Truly Ergonomic Keyboard)

He's got his own ideas. See discussion at https://plus.google.com/113859563190964307534/posts/Yxr1WivAu2K

i've done extensive research on this. see:

Keyboard: What's the Difference Between Alt Graph Key, Compose Key, Dead Key? (repost)

Emacs vs vi: How to Compute a Keybinding's Efficiency?

this suggest a scientific way to compute key efficiency. End the key debate once for all.

i hope someone might implement it. Or, i might do it eventually, but don't know what year.

GNU emacs's default key binding is no better than random keybinding.

there's a increase in ergoemacs-mode users since it went to FSF's repository. Let's get more people to use it!

best PC form keyboard for Mac

mac programer display and keyboard setup 69189 dan lentz
Dan Lentz's setup.

a friend (Dan lentz, Common Lisp and clojure expert) recently needed a keyboard to replace his Mac keyboard (he says it breaks every few months). I gave some recommendations. See: https://plus.google.com/+danlentz/posts/1oEtqpv6oEB

the keyboard i recommend according to his needs are:

Emacs Less-known Tips (minor update)

Emacs: Tabs, Space, Indentation Setup (updated)

Emacs: Delete Trailing Whitespace (on its own page)

Emacs Lisp: Setup Mouse Click to Highlight Matching Words (on its own page)

Emacs: Search & Highlight Words (minor update)

Keyboard revolution is here. Introducing, the Axios Keyboard ⌨

stackexchange emacs channel proposal passed. Join. http://area51.stackexchange.com/proposals/76571/emacs?referrer=hcehnezM28PzEQTGEFwH_Q2

fixed a bug in Emacs: Move Cursor by Paragraph or Text Block and Emacs Lisp: Move Cursor to Beginning of Line or Block. Thanks to Thorsten.

updated code. Emacs: Copy/Cut Current Line If No Selection

What to Do with Emacs Lisp? and my path to emacs lisp (minor edit)

Emacs Lisp: Count Lines, Words, Chars (minor update. Added a command to count region or line.)

Emacs Lisp: Single Key to Copy/Paste from Register (updated. No longer requiring a lib.)

in emacs's 1k+ default bindings , i only use 6, arrows and page up/down. Banish Key Chords Banish Key Chords

comment at https://plus.google.com/113859563190964307534/posts/hys14XrtDtX

does linux tiling window really suck? a challenge

F9 is switch to emacs

this is superb. you should, too. Tiling window is no good.

for how, and related tips, see:

vim: set your capslock to esc

if you use vim, it is critical that the Esc be a easy key. Some people make it “jj”, that's not good enough. The ideal position is either under your thumb, with a big key, or the traditional Caps Lock key position, and, must be a single key, not key chord.

See updated: Vim: How to Remap Escape Key?

for vim fans: Linux: How to Swap Caps Lock & Escape Keys?

what switch does space-cadget keyboard use?

i learn that, the Symbolics lisp machine's Space-cadet Keyboard uses Honeywell Hall Effect key switch, which is the highest quality key switch.

space-cadet keyboard 5
Space-cadet Keyboard

According to: http://deskthority.net/wiki/Honeywell_Hall_Effect:

Introduced in 1968, Micro Switch (a division of Honeywell) adapted their Hall effect switch technology to work in keyboards. These switches are among the highest quality ever produced by any keyboard switch company, with reliability being paramount to their design. For increased reliability, there are both 3 pin and 4 pin designs of the switch. The 4 pin are +5, GND and dual open-collector outputs, allowing wired-or of the X, Y keyboard matrix. These switches are naturally bounce-free!

The patent itself originates from 1969, but the design is aesthetically very different from the produced switches.

The Honeywell Hall Effect switch is most famous on some Symbolics keyboards, as well as the Space-cadet keyboard.

Keyfeel: Smooth linear switch, makes Cherry MX Black switches feel like they have sandpaper on the stems.

thanks to Yuriy Pitometsu

a new emacs binary site for Microsoft Windows. http://emacs-bin.sourceforge.net/

thx to Aaron Peromsik

see also Which Emacs to Download for Windows and Mac?

Keyboard Layouts Fight! Dvorak, Colemak, Workman, NEO, Bépo, … (minor update)

I do not believe, there's another soul in this world, who has a keyboard & keybinding setup more efficient than me.

sorry my friends. I had to say that.

Emacs: How to Override Minor Mode Keybinding (major update)

emacs: show isearch keys

try the command isearch-describe-bindings. It will list all keys for isearch. That is, when you call isearch-forwardCtrl+s】.

Thanks to Matt Fidler of ergoemacs-mode

see also: Emacs: How to Override Minor Mode Keybinding

smart whitespace-cleanup before save

Steve Purcell got a great idea about whitespace-cleanup.

whitespace-cleanup-mode is a minor mode which calls whitespace-cleanup before saving the current buffer, but only if the whitespace in the buffer was initially clean. It determines this by quickly checking to see if whitespace-cleanup would have any effect on the buffer.

see whitespace-cleanup-mode.

Emacs's Key Notation: What's the difference between "<return>" and "RET"? (thanks to Kumar)

Emacs's Key Notations Explained (/r ^M C-m RET <return> M- meta) (minor update)

Emacs Lisp: Delete Trailing Whitespace on Save and Compact Empty Lines (updated)

Emacs: Interactive Abbrev in Shell (major update)

Emacs Inferior Shell vs Terminal: What's the advantage of running shell inside emacs? (on its own page)


Emacs: What's the difference between {shell, term, ansi-term, eshell}? (on its own page)

emacs: using smex as ido interface to describe-function

if you are using smex, when in smex, you can press 【Ctrl+h f】to jump to describe-function of current command. This is fantastic, because, it basically becomes a ido interface for using describe-function. (the alternative is to use icomplete-mode, but that isn't as good as ido.)

Sacha Chua interviews Mickey Petersen of MasteringEmacs.org

See: 〔Emacs Chat: Mickey Petersen — Mastering Emacs By Sacha Chua. @ http://emacslife.com/emacs-chats/chat-mickey-petersen.html

Sacha Chua is super cute there. And, she's very intelligent, and nice, person. I must say, Mickey Petersen turns out to be a handsome dude. From this video, Mickey is in his spacious living room, well-groomed, wears a sparkling clean white shirt, into cooking. So is a bit different from typical hacker one'd imagine.

emacs vs vim tip jars 2014-09-04
“The Philz baristas at Facebook have learned their customers' weakness as evidenced by these tip jars. ” (from Jeremy Morrell)

comment at https://plus.google.com/113859563190964307534/posts/6QBHaBSocF8

emacs bookmark-jump

discovered bookmark-jump, updated at Emacs: Using Bookmark Feature. Somehow, i've never used that. (thanks to diesch and RobThorpe on reddit at http://www.reddit.com/r/emacs/comments/2f15sh/emacs_using_bookmark_feature/)

I haven't used bookmark for a couple of years. I use Emacs Lisp: Hotkeys to Open File Fast. Will have to give bookmark another shot.

emacs with-syntax-table pain

it turns out, if you use

(with-syntax-table (standard-syntax-table)
    (modify-syntax-entry ?\« "(»")
    (modify-syntax-entry ?\» ")«")
    ;;     )

it'll actually modify the global syntax table, the one returned by standard-syntax-table that is also used by fundamental-mode. (you can check by defining a function containing the above. Call the function. Then, open a new buffer, set it to “fundamental-mode”, then call “describe-syntax”, and check the french quote character's syntax. (by default, it has a syntax of punctuation.))

(info "(elisp) Standard Syntax Tables")

To work around it, you can just create a new syntax table and set it to a local variable, then call with-syntax-table with that.

for a sample code, see Emacs Lisp: How to Modify Syntax Table Temporarily (updated again. Refresh)

i haven't had time to figure out the detail why “with-syntax-table” is doing that. Maybe a bug, i don't know.

comment at https://plus.google.com/113859563190964307534/posts/WB5r4bg8ifZ

emacs syntax table is a major pain in the ASS!

after a hour, discovered that if you use “with-syntax-table”, and modify the syntax entry, it actually modifies the syntax table globally.

that is, for example, if you define the following:

(defun xah-select-text-in-bracket ()
  "Select text between the nearest brackets.
⁖  () [] {} «» ‹› “” 〖〗 【】 「」 『』 () 〈〉 《》 〔〕 ⦗⦘ 〘〙 ⦅⦆ 〚〛 ⦃⦄ ⟨⟩."
  (with-syntax-table (standard-syntax-table)
    (modify-syntax-entry ?\« "(»")
    (modify-syntax-entry ?\» ")«")
    (modify-syntax-entry ?\‹ "(›")
    (modify-syntax-entry ?\› ")‹")
    (modify-syntax-entry ?\“ "(”")
    (modify-syntax-entry ?\” ")“")

    (let (pos p1 p2)
      (setq pos (point))
      (search-backward-regexp "\\s(" nil t )
      (setq p1 (point))
      (forward-sexp 1)
      (setq p2 (point))
      (goto-char (1+ p1))
      (set-mark (1- p2)))))

and call the command, then, open a new buffer, set it to “fundamental-mode”, then call “describe-syntax”, you'll see tha the standard syntax table used by “fundamental-mode” is actually changed.

haven't had time to figure this one out yet. Just want to put out a warning first. My code here: Emacs Lisp: How to Modify Syntax Table Temporarily is not good since it modifies global syntax table. Keep tuned in for updates.

Emacs Lisp: How to Modify Syntax Table Temporarily (updated. Thanks to Jon Snader's mention @ http://irreal.org/blog/?p=2945)

Like it? or share

Past Articles by Date