Xah Emacs Blog Archive 2018-07
emacs indentation problem and universal framework
emacs lisp. going to do a biggish job. write a tutorial for how to implement programing language indentation in major mode. and do it for my xah-js-mode.
it'll take about 6 hours.
emacs lisp. to write a indentation command, is a clean text processing task. given a text file and cursor position, you want to add certain tab or space in beginning of certain lines. Not trivial, but nor really difficult.
However, if you want to follow emacs convention, the task becomes somewhat more complicated. because emacs has a very stilted convention that's also half-assed. if you publish your mode, you basically have to follow this convention, else hacker types no welcome it.
emacs has 1 major problem. it tries to have a universal system, so if all major mode follows it, then users can make 1 config across all major modes. e.g. set up tab/space for indentation, indentation commands, comment, syntax coloring, completion, etc.
the problem is, some of these systems are really lousy. That's why you end up with each major mode doing its own way, or inventing complete new UI. Most notable is completion, indentation/tab/space setup.
Note, the “universal system” is modern jargon is Framework or API. However, in emacs lisp, they are not really that, because the entire elisp doesn't follow API mindset, partly by intention, cuz rms wants it to be “free coding”, or, fear if there's API, 3rd party will hijack.
2018-04 gonna have to get up and walk for an hour per day. Else my left hand is going to crippledom fast.
notes on today's emacs meetup Mountain View. 2018-07-28
today's emacs meetup was fun. https://www.meetup.com/Emacs-SF/events/252240839/attendees/
We met • Jeff T • Michael W • Leslie L • Harry S • Arthur A G • David S • Huynh K • Gaurav J • and me Xah L.
Gaurav provided us with a super nice conf room with a view from 10th floor! and we had few nice light presentation on the spot!
emacs meetup SF has a github page https://github.com/Emacs-SF/
and i think @JaafarTrull keep notes on it. Not speaking for jeff or team, but i think we are looking for more lightning talks, or longer presentations. So if interested, get in touch with jeff.
Harry gave a short talk about using emacs with UI to “the best” dictionary, 1913 Webster's. you download a dict source file, a star dict command line UI, and a emacs UI wrapper. you can see setup at https://github.com/hrs/dotfiles/blob/master/emacs/.emacs.d/configuration.org#look-up-definitions-in-webster-1913
irreal wrote about using emacs with 1913 Webster dictionary at http://irreal.org/blog/?p=6546 am going to set it up myself. I'd love it. Yes, what dictionary you use matters.
am a dictionary nerd. I used to lookup words some 50 times a day, for 20 years. Still do 5 or so times daily now. You can read up what i have to say at American Heritage Dictionary vs Merriam Webster Collegiate btw, the worst dictionary is the one bundled with Mac.
For dictionaries, my ranking is:
- American Heritage.
- Merriem Webster UNABRAGED (weights a brick).
- 1913 Webster, WordNet, Google, wiktionary, are all rather lackluster, but each has its uses.
- Merriam Webster Collegiate, which is what you see everywhere and online, is the worst.
Well, the one bundled with Mac, which is “New Oxford American Dictionary”, is worser than worst. see American Heritage Dictionary vs New Oxford American Dictionary
by the way, if you want emacs commands to lookup any online dictionaries (or web search, function doc lookup etc), try xah-lookup.el Emacs: xah-lookup.el, Lookup the Web can setup to use emacs builtin browser eww
for next emacs meetup in Mountain View, i think am going to bring my Kinesis Advantage2 Keyboard Kinesis Advantage2 Keyboard Review so you guys can try it. it'd be fun.
another thing i learned from the meetup is, @JaafarTrull gave a lightening talk about emacs lsp mode. LSP is Language Server Protocol. It allows emacs to connect to server dedicated to parsing langs. So you get better completion etc due to real parser at server.
the hideousness of emacs lisp regex
wasted 1 hour debugging emacs lisp replace-regexp-in-string. the replacement string cannot be (match-string 1 var), must be "\\1"
Elisp: Region, Active Region
and a reddit question
The Different Meaning of “closure”
What's Closure in Programing Languages?
see bottom there
elisp, nested dolist is a pain
ok, nested dolist is a pain in the ass. very hard to manage and edit.
in Wolfram Language, loop function usually accept a optional predicate function, so that if it returns true, the loop exits. This is much better than elisp's catch/throw.
[see Elisp: Exit Loop/Function, catch/throw]
if you want to understand Wolfram Language's such exit, search online for “NestWhile” https://reference.wolfram.com/language/ref/NestWhile.html
Emacs: Xah Fly Keys Tutorial
minor update. Thanks to George Jones.
emacs keyboard used in 70s and 80s
posted to reddit.
hi guys, am trying to get an overview of keyboards used by emacs people during 70s and 80s. If you been there, could you list the keyboards/terminal you used, and year period, before 1990, as much as you can remember?
if you been there, help me out. thanks.
What Keyboards Are Used for Emacs in 1970 and 1980s?
emacs keyboard history
new version of emacs tutorial is out
Buy Xah Emacs Tutorial
new version is sent out to all who got it after 2014, or those responded to previous update.
if you should've got it but didn't , email me.
there are some of you who bought it twice, or otherwise donated extra. Thank you very much.
autoload and require
answer to reddit question.
autoload is more for interactive use purposes.
require is for loading libs.
so if you are writing lisp code and need another package, always use
if you are setting up init file, best to set up
autoload when possible. Because that way, it saves startup time. The file is loaded only when user actually calls it. Best example of such are programing language modes.
see Elisp: load, load-file, autoload
List of Emacs Starter Kits (minor update)
emacs default key
my reddit post
Perhaps, look at it this way:
most emacs users use emacs default keys because it's the default. This is same with qwerty vs dvorak situation, or any tech. It takes quite some effort to change things out of ordinary. e.g. first one must be aware there are alternatives. This also rules out most newbies for not using default key.
for those who use spacemacs and change it to emacs default key, probably because, they already have experience with emacs. The default keys are burned to muscle memory, which is hard and painful to change.
default key has other advantages other than habit. e.g. dvorak layout is more efficient, but everytime you goto library, or use other computer, it's a problem. And other people can't type on your keyboard. This also applies to PC keyboard vs those fancy ergo ones such as ergodox.
another advantage of default is that it's the “official”. As with most other things, you want to stick to official. Unless one really learned otherwise, such as by words of mouth and established a trust on X.
vi is more popular simply because vi is bundled with unixes. Emacs require install. This is still true today on linuxes.
people switch away from default mostly due to need. e.g. those who got hand pain. Those who have interest in efficiency. (which may be the same reason that drew them into emacs in the first place)
i used emacs default keys 100% for the first 6 years of my emacs life.
emacs meetup in Mountain View, CA!
mark your calendar.
and several recent articles about lisp the programing language Xah Programing Blog
lisp machine keyboards
several recent articles photos about lisp machine keyboards Xah keyboard Blog
Elisp: Hash Table
updated. Now includes literal expression for hash table.
Emacs: Xah Math Input Mode
updated. fixed emacs 26 change of
ucs-name. now, selection such as RIGHTWARDS ARROW works again.
emacs 26 elisp change. ucs-names is now a hashtable
2018-07-09 emacs 26 change.
ucs-names was alist, now it's hash table.
update all your code
you can use this wrapper:
(defun xah-math-input--name-to-codepoint (@name) "Returns integer that's the codepoint of Unicode char named @name (string). Version 2018-07-09" (interactive) (if (version<= "26" emacs-version) (gethash @name (ucs-names)) (assoc-string @name (ucs-names) t)))
elisp name “my/” prefix, slash or hyphen?
reddit question https://www.reddit.com/r/emacs/comments/8waf1y/whats_the_deal_with_my_notation/e1v4ptp
as many said, it's a convention. This convention, is not official though. Official gnu emacs stance is to use hyphen.
technically, slash is slightly better, as it distinguishes name space purpose from word separator. However, because it's not gnu convention, so it has problems. eg say you dev all your packages with slash. But one day your package becomes popular, and you are considering to assign paper to be part of gnu emacs. Then, you got the problem of changing all your names, thus break all init out there...
real solution, is to get FSF emacs team to introduce namespace. It is not hard to do, if one do not consider 100% backward compatibility to 30 years back, but typically they want that, for reasons in my opinion is not practical. Among other social problems of gnu emacs dev. Major one is that in the fsf culture, no one really takes a leader role to get things going. It's arguments and arguments, and rms now and then say things by hegemony. Technically he should not have power over any non-political emacs issues, as that is understood to be the current maintainer. But in reality, far from it.
besides the slash vs hyphen issue, there are others, e.g. using question mark for all predicate functions. (i.e. function that returns true/false). The question mark is superior, and is the convention in scheme/racket lisp, ruby, clojure. Emacs lisp tradition is p, however, it's quite lousy, as lots functions end in p but is not predicate, and for predicate, some are “-p” some just “p”. Again, we have the backward compatibility vs progress problem. Note, many popular packages on melpa, use the question mark convention. e.g. the package “dash”.
Emacs: Insert Date Time
minor fix. now if
universal-argument is called before, and there's selection, the selection is deleted only after the choice of format is made. (before, it delete selection first, then prompt choices, which is not good, because sometimes you want to see what's the format used before you chose.)
Emacs: Check Parenthesis/Brackets Balance
better doc. also, don't move cursor to end of buffer.
emacs highlight cursor line
global-hl-line-mode. does anyone uses it?
Emacs: Init File Tutorial
twitter vote https://twitter.com/ErgoEmacs/status/1014017207154630656
emacs indium https://github.com/NicolasPetton/Indium
this seems to be the upcoming best emacs package set for web dev.
thanks to https://twitter.com/ebanders for the tip
one extreme complex fak. you can't compile jsx with TypeScript unless you let TypeScript know react js file paths. but now you can't unless they have .ts suffix. but if you change them to .ts , faking 1 thing leads to 10 more complexity.
- draft support of jsx syntax highlight.
- support .jsx file suffix.
xah TypeScript mode. https://github.com/xahlee/xah-typescript-mode
also now support tsx file extension. beta
Emacs: Run Current File
xah-run-current-file now support .tsx (TypeScript + react + jsx)