Xah Emacs Blog

Tips & Tricks for emacs and emacs lisp.

emacs 24.4 prelease binary for 64 bits Windows. http://semantic.supelec.fr/popineau/programming-emacs.html#sec-2, by Fabrice Popineau

new version of emacs tutorial. Buy Xah Emacs Tutorial.

tweet, repost, share, buy. Thank you.

spent 3 hours hacking emacs lisp. Created syntax coloring for CSS3 HSL (Hue, Saturation, Lightness) syntax.

emacs xah css mode 2014-04-22
emacs xah css mode

See updates at:

there's functions at Emacs: Working with CSS Color Values that you can call to color any file's hex/hsl color syntax.

Emacs Lisp: Insert Random Number, Random ID, Random Hexadecimal (updated)

Emacs: Copy/Paste History, Multiple Clipboards, Register (updated)

30 minutes job with perl python ruby becomes 5 minutes with emacs lisp: Emacs: Find & Replace Multiple Files by Function: Add Unicod Name

Emacs: Working with CSS Color Values (updated)

Sacha Chua's Emacs Beginner Resources List, and Emacs Videos

Sacha Chua, the incredibly productive and unique emacs hacker, posted a blog about best emacs resources.

Emacs beginner resources By Marie Alexis Miravite. @ http://sachachua.com/blog/2014/04/emacs-beginner-resources/

Thanks to Sacha and Marie for giving my site a high rating.

Sacha recently started to do a lot emacs videos. I've watched them all, except the new ones in the past month. Haven't had a chance to. If i can get over my stage fright, we'd do a emacs Q&A or something similar down the road.

you can watch Sacha's videos, collected at http://sachachua.com/blog/tag/emacs-chat/

actually that's not all the emacs ones. I couldn't find one place that collects all at the moment. Check out all her YouTube at https://www.youtube.com/playlist?list=UUlT2UAbC6j7TqOWurVhkuHQ

her videos are very fun to watch.

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

Emacs Lisp: Converting Decimal & Hexadecimal Numbers (repost)

Emacs Command: Change Unicode Char to HTML Markup

here's a useful emacs lisp command that turns a Unicode symbol into a HTML markup.

