Xah Talk Show 2022-01-22 emacs lisp coding narrow-to-region, sort-lines, hilight-unicode, emacs vs xemacs
54:03 emacs vs xemacs, richard stallman, open source schism
write xah-narrow-to-region. if no region, just current text block. put in Xah Fly Keys, give it a key.
write xah-sort-lines, that works on current block if no region. put in Xah Fly Keys, give it a key.
write xah-hilight-unicode
(defun xah-narrow-to-region ()
"Same as `narrow-to-region', but if no selection, narrow to the current block.
Version 2022-01-22"
(interactive)
(if (region-active-p)
(progn
(narrow-to-region (region-beginning) (region-end)))
(progn
(let ($p1$p2)
(save-excursion
(if (re-search-backward"\n[ \t]*\n"nil"move")
(progn (goto-char (match-end 0))
(setq$p1 (point)))
(setq$p1 (point)))
(if (re-search-forward"\n[ \t]*\n"nil"move")
(progn (goto-char (match-beginning 0))
(setq$p2 (point)))
(setq$p2 (point))))
(narrow-to-region$p1$p2)))))
(defun xah-sort-lines ()
"Like `sort-lines' but if no region, do the current block.
Version 2022-01-22"
(interactive)
(let ($p1$p2)
(let (($bds (xah-get-bounds-of-block-or-region))) (setq$p1 (car$bds) $p2 (cdr$bds)))
(sort-linest$p1$p2)))
(defun xah-hilight-unicode ()
"Highlight all unicode chars in current buffer or selection.
Version 2022-01-22 2022-01-24"
(interactive)
(let ($p1$p2)
(if (region-active-p)
(setq$p1 (region-beginning) $p2 (region-end))
(setq$p1 (point-min) $p2 (point-max)))
(save-restriction
(narrow-to-region$p1$p2)
(goto-char (point-min))
(while (re-search-forward"[^[:ascii:]]+"nilt)
(put-text-property (match-beginning 0) (match-end 0) 'font-lock-face '(:background"red"))))))