Xah Emacs Blog Archive 2012-04
another bug report. “GNU Emacs 24.1.50.1 Bug: find-dired on Filenames with Spaces”. See: Emacs Misc Bugs
Eli Zaretskii (a long time emacs dev) gave a detailed explanation about bi-directional text feature in emacs 24. At Source groups.google.com
GNU Emacs 24.1.50.1 bug: find-dired. See Emacs Misc Bugs
Updated. 5 solutions for the Decimalize Latitude Longitude problem, in elisp, python, ruby. Programing: Decimalize Latitude Longitude
Emacs *scratch* Poem
The emacs scratch buffer thread on gnu.emacs.help newsgroup (Source groups.google.com) is rolling, and became a verse fodder.
emacs's *scratch* amounts to a bitch but we cannot ditch the banner of our church
Emacs 24: Oddity with Bidirectional Language/Script Support
first, here's my emacs version am testing from. “GNU Emacs 24.0.93.1 (i386-mingw-nt6.1.7601) of 2012-02-15 on MARVIN”
Some facts:
- Right arrow key → is bound to
right-char
. - Ctrl+f keys is bound to
forward-char
.
Now, paste this sentence in emacs “(كتاب ألف ليلة و ليلة)”. Then, hold down right arrow key, then when cursor moves into the Arabic text, it'll suddenly reverse direction, and move right to left, until it reaches the left most arabic char sequence, it'll jump back to the english text and continue move right.
Now, do the same but using forward-char
【Ctrl+f】. Actually, the same behavior is observed visually!
from Eli Zaretskii's post (at Source groups.google.com), it seems to be the expected behavior. But then what's the difference of forward-char and right-char? Am totally confused now.
In emacs 23, holding right arrow (or Ctrl+f) simply move cursor to the right, ALWAYS. I was expecting this from emacs 24's right-char
.
Programing: Decimalize Latitude Longitude
Programing: Decimalize Latitude Longitude
Emacs 24 Improvements: copy/paste, describe-char, calc keymap See: Emacs 24 (Released 2012-06)
separated into a new page for easier search engine find: Emacs Dired Recursive Load Error 2011-05-26
updated. Transform HTML Tags with Emacs Lisp. Much thanks to Jon Snader.
minor update: Process HTML with Emacs Lisp: Transform FAQ Tags. Thanks to jcs.
Emacs: kill-buffer Induces Buffer Accumulation
updated Emacs: Problems of the Scratch Buffer
Lisp: Check If a Item Exist in a List
wrote this yesterday, when i want to know if a item exists in a list.
(defun sequence-to-alist (mySequence) "Take a sequence mySequence and returns a association list. Each element's cdr is “t”. Example: (sequence-to-alist (list 3 4 5)) ⇒ ((3 . t) (4 . t) (5 . t)) This function is useful when you need to check a element is in a list, using `assoc' without loading CL library." (mapcar (lambda ($x) (cons $x t) ) mySequence))
ends up not using it. But, i think even if i need it, i probably should just use whichever is in the CL package. Btw, of you Common Lisp coders, what function would it be?
Answer: there's a elisp function member
. (thanks to [Elias Mårtenson https://plus.google.com/115209488640908180409/posts].)
Updated the navbar for emacs and elisp manual. The navbar now floats at bottom right. e.g. Emacs manual: Buffers. Elisp manual: Synchronous Processes.
aspell's Dismal Vocabulary Size
Elisp vs Perl: Validate File Links
Ruby Creator Matz: How Emacs Changed My Life
updated: Emacs Lisp: google-earth Command
Updated: how to query user for string, file path, regex, with name completion and input history support, at Emacs Lisp: How to Write a Command.
Twitter Humor: Chrome vs Emacs, Version Numbering Pressure
Got this tweet today:
bamanzi: «Emacs压力好大 RT @riku: 我擦, Chrome 的版本都已经到 20 了。»
Translation:
riku: «OMG! Chrome's version reached 20.»
bamanzi: «pressure is on Emacs»
Updated. For you Linux and Mac users, please help test. Emacs: Open File in External App 🚀. Let me know if it works.
ErgoEmacs Keybinding is now in the MELPA repository
ErgoEmacs Keybinding is now in the MELPA repository. (thanks to [2012-04-09 Steve Purcell ] ( https://github.com/purcell ))
I've also added instructions for check out using svn. For how to use melpa/svn to install, see: ErgoEmacs Keybinding.
Large Scale Software Development with Elisp
Scheme Lisp is Coming to Emacs!
(meeting - Tue Apr 10 19:00 - Rocky Bernstein: Large Scale Software Development with Elisp)
He lives in relative obscurity yet his software is used daily by millions. Rocky Bernstein, former IBM Researcher, Chaitin co-author and 30 year developer walks us through a mosaic of development techniques focusing on personal software scalability.
The long time Free Software developer is best known for his decade of debugger development using Emacs Grand Unified Debugger as a front-end for his other works:
- Ruby Debugger (ruby-debug)
- Python Debugger (pydb)
- Perl Debugger
- POSIX Shell Debuggers for bash, Korn Shell, zsh and GNU Make
Additionally, Rocky is the author of libcdio: the GNU CD I/O and ControlLibrary. Allowing multimedia assessing of CD-images (includingISO-9660) in an OS and device-independent way, it is used in FreeBSD, NetBSD and nearly every Linux distribution.
Location: Meetup HQ, 9th Floor 632 Broadway [ http://maps.google.com/maps?q=632+Broadway,+New+York,+NY&hl=en&sll=40.74461,-73.994984&sspn=0.013509,0.016587&oq=632+broadway&hnear=632+Broadway,+New+York,+10012&t=m&z=17&iwloc=A ]
Official announcement: www.lispnyc.org
Slashdot news: Guile Scheme Emacs-Lisp Compatibility Matures At http://news.slashdot.org/story/12/04/02/197221/guile-scheme-emacs-lisp-compatibility-matures
Xah Emacs/Elisp Tutorial Update 2012-04-07
New version of my emacs tutorial ready.
If you've bought it before, please just email to Xah@XahLee.org with subject “emacs tutorial upgrade”.
If you haven't bought it yet, you can get it for just $10. See: Buy Xah Emacs Tutorial. Currently about 350 HTML pages, about 1k pages printed.
Also, you can subscribe my emacs blog from Google Plus, facebook, twitter, or Google Reader. See: Xah Lee Feeds. Help spread the word. Thanks.
ErgoEmacs pt-Nativo Portuguese Efficient Keyboard Layout
One of the layout supported by ErgoEmacs Keybinding is pt-Nativo for Portuguese. [see Supported ErgoEmacs keyboard Layouts] The website for br-native is gone.
Here's a page containing basic info about the pt-Nativo layout, and the installation files for Windows and Linux. pt-Nativo (Portuguese) Efficient Keyboard Layout (Thanks to Xavier Pinho for the archive.)
updated. Simplified. Emacs Keys: Define Key. Also, separated into a new page: Emacs Keys: Syntax.
Updated; new page. ELisp: Beware of Region Boundary Change
Updated. Emacs Lisp: Command to Update RSS/Atom Webfeed (thanks to jcs for feedback)
updated: Ask ErgoEmacs.
updated: Problems of grep in Emacs
updated (new page): Emacs: Inconsistency of Search Features
updated (new page): Emacs: Change to Title Case 🚀
when quitting emacs save-buffers-kill-terminal
【Ctrl+x Ctrl+c】, emacs will ask to save unsaved buffer, but doesn't switch it to front to let you see.
Is there a hook or variable to make it so?
Note: save-buffers-kill-terminal
eventually calls save-some-buffers
. According to its doc string, it says you can press Ctrl+r to view the buffers in question. (this doesn't work in ErgoEmacs for some reason, i'll have to look into) In anycase, i want automatic switch.
describe-syntax
【Ctrl+h s】 nice.
other keys i learned in past months and use heavily are:
- Ctrl+x Ctrl+j (
dired-jump
). Locate the current file in dired. - Ctrl+x Ctrl+q (
toggle-read-only
). I use it only in dired, which actually callsdired-toggle-read-only
→wdired-change-to-wdired-mode
. Lets you change file names by edit.
Emacs: man for woman?
got this comment.
«You define man as an alias for woman? woman doesn't work all the time, if it fails, how do you invoke man?»
major lol. ☺ (See: Emacs: Command Name Alias.)
Btw, why doesn't alias man to woman work? I have this alias: (defalias 'man 'woman)
but it still calls man when M-x man.
Here's why, answer given by Stefan Monnier [http://www.iro.umontreal.ca/~monnier/]:
The reason is that woman.el
begins with (require 'man)
, so when you Alt+x man
, it autoloads woman
, which loads man
, which redefines man
thus overwriting your defalias.
So, to get what you want, do this:
(defalias 'man 'woman) (eval-after-load 'woman '(defalias 'man 'woman))
Emacs Lisp for Text Processing and Wishes
Elisp is really cool.
been using it to do text processing like perl for several years now.
About every day, my script goes over few thousand files.
(doing report, or find replace.
Though, the files sizes are each under 100k) No problem.
(caveat: always use with-temp-buffer
or with-temp-file
, never use find-file
to open file, else it can be 40 times as slow. [see find-file vs with-temp-buffer])
recently ditched my last perl and python scripts i use daily for this purpose. (one perl for validating local links of HTML files. one python for find/replace)
It's slower than perl/python, but fast enough for interactive use, and more powerful. More powerful is especially true when you need to deal with nested things such as HTML that's out of regex's reach. (because with emacs's buffer datatype, you just move the cursor about, save positions, grab text, etc. (From my perl and python experience, all you can do there is apply regex to each line or whole file. Anything more complex than that gets complex quickly, and you basically have to start to implement your own text buffer, or use/write a parser.))
(just did a speed comparison of my perl and elisp script that check local links of 5k HTML files.
The script algorithm used are not exactly identical, but do the same thing for my need.
Perl runs 20 seconds.
Elisp 44 seconds.
(the elisp is called interactively in emacs, as opposed to emacs --script ‹script name›
in shell.))
2 wishes:
- Wish elisp would have some heredoc mechanism [see PHP: String Syntax] [see Python: Quote String] . Because the emacs regex backslash escape is practically unreadable (which leads to major problem in regex find replace if you slipped a slash).
- Wish elisp can spawn background process, so that while something is running it doesn't freeze the world over. (i don't actually wish it introduces threads, which i knew little about, but knew it's shit in a programing lang. I hope it to be something more like unix's background process.)
rant: Emacs Lisp: read-from-minibuffer Propels Deep Questions
Emacs: Single Key for isearch
one of the key i use the most often is isearch.
if you want a single key to do isearch, you can define it this way.
(global-set-key (kbd "<f8>") 'isearch-backward) (global-set-key (kbd "<f9>") 'isearch-forward) (defun xah-isearch-hook () "Hook for `isearch-mode-hook' " (define-key isearch-mode-map (kbd "<f8>") 'isearch-repeat-backward) (define-key isearch-mode-map (kbd "<f9>") 'isearch-repeat-forward) ) (add-hook 'isearch-mode-hook 'xah-isearch-hook)