emacs lisp: region-active-p vs use-region-p

what's the difference? if you look at the source code, region-active-p just check if transient-mark-mode is on and mark-active is true. And use-region-p added a check for use-empty-active-region.

(defun region-active-p ()
"Return t if Transient Mark mode is enabled and the mark is active.
Some commands act specially on the region when Transient Mark
mode is enabled. Usually, such commands should use
`use-region-p' instead of this function, because `use-region-p'
also checks the value of `use-empty-active-region'."
(andtransient-mark-modemark-active))

who wrote emacs since 2000?

since few years ago, i have a habit to see who's the author of a package.

we all know that GNU Emacs was first emacs written in lisp, and is written by rms. But other than rms, most have a hard time coming up with a second name.

emacs's been around for 3 decades now. There are many fundamental and non-trivial core features in past few years. For example, who implemented the Unicode engine in emacs? who implemented the behavior where arrow down key moves by visual line? Who revamped emacs's completion engine? who implemented right-to-left languages support? who build the Chinese input system?

for packages, it's very easy to see who wrote it. Just Alt+xdescribe-function, then tab a few times to the elisp source code. (if you have emacs compiled, it's better, because binary emacs don't come with source code)

emacs: efficient ways of going into a directory

dired-jump, when in dired, it'll go up a directory. Very cool. Because, normally you have to press ^. But, if you've given a easier key to dired-jump than that, then you just press the dired jump key instead!

you'll need this in your init file first:

(require 'dired-x)

it's bundled with emacs for years.

note: you should never need to call dired directly. Either use dired-jump, or use find-file. (be sure to have ido on, and when in ido-find-file, press 【Ctrl+d】 to go into dir.)

i haven't called dired command for about 6 years. First, i noticed that find-file will do equivalent when your path is a dir. This way, you don't need another key squatting a key spot. Just give a simple key for find-file. (in ergoemacs-mode, the find-file has key 【Ctrl+o】) Then, ido improves the find-file situation by having automated path completion, so that saves you much key strokes. Then, dired-jump replaced other methods to go into dired more than 50% of the time.

why do i want to regenerate? because i'm using several of my own emacs modes for coloring, including xah-elisp-mode, xah-html-mode, xah-css-mode, xah-js-mode, because the default doesn't color many keywords. But in my modes, i constantly add new keywords or tweak how i want them colored. For example, in JavaScript, should coloring be grouped by keywords, object name, function name, or native object vs hosted object, or methods vs properties, etc. So, when i made a change to how the mode colors, i sometimes want to update all pages on my site.

;; Thanks to everyone for their suggestions for refinements of this
;; package. I particularly have to credit Michael Cook, who
;; implemented an incremental completion style in his 'iswitch'
;; functions that served as a model for icomplete. Some other
;; contributors: Noah Friedman (restructuring as minor mode), Colin
;; Rafferty (lemacs reconciliation), Lars Lindberg, RMS, and others.

it mentioned Noah Friedman , which i recognize, thank to Nick Alcock (who is currently the great mole with all sensors extended).

icomplete doesn't have flex matching as ido. (that is, matches middle of the word) However, it supports wildcard. For example, when you Alt+xexecute-extended-command looking for a command named “abc”, you can type “*b” to make the completion candidates show.

Make Ido Mode Display Vertically

The command youtube-dl has a package in Ubuntu's apt-get, but it's outdated and doesn't work. I learned from Christopher Wellons that it has a website. Wellons was recently interviewed by Sacha. There are lots goodies in Wellons's blog. Check it out.

and, a interesting thing about vimrc syntax is that its comment starts with "

that's right, a single double quote at the beginning of line. I used another quote at the end of line just to make it familiar and save myself trouble of creating another CSS to deal with syntax coloring of vimrc code.

Elisp: How to Write a Filter Function, and Never Indent Your Code

Xah's edict of the day: never use dolist. Never use lisp macro. Never manually tuck your parens or indent a line. And, don't use CL.

the ideal format for the above code should be one single line.

which, is common in Mathematica. The editor shall display it nicely.

one thing lisp doesn't make this possible is its line-oriented comment syntax.

btw, there's a interesting tidbit in the above, that's the trick of using “logand” (binary logical and) to compute whether a integer is even. I got it from the CL lib in emacs. (info "(elisp) Bitwise Operations")

for more about how indentation should be ban'd, its relation to language syntax design, see:

emacs lisp, bad style, good style

discovered a very bad form in one of the core elisp file.

(defunadd-to-invisibility-spec (element)
"Add ELEMENT to `buffer-invisibility-spec'.
See documentation for `buffer-invisibility-spec' for the kind of elements
that can be added."
(if (eqbuffer-invisibility-spect)
(setqbuffer-invisibility-spec (listt)))
(setqbuffer-invisibility-spec
(cons element buffer-invisibility-spec)))

the if there should be when.

this is in subr.el

2014-06-03

emacs key Ctrl+?

some 7 years ago, i wrote that one of the key you shouldn't define is 【Ctrl+?】.

xfq asked me where did i read that, but i couldn't remember where in the emacs/elisp manual.