Xah Emacs Blog

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Tips & Tricks for emacs and emacs lisp.

“xah-filter-list” & “xah-string-match-in-list-p”

Coding is tedious. T E D I O U S.

spend a hour to write these today:

(defun xah-filter-list (φpredicate φlist)
  "Return a new list such that φpredicate is true on all members of φlist.
Note: φlist should not have a element equal to the string \"e3824ad41f2ec1ed\"."
  (let ((ξresult (mapcar (lambda (ξx) (if (funcall φpredicate ξx) ξx "e3824ad41f2ec1ed" )) φlist)))
    (setq ξresult (delete "e3824ad41f2ec1ed" ξresult))
(defun xah-string-match-in-list-p (φstr φlist-of-string φmatch-case-p &optional φreverse-match-p)
  "Return the first element in φlist-of-string if φstr occur in φlist-of-string, else false.

if φreverse-match-p is true, change the direction of match. That is, true if any element in φlist-of-string occur in φstr.

φmatch-case-p determines whether case is literal for the match.
No regex is used.
Existing match data is changed. Wrap it with `save-match-data' if you need it restored."
  (let ((case-fold-search (not φmatch-case-p)))
    (if φreverse-match-p
          (catch 'myTagName
             (lambda (ξx)
               (when (string-match (regexp-quote ξx) φstr ) (throw 'myTagName ξx)))
        (catch 'myTagName
           (lambda (ξx)
             (when (string-match (regexp-quote φstr) ξx ) (throw 'myTagName ξx)))

haven't had time to polish it.

they are dumped in “xeu_elisp_util.el” at github.

why i wrote them? here's the problem.

i have a list of files generated by

(find-lisp-find-files ξ-inputPath "\\.html\\'\\|\\.xml\\'")

but i want to filter out some directories. In any other lang, including bash or unix util, you can easily add a option or filter. Emacs lisp can't do. The “find-lisp-find-files” is some kinda obscure function few know. Not much documentation, and not very flexible. So, i had to write my own.

so, the code now is:

              (lambda (φh) (not (xah-string-match-in-list-p φh ξ-skip-list "match case" t)))
              (find-lisp-find-files ξ-inputPath "\\.html\\'\\|\\.xml\\'"))

it's at “git/xahscripts/elisp/xah_site_move.el” (by the way, this is one of the larger code i spend a couple weeks to write. It is used to split my site into several domains. Basically, given a directory D, and a list of pairs, each pair is 2 full file paths, from and to. Correct all relative links of html files in D according to the from/to pairs. The code is about 1k lines. The bulk is at “xah_emacs_xahsite_path_lisp_util.el”. The task is quite more complex than i imagined. (i wrote them in ))

comment at https://plus.google.com/113859563190964307534/posts/4HmTw4W7tg8

i haven't done much emacs blogging in past week. Mostly focusing on writing my tutorials on JavaScript and Web Dev.

Matt is working on http://ergoemacs.github.io/ergoemacs-mode/ diligently as always. Code commits and answering bug reports patiently every day. Every other day i git pull, hundreds of line changes. Amazing.

Mastering the Tools of the Trade

Several tutorials for programers:

I spend 5 years to write them. You spend 5 minutes to read them.

If you are a computer science college student, or if you are pro programer in lang X and want to learn lang Y, then read them. Just these, and the spec or official documentation. (usually linked from each page)

if you like them, you can buy all. Entire xahlee.info, formatted for offline reading. ∑ Xah Code

Xah Linux Box Configurations

A video review of Slimblade vs L-Trac Trackball. See bottom there.

Future and Policies of Books

I got this in my email, from Amazon: http://www.readersunited.com/

it's not about emacs, but about policies and future of ebooks. In short, there's a dispute between Amazon and another big company. Amazon, claims to want to lower price of ebooks, but the publisher refuse.

If you have any interest in policies in society and books, check it out.

Unicode is quite interesting, not just for fun emoticons 👽 and math ∑. Because, when you go deep, it is about ALL grapheme and logographs and symbols of ALL human's writing systems, past and present. See Unicode Characters ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥.

toggle-read-only is obsolete since 24.3. Use read-only-mode instead.

new version of emacs tutorial is out. Buy Xah Emacs Tutorial. Thanks for reading.

Master JavaScript in 1 Month

again, heavy work on JavaScript in past month. Result of 1 year study. More complete and in-depth than my 8 years emacs lisp haphazard blog effort.

web programing, tablets, phones, are the most vibrant field in programing since perhaps 2008. JavaScript rules there.

hope you like it, buy it. Xah JavaScript Tutorial

Complete guide to choosing a mouse. Which one is for you? Computer Mouse, Trackball, Input Devices

replace html chars to unicode

sometimes in posting html code to forums, it's painful to html-encode the greater and less signs, and the ampersand. You can never be sure whether the site accept html tags or not. Here's little command that convert it to Unicode.

(defun xhm-replace-html-chars-to-unicode ()
  "Replace HTML < > & to Unicode chars 〈 〉 &.
This works on the current text selection or block of text.

See also:
  (let (bds p1 p2 myText)
    (setq bds (get-selection-or-unit 'block))
    (setq myText (elt bds 0) p1 (elt bds 1) p2 (elt bds 2))
    (replace-pairs-region p1 p2 '( ["&" "&"] ["<" "〈"] [">" "〉"] ))))

part of Emacs: Xah HTML Mode.

you'll need Emacs Lisp: get-selection-or-unit

Docstring Convention: Python vs Emacs Lisp (updated)

from reddit:〔〈changing emacs documentation system from texinfo〉 @ http://www.reddit.com/r/emacs/comments/2bummt/changing_emacs_documentation_system_from_texinfo/

YES. Emacs Should Adopt HTML as Texinfo Replacement

somebody loved emacs over at w3c. Look at http://www.w3.org/TR/2011/REC-CSS2-20110607/cover.html, view source, bottom.

Xah Emacs Blog Archive 2014-06 to 2014-06

this is excellent. 〔How to Make an Emacs Minor Mode By Christopher Wellons. @ http://nullprogram.com/blog/2013/02/06/

via jcs

Steve Jobs on keyboard. something is coming. https://onkeyboards.com/

Jesse Vincent's keyboard design is near completion.

Jesse Vincent, co-founder and CTO of Keyboardio, .

the video is a bit of marketing, but nevertheless, it's a excellent keyboard. Visit Vincent's site at http://www.keyboard.io/

Why Microsoft Outlook has 【Ctrl+f】 for forward email, while every other Microsoft software has it for Find? Reminds me of emacs & rms. http://blogs.msdn.com/b/oldnewthing/archive/2014/07/15/10542285.aspx

via Sujith Abraham

fixed a bug. Yesterday's change broke getting http links. Emacs Lisp: Command to Extract URL

by the way, the command is in Emacs: Xah HTML Mode. So, github to be continuously updated.

Emacs Lisp: Ban Syntax Table

Are you using Emacs Gnus to read webfeed? emacs gnus doesn't support atom format last i heard. Try elfeed. https://plus.google.com/+XahLee/posts/5JrhNjhtXRT

Emacs Lisp: Command to Extract URL (updated code. Now works on both single/double quoted string.)

Emacs's Mode Line Suggestions (repost)

Microsoft Keyboard: How to Disable the F Lock Key (repost)

Emacs Keybinding: the Power of Key Sequences (minor update)

there's a ergoemacs keybinding for the editor Light Table. See: https://github.com/nikitakit/LightTable-ErgoEmacs

JavaScript is the future. I worked out a tutorial in the past year. Much more in depth than my 10 years dabbling in emacs lisp. Why would you read my tutorial when there are lots on the web? Because i believe there's nothing better out there, except the printed books. In particular, it is written in my unique Xah Style. Namely, simple, example based, and as close to formal language as possible. (the “formal language” part may scare you off, but try it.) Xah JavaScript Tutorial

Tweet it, link to it, buy. Thank you.

emacs lisp: twitterfy-shorten text

(require 'xfrp_find_replace_pairs)
(require 'xeu_elisp_util)

(defun xah-twitterfy ()
  "shorten words for twitter."
  (let* ((bds (get-selection-or-unit 'block))
         (p1 (elt bds 1))
         (p2 (elt bds 2)))
    (replace-pairs-region p1 p2 '(
                                  [" are " " r "]
                                  [" you " " u "]
                                  [" and " " & "]
                                  [", " ","]
                                  ["..." "…"]
                                  [". " "。"]
                                  ["。 " "。"]

it seems that many emacs users don't know these commands. Now and then i hear people surprised by their existence after n years of using emacs. Emacs: List/Delete/Highlight Matching Lines, Sort/Reverse Lines

Emacs Lisp: Filter a List

updated the command to delete current file. Now, will also do backup for buffers that's not a file. Emacs Lisp: Delete Current File

Vim: How to Remap the Escape Key? (on its own page)

fixed “xah-backward-block” Emacs: Move Cursor by Paragraph or Text Block

ergoemacs-mode is now in GNU ELPA http://elpa.gnu.org/packages/ergoemacs-mode.html

yay. We had all to sign papers. The code is primarily by Matthew Fidler. David Capello and me worked on it before.

i want to especially thank my friend Xue Fuqiao (aka xfq) for the suggestion and helping the process.

DAS Keyboard 4 Professional keyboard

DAS came out with a new keyboard. DAS Keyboard 4 Professional keyboard

pity, it's the same old PC form keyboard, ones that whack your hand.

hacker news discussion https://news.ycombinator.com/item?id=7979073

see also Computer Keyboards, Layouts, Hotkeys, Macros, RSI ⌨

emacs lisp: what does “prog1” do?

learned about prog1 today.

(info "(elisp) Sequencing")

thanks to Dan Lentz

Programing Language: Function Dependency

Can Emacs Lisp Fix Its Namespace Problem by Copying JavaScript Practice?

emacs: ergoemacs-mode link change

ergoemacs-mode news, from Matthew L Fidler. Link is changed

https://ergoemacs.github.io/ergoemacs-mode/   ← old
https://ergoemacs.github.io/           ← new

the change is made because: before, when you check out, you get some 100 mega bytes of stuff, which includes the ergoemacs-mode website and all the images about layout.

now, the code and home page are separate github projects.

be sure to update your links.

there's automatic redirect. But some link with specific URL may break, Matt is fixing them. Thanks Matt.

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

emacs: xah fly keys package

for those of you heavy keyboard tinkers, i've pulled dependent commands into xah-fly-keys.

download at https://github.com/xahlee/xah-fly-keys

if you have issue, just file bug report there.

i'll incorporate this into ergoemacs-mode as a theme one day.


there are 2 parts to my keybinding. One is fast-repeat commands, and these are mostly cursor movement commands and text deletion commands. These are in xah-fly-keys, which is also what ergoemacs-mode is about. Typically, these are top 20 commands you use most frequently, and everybody use all of them every minute. 〔➤ Emacs: Fast-repeat vs Non-fast-repeat Commands & Keys

the other part is the hundreds other emacs commands. I've designed a key set for them, as key sequences, 95% complete. Right now they are in my emacs init file. I'll write about it down the road, and push it into xah fly keys.

xah fly keys home page ergoemacs-xah Mode. (naming is yet to be resolved. Not sure it should be ergoemacs-xah or ergoemacs-vi or xah-fly-keys.)

Programing Language: Fundamental Problems of Lisp (minor update)

ergoemacs's 7 years old

;; version 1.0, 2007-08-01. first version.

so, next month, ergoemacs's gonna be 7 years old. The original site: ErgoEmacs Keybinding: a Ergonomics Based Keyboard Shortcut System

Like it? or share

Past Articles by Date