(defun xah-mark-unicode (p1)
  "Wrap 「<mark class=\"unicode\" title=\"U+…: ‹NAME›\"></mark>」 around current character.
When called in elisp program, wrap the tag at cursor position p1."
  (interactive (list (point)))
  (let* (
         (ξcodepoint (string-to-char (buffer-substring-no-properties p1 (1+ p1))) )
         (ξname (get-char-code-property ξcodepoint 'name))
    (goto-char p1)
    (insert (format "<mark class=\"unicode\" title=\"U+%X: %s\">" ξcodepoint ξname) )
    (forward-char 1)
    (insert (format "</mark>") )
    ) )

For example:


<mark class="unicode" title="U+26E4: PENTAGRAM" >⛤</mark>

Emacs Lisp Solution: Print All Unicode Characters Who's Name Contains "BULLET"

;; print all unicode chars up to 2^16 who's name contains "BULLET"
  (lambda (x)
    (let ((nn (get-char-code-property x 'name)))
          (and (not (null nn))
               (string-match "BULLET" nn))
        (insert-char x)
        (insert " " nn "\n")
  (number-sequence 0 (expt 2 16)))

See: Emacs Keyboard Macro Example: Insert All Unicode Bullets (updated)

(thanks to Martin for initial solution)

Few days ago we have a challenge: Emacs Keyboard Macro Example: Insert All Unicode Bullets (updated)

For a Python solution, see: Python: Processing Unicode: unicodedata Module Tutorial.

learned a lesson. Never open a PDF in emacs. Never even do it accidentally.

emacs since version 23 can open PDF files. 〔☛ Emacs 23.2 Features〕 It opens PDF file in doc-view-mode. It works by converting the PDF file to png image files. Opening a PDF file in dedicated PDF reader takes 1 or 2 seconds, in emacs it takes 10 or freeze emacs. (and it doesn't work in Microsoft Windows or Mac, because it require some external libs.)

here's how to open PDF as hex, to prevent emacs freezing when accidentally hit a PDF file in dired.

;; open pdf files in hex mode
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . hexl-mode))

emacs 24.4 pretest version is out. Linux only. http://permalink.gmane.org/gmane.emacs.devel/171413

Emacs: Using Eww Web Browser (on its own page)

Emacs Keyboard Macro Example: Insert All Unicode Bullets (repost)

the Microsoft Sculpt Ergonomic Keyboard, a great ergonomic keyboard, reviewed by Øystein E Krog (see comment)

Emacs Lisp's Library System: What's require, load, load-file, autoload, feature? (updated)

one of the most important command, few people knew how to control case sensitivity. Emacs: Find/Replace Tutorial (minor update)

UNICODE Basics: What's Character Set, Character Encoding, UTF-8, and All That? (major edit)

Emacs 24.4: Press F11 to Go Full Screen

emacs 24.4 feature. Call toggle-frame-fullscreenF11】 to go to full screen.

Emacs: Set Unicode Specific Font

Here's how to set specific font for Unicode emoticons (or a range of Unicode characters)

;; specify font for all unicode characters
(set-fontset-font t 'unicode "Symbola" nil 'prepend)

This is very useful. Because, even if you have Unicode font, but emacs still does not display some Unicode emoticons. For example, on latest iBook, Mac OS X, emacs won't display these characters: 😃 😄 😱 😸 👸 👽 👍

updated at Emacs: How to List & Set Font

Delete Duplicate Lines

delete-duplicate-lines will delete duplicated lines in current text selection. The lines need not be sorted. You can try it on this:


New Features in Emacs 24.4

Emacs 24.4 hash-table-keys & hash-table-values

emacs 24.4 has new functions to extract keys from a hash table. Same for values. (but you need to load a library first.) See: New Features in Emacs 24.4 and Emacs Lisp: Hash Table

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

Emacs Lisp: Convert Punctuation Between English/Chinese Forms (updated)

learn the Dvorak keyboard layout, part 1 By Casey Johnston. @ http://arstechnica.com/gadgets/2014/03/my-quest-to-learn-the-dvorak-keyboard-layout-part-1/

glad i got it over 20 years ago.

see also Dvorak Keyboard Layout and My Experiences

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

Vibrant Keyboard Scene: Sweet Dreams DIY Keyboard ⌨

sweet dreams keyboard 71304
Sweet Dreams Keyboard ⌨

updated: Emacs: How to Set Mouse Buttons & Wheel. Shows you how to define mouse buttons, wheel, and how to make commands act on clicked point.

Highlight Words by Mouse Click

with emacs 24.4, you can make mouse right-click to highlight all clicked name. So, you can keep click around. For the elisp code, see updated at: Emacs: Search & Highlight Words (thx to Jacek Wysocki for asking)

the best PC form keyboard is this Logitech G710+ Mechanical Keyboard (updated) If you don't like weird ergonomic shaped keyboard, get this.

emacs 24.4 has unique buffer names. See: New Features in Emacs 24.4

all your key needs. Programable Keypads: Add Extra Function Keys to Your Keyboard (updated)

in emacs 24.4, electric-indent-mode is on by default. For detail, see New Features in Emacs 24.4. If you don't have 24.4 yet, see How to Build Emacs from git Repository

the IBM Model M type 3192-G keyboard, 1985, a keyboard that doesn't have Ctrl key. See in Do Terminals Have Control at Capslock Position? (updated.)

prototype out. Esrille New Keyboard (M-Type & TRON) from Japan. Of the new batch of batman keyboards, i think this is the best.

Emacs: Convert Image Files in Dired (updated)

How to save text selection to file?

got asked this. In vi, you can :n,m w new file name. In emacs, you call write-region, see (info "(elisp) Writing to Files")

emacs 24.4 feature: save/restore Windows Configuration. Emacs: Save/Restore Opened Files, Windows Configuration: desktop-mode

Emacs 24.4: subword-mode & superword-mode

old article. Emacs: Using Bookmark Feature. minor update.

Emacs Lisp: Delete Current File (updated)

Emacs 24.4 Features: Use Emacs as Image Viewer

new version of emacs tutorial. Buy Xah Emacs Tutorial.

tweet, repost, share, buy. Thank you.

Emacs Images Thumbnails Index (regular update)

Emacs Mismatch Chinese/Western Parenthesis

noticed today, if you have a pair of parens, and the first one is Chinese paren, and the second a western paren, emacs will match & highlight them.

steps to reproduce:

  1. call insert-charCtrl+x 8 Enter ↵
  2. type ff08
  3. call insert-char
  4. type 29
  5. call show-paren-mode to turn it on (if turned off, call again)
  6. place your cursor on the opening paren.
  7. you'll see that they are highlighted as a matching pair.

bug or feature?

(M-x report-emacs-bug)

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

Emacs Screen Tour: Dan Lentz's Emacs Screen

emacs screenshot Dan Lentz 2014-03-12

Dan Lentz's Emacs Screen

previous screen articles are put into a page by themselfs:

emacs 24.4 feature, Emacs: Search Current Word

How to Create a APL or Math Symbols Keyboard Layout ⌨ (minor update)

debunking myth. Do Terminals Have Control at Capslock Position?. Michael Lockhart added many old keyboard info, see comment at bottom.

How to Edit Lisp Code with Emacs's builtin features (minor update)

Emacs 24.4, Pretty Lambda λ But No Pretty Form Feed ^L

Emacs 24.4 included the Pretty Lambda λ mode. But it didn't include the more practical pretty form feed ^L mode. 〔☛ Emacs: Show Form Feed (^L) as Line〕. Send a bug report to gnu. M-x report-emacs-bug.

Emacs: Pretty Lambda λ in Emacs 24.4

you probably already knew all this, but Emacs: How to Define Keys is the most useful tip for emacs.

minor correction. The link to Google Plus emacs community is this: Google Plus emacs community. I got it wrong in my earlier post today.

Emacs Screen Tour: Emacs Oldbie Nick Alcock

emacs screenshot Nick Alcock 2014-03-07
Nick Alock's Screen

Emacs Screen Tour: Emacs Oldbie Nick Alcock

Emacs Form Feed (^L) Display Suggestions & Tips (minor update)

Emacs: Why I Don't Use paredit

Web Browser Bundled in Emacs 24.4, and How to Build Emacs from git Repository

another emacs meetup, this one at St. Louis, MO, USA, on Mon Mar 17, 6:30 PM, hosted by Deech. See: http://www.meetup.com/St-Louis-Emacs-User-Group/

Emacs Meetup in London

well-known emacs hacker Nic Ferrier, is hosting a emacs meetup in London.

London Emacs meetup http://www.meetup.com/London-Emacs-Hacking/events/169644642/, come along if you can. Only 30 slots!

Show Your Emacs Screen

xah emacs screenshot 2014-03-06

Show Your Emacs Screen

A correction to yesterday's post. auto-revert-mode is local to current file. To turn on globally, use (global-auto-revert-mode 1)

Emacs: How to Quickly Switch Fonts (minor update)

emacs “company-mode”, a name completion framework. I heard many good things about it. Haven't used it myself. You might try it. It's at: http://company-mode.github.io/

emacs auto-revert-mode, due to magit-mode

been using auto-revert-mode in past month. Pretty good. It automatically update buffer when file on disk changed (by some other program or editor)

not sure why it's on. I looked at my init files but it's not there. Must be some packages that turned it on, but not sure what. Maybe magit-mode did it, since i recall upgrading it. A web search confirmed it. (https://groups.google.com/forum/#!topic/magit/shCpTvyyygI) Magit did this sometimes in Feb.

i'll let it sit for a while.

i did notice that some buffers don't auto revert, but after reading the magit change discussion, it seems magit turned it on only for files under git.

so, for better global experience, better turn it on globally.

(global-auto-revert-mode 1)

comment at https://plus.google.com/113859563190964307534/posts/1hdLUre2qJC

Emacs: Let's Kill Texinfo

ESR, the ever trouble maker, wrote a blog about his successful push for GNU emacs dev to use git. 〔Dragging Emacs forward By ESR. @ http://esr.ibiblio.org/?p=5211

he also mentioned, the possibility to kill Texinfo.

it should've been dead since 2007.

in general, GNU and the Open Source have like a 5 to 10 years lag in adopting technology, for reasons that are inadvertently intentional and or simply incapable.

comment at https://plus.google.com/+XahLee/posts/3sSyhonLZCg

Emacs: Sync Environment Variable from Shell

thanks to samhalicke's comment at Emacs: Set Environment Variables within Emacs#comment-1268323059

This emacs package will sync your shell's environment variables on Mac OS X when you started emacs from GUI. https://github.com/purcell/exec-path-from-shell (it doesn't seem to work for Microsoft Windows, as i see no code dealing with registry. 〔☛ Microsoft Windows Registry Tutorial〕)

much keyboard updates.

xfq mentioned that by default, emacs will tally abbrev expansion. See his comment at Using Emacs Abbrev Mode for Abbreviation#comment-1266520734.

i didn't know that. The abbrev tutorial i gave basically thwarted that. Thanks to xfq.

Starting Ask Emacs again, now on weekend. post your questions at comment at Ask Emacs 2014-03-01

Past Articles by Date