Xah Emacs Blog

Xah Emacs Blog Archive

for keyboard fans, goto Xah keyboard Blog

12 years ago, my emacs tutorial was free, and under creative commons license. And i was using elisp as my all-weather scripting lang.

xah emacs tutorial 2008 QNz58
xah emacs tutorial script, year 2008.
; 2008-06-12

; make my website emacs tutorial into a zip for download

; primarily, this script will make a zip file out of a directory and place the zip on a dest dir.
; however, there are few little things that needs to be done when archiving a dir for distribution:
; • remove temp files and dir that isn't supposed to be pulic. Temp are those starting with “xx”
; • remove emacs backup files, osx's “.DS_Store”
; • create a parent dir and add css files and icon files
; • for each file, remove the javascript lines that are Google's web stat bug
; • for each file, fix no longer correct relative links to “http://xahlee.org/...”.

;;;; user parameters

; root dir to work with
(setq webroot "/Users/xah/web/") ; must end in slash

; list of source dirs relative to webroot
(setq sourceDirsList (list "p/time_machine"))

; destination dir path, relative to webroot
(setq destDirRelativePath "diklo")

; dest zip archive name (without the “.zip” suffix)
(setq zipCoreName "time_machine")

; whether to use gzip or zip.
(setq use-gzip-p nil)

;;;;

(setq destRoot (concat webroot destDirRelativePath "/"))
(setq destDir (concat destRoot zipCoreName "/"))

;;;; copy to destination
(mapcar
 (lambda (x)
   (let (fromDir toDir)
     (setq fromDir (concat webroot x))
     (setq toDir
           (xah-drop-last-slash (concat webroot destDirRelativePath "/" zipCoreName "/" x)) )
     (make-directory toDir t)
     (shell-command (concat "cp -R " fromDir " " toDir))
     )
   )
 sourceDirsList)

; copy the style sheets over, and icons dir
(shell-command (concat "cp /Users/xah/web/lang.css " destDir))
(shell-command (concat "cp /Users/xah/web/lbasic.css " destDir))
(shell-command (concat "cp /Users/xah/web/lit.css " destDir))
(shell-command (concat "cp -R /Users/xah/web/ics " destDir))

; remove emacs backup files, temp files, mac os x files, etc.
(shell-command (concat "find " destDir " -name \"*~\"  -exec rm {} \\;"))
(shell-command (concat "find " destDir " -name \"#*#\"  -exec rm {} \\;"))
(shell-command (concat "find " destDir " -type f -name \"xx*\"  -exec rm {} \\;"))
(shell-command (concat "find " destDir " -type f -name \"\\.DS_Store\"  -exec rm {} \\;"))
(shell-command (concat "find " destDir " -type f -empty -exec rm {} \\;"))
(shell-command (concat "find " destDir " -type d -empty -exec rmdir {} \\;"))
(shell-command (concat "find " destDir " -type d -name \"xx*\" -exec rm -R {} \\;"))

;; change local links to “http://” links. Delete the google javascript snippet, and other small fixes.
(setq make-backup-files nil)
(require 'find-lisp)
(mapc (lambda (x)
        (mapc
         (lambda (fPath) (clean-file fPath (concat webroot (substring fPath (length destDir)))))
         (find-lisp-find-files (concat destDir "/" x) "\\.html$"))
        )
      sourceDirsList
)

;; zip the dir
(setq default-directory (concat webroot destDirRelativePath "/"))
(when (equal
       0
       (if use-gzip-p
           (shell-command (concat "tar cfz " zipCoreName ".tar.gz " zipCoreName))
         (shell-command (concat "zip -r " zipCoreName ".zip " zipCoreName))
         ))
  (shell-command (concat "rm -R " destDir))
)

;;----------------------------

; read me text
(setq readMeText "
This is “Xah'S Emacs Tutorial” by Xah Lee.

--------------------------------------------------
The “emacs” dir is emacs and elisp tutorial. The “elisp” dir is elisp manual.

--------------------------------------------------
The tutorial is updated few times a year. The download location is:
http://xahlee.org/diklo/xah_emacs_tutorial.zip

--------------------------------------------------
PERMISSION TO COPY

“Xah'S Emacs Tutorial” is licensed under
“Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.”
available at
http://creativecommons.org/licenses/by-nc-nd/3.0/us/

The elisp manual is licensed under
“GNU Free Documentation License”, available at
http://www.gnu.org/copyleft/fdl.html

")

;; create the read me file.
(find-file (concat destDir "read_me.txt"))
(insert readMeText)
(save-buffer)
(kill-this-buffer)

now on Microsoft Windows, emacs file encoding issues comes up.
Emacs File Encoding FAQ

new version of emacs tutorial out. produced in sparkling PowerShell and golang on Windows! (instead of elisp and python on Mac.) Pick up emacs lisp in 3 hours! Buy it at [ Buy Xah Emacs Tutorial ]

xah-run-current-file now you can customize extensions. Emacs: Run Current File Also in Emacs: Xah Fly Keys

emacs calling windows shell problem

emacs lisp windows cmd powershell 2021-01-20 2mHg4
5 hour spent working on this faak. goal: in emacs lisp, open folder view with the file highlighted. complexities in cmd.exe powershell pwsh 3 levels of string quote escape, and slash backslash faak

Emacs Lisp Toothpick Syndrome

Emacs: Move Image File
more code update. now support ShareX screenshot directory.

Emacs: Open File in External App updated

better many commands that call shell on Microsoft Windows: • xah-open-in-external-appxah-show-in-desktopxah-open-in-terminalxah-open-in-vscodexah-show-in-desktop

Marisa_Kirisame_emacs_magic-s250
霧雨 魔理沙 Marisa Kirisame emacs magic

on its own page. and updated Emacs Fun Index Xah Emacs Fun Index

Emacs: Novel Reading Mode
code update. increased space between lines.

Xah Emacs Packages
updated

Emacs: Move Image File
updated

xah fly keys, setup major mode keys

those asking about how to setup key in magit, here's a good solution. Added to:
Emacs: Xah Fly Keys Customization

Emacs go-mode gofmt diff problem

xah-dired.el

Lots update to emacs lisp commands that call shell. Fixed a few that don't work in Microsoft Windows. If you find a problem, tell me in xah discord.

and many more changes.

these commands are now in a package, see Emacs: xah-dired.el

code update Emacs: Move Image File

Emacs: Open Marked Files in Dired

Emacs: Zip Dir in Dired

Emacs: Xah Fly Keys

changed text-scale-increase to Ctrl+= , was Ctrl++ . modern app use Ctrl+= , instead of the Ctrl+Shift+= (the more logical control with plus, requiring to press shift)

Emacs: HTML Image Path to Img Tag code update

added • xah-html-convert-to-jpgxah-html-resize-img to Emacs: Xah HTML Mode, and major version release. Many key changes.

Emacs in Microsoft Windows FAQ lots update. continue review

Emacs: Move Image File

xah-move-image-file code change. now works better on Microsoft Windows when calling optipng and exiftool

minor updates.

XahTV 2021-01-07 emacs delete html tags, workflow, Kinesis Advantage2 keyboard, gaming machine

Elisp: Bracket CAP WORDS

RSI stories of Ben Wing, The architect of xemacs

peculiar stories of Ben Wing.

Elisp: Abbrev, Template, for Major Mode
updated formatting.

minor updates.

Emacs: Xah HTML Mode added xah-html-delete-tag-pairCtrl+c u

xah talk show 2021-01-03 elisp coding, why golang is easier to learn than python

Emacs: Xah Fly Keys added toggle-truncate-linesSpace n y】 (dvorak notation) qwerty is 【Space l t】. This is a useful command, when you want to see the line structure. I used to just toggle full screen for it. But this is a better solution.

Emacs Key Layout Diagram redo in svg

Ruby Creator Matz: How Emacs Changed My Life
repost

minor update and repost

new version of my emacs tutorial out. Sent to previous buyers. Buy it at Buy Xah Emacs Tutorial

Emacs, Why Not Use Dash
added a video by rms

xah talk show 2020-12-22 live coding emacs lisp, xah fly keys + batman keyboard, math history books

work in progress Emacs Magit Mode Problem

repost Emacs: Problems of the Scratch Buffer

Emacs: Save Split Windows Configuration
minor update.

updated my copy of emacs manual version 25 to 27.

Emacs: Xah Fly Keys update. Now jump-to-register has key 【space n m】. To be used with window-configuration-to-register 【space n ;】 and frameset-to-register 【space n '】. All dvorak notation.

Emacs Should Adopt HTML as Texinfo Replacement

xah talk show 2020-12-18, emacs random talk, org vs html, keyboard layout vs shortcut layout

updated

bunch of todos of the past few months.

look into make abbrev run a function

review

make-empty-file . be careful, if you call it and just hit enter for current dir, it wipes out the current file.

2020-08-28 vc commands. Emacs: Version Control

2020-08-26 emacs has window-toggle-side-windows. it can be used to toggle the side pane of treemacs. Thanks to Rick Naam for this tip. review, read in detail.

fixed xah-css-compact-css-region , added xah-css-compact-css-buffer
Emacs: Xah CSS Mode

Emacs Lisp Function Frequency
updated

Emacs: Open File in External App
xah-open-in-terminal now, on Microsoft Windows, it starts cross-platform PowerShell pwsh. You need to have it installed.

Elisp: Hash Table
minor format change.

Elisp: Batch Find Replace old article. added to the elisp examples panel.

coded in emacs lisp in past 5 hours.

elisp xahlee 2020-12-16 qxM66
elisp xahlee 2020-12-16 qxM66
screenshot 2020-12-16 XZSsD
emacs lisp, replace string= by string-equal

reason: The string-equal name is more consistent with emacs lisp function names, containing just alphanumerics and dash. It is also the original name. The other is a alias. It is more amenable to abbrev, e.g. Makes more sense for se to expand to it then string=

changed files:

Emacs: Move Image File
fixed a bug where removing meta info don't work.

Emacs: Org Mode, Work with Source Code
minor update

Emacs Less-known Tips
minor update

Emacs: Upcase Sentences now works better in html modes.

Emacs: Move Image File updated code. now shell output buffer don't clash.

Elisp: Bracket ALL-CAPS Words

Elisp: Buffer Functions
minor update. reformat.

Elisp: provide, require, features minor update

Emacs: Move Image File
updated code. xah-move-image-file Now call exiftool afterwards to remove metadata, if the command is available.

Emacs: xah-dired.el
updated code xah-image-autocrop. Now auto call optipng if available.

Emacs: Define Key Sequence
minor update. thanks to ctietze

Why Emacs Keys are Painful

Elisp: Doc String Markup
updated.

Emacs: Show Line Numbers updated.

Xah Talk Show 2020-12-02 emacs Sentence Lines, my RSI, Microsoft Sculpt Keyboard, Function Keys

Elisp: Reformat to Sentence Lines

Emacs: Upcase Sentences
Code update. Now in html, if space follows p tag, still works.

updated. Best Keyboards for Emacs

I got a Microsoft Sculpt Ergonomic Keyboard. Because i need a wireless. Not bad. But the key feel is not great for long typing session. I think i gonna need Epomaker Niz Plum . Never try to save on keyboard, you end up spending more.

been typing too much again.

xah rsi 20201117-s250
Xah Lee Emacs Pinky 2020

EmacsConf 2020 morrow

EmacsConf 2020 https://emacsconf.org/2020/ Nov 28, 29 9am-5pm Toronto/EST time; equivalently, 6am-2pm PST, 2pm-10pm UTC, 3pm-11pm Zurich/CET

thanks to sacha https://twitter.com/sachac/status/1332704763742449668

emacs lisp add period to line end

Written on the spot. This is useful because when in online chat, often you don't type the ending period. But when you copy and paste to a blog and reformat it to HTML, you want the ending period.

(defun xah-add-period-to-line-end ()
  "Add a period to each end of line that does not have one.
Work on current paragraph if there is no selection.
Version 2020-11-25"
  (interactive)
  (let ($p1 $p2)
    (if (use-region-p)
        (setq $p1 (region-beginning) $p2 (region-end))
      (progn
        (if (re-search-backward "\n[ \t]*\n+" nil "move")
            (progn (re-search-forward "\n[ \t]*\n+")
                   (setq $p1 (point)))
          (setq $p1 (point)))
        (re-search-forward "\n[ \t]*\n" nil "move")
        (setq $p2 (point))))
    (save-restriction
      (narrow-to-region $p1 $p2)
      (goto-char (point-min))
      (while (search-forward "\n" nil "move" )
        (backward-char )
        (if (eq (char-before ) ?\. )
            nil
          (insert "."))
        (forward-char )))))

Author of Intro to Emacs Lisp Robert J Chassell Died
added a book photo

new version is made. buy it. Buy Xah Emacs Tutorial

minor format updates.

Emacs: Open File in External App
fixed xah-open-in-terminal on macOS now won't close terminal if emacs quit.

Emacs: Open File in External App
fixed xah-show-in-desktop on Mac. So when in dired and cursor is not on a file, still works.

emacs vs vscode memory 2020-11-18
emacs vs vscode memory 2020-11-18

Xah Fly Keys Testimonial
new love

reformated:

Emacs: Repeat Last Command
added a section about repeat command.

These commands are very useful. I use it daily now. repeat-complex-command repeat

See also:

installed emacs 27.1 on Windows 10

emacs 27.1 win10 2020-11-13 5y6tZ
emacs 27.1 win10 2020-11-13

it fixed the problem of emacs being slug slow when you have chinese or unicode math symbols in buffer. Sometimes each cursor movement takes half a second.

this is because emacs 27 uses HarfBuzz text engine.

Download Emacs for Windows, Mac, Linux
updated

Elisp: Chinese Char To Reference Link
updated code.

Emacs: Change Brackets/Quotes
minor code update. better names in prompt.

MacBook broken option key 2020-10-30 dmZdd
MacBook broken option key 2020-10-30 https://twitter.com/davidcapello/status/1083430018171179008

Xah Lee Emacs Pinky 2020

This Emacs Pinky, pained me from 2018 to 2020. but now, it's mostly cured! Once you found the source of RSI, then things are good.

Emacs: Compile TypeScript File
renamed xah-ts-compile-file to xah-typescript-compile-file

Emacs: Run Current File
code update. now JavaScript and TypeScript code runs in deno (instead of node.js). Requires deno.

Emacs: Open File Path Under Cursor
code update. now can open html file with #fractionPart

updated. emacs 27.1 change. focus-out-hook to after-focus-change-function

Emacs: Byte Compile Elisp Files

once in a while, byte compile your init files or elisp code, to discover emacs changes and other warnings.

Fixed yesterday's Chinese font update. Emacs: Font Setup
See also: Chinese Font

Emacs: Xah Emacs Lisp Mode code update. Added after-focus-change-function

minor updates.

am becoming a god at 4chan

4chan xahlee 2020-10-03 vDYsk
4chan xahlee 2020-10-03

Xah Talk Show 2020-10-03 Dumang Dk6 Keyboard, Idiocy of Typography, emacs, python MapThread

new version of my Emacs Tutorial is out. Buy it now! Buy Xah Emacs Tutorial Update sent to previous buyers.

major updates.

Emacs: Xah JavaScript Mode now support TypeScript. Still lots to work on. donate $$$ me.

Xah Talk Show 2020-09-23 Emacs Lisp Format JavaScript, the Idiocy of Formatting Style Guide

receiving bug report response after 12 years. Nice.

gnu emacs bug 1355 email 2020-09-20 q6mTV
gnu emacs bug 1355 email 2020-09-20 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=1355

Not the first time it happened.

By the way, Lars Ingebrigtsen is a nice guy. He wrote gnus and Emacs: Eww Web Browser

See also: Emacs Mode Line Problem

xah fly keys lisp string vs symbol 2020-09-19 rth45
xah fly keys lisp string vs symbol 2020-09-19

Emacs Lisp: Symbol vs String

QWERTY Dvorak Layout Conversion Table

now the key layout diagram supports workman

xah talk show 2020-09-15 emacs lisp live coding + tutorial. insert-br-tag

xah talk show 2020-09-13 emacs lisp xah-remove-console-log, live coding + tutorial

Emacs: Reformat Lines for Source Code
xah-reformat-lines now always make long line first. so, can be used in key macro.

code update

xah-run-current-file now use deno instead node for js. Emacs: Run Current File

Changed (region-active-p) to (use-region-p) for the following commands:

Elisp: xah-fix-datetime
on its own page and code update. Was at Elisp: Parse Date Time

updated

Xah Talk Show 2020-09-07 Emacs Lisp, Insert/Parse Date Time

Testimonial on Xah Emacs Tutorial

Xah Talk Show 2020-09-05, emacs lisp coding, write command to display html hr tag as line

Xah Talk Show 2020-09-04 Emacs Lisp. File Path to Link, Image Link, Get Title, Image Dimension

How to Avoid Emacs Pinky
minor updates.

Use Proportional Font for Code

large proportional font for code 2020-08-31 MxXgx
now experimenting with coding with large proportional font. So far i like it. (The screenshot page is Best Monitor, Xah Pick)

Emacs: Proportional Font

updated

Xah Emacs Blog Archive

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy JavaScript in Depth

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode