Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lawlist
lawlist / isearch-recenter
Created August 8, 2020 02:41
Draft of recentering while running isearch.
(defvar my-isearch-window-start '(nil 0)
"Record the `selected-window' and the Y-axis coordinate of point each time that
`isearch-update' calls `my-isearch-update-recenter' (via an advice). The value
of this variable will be a cons cell with the CAR being the `selected-window' and
the CDR being the Y-axis coordinate of point.")
(defun my-isearch-update-recenter ()
(let* ((win (selected-window))
(pt (point))
(y (cdr (nth 2 (posn-at-point pt win))))
@lawlist
lawlist / gls-example.el
Created May 6, 2020 03:40
Demonstration creating a running process with a let-bound process-environment.
;;; NOTE: The process output from the gls command tends to be truncated when both
;;; (1) _not_ using a process filter and (2) _not_ using a pipe. When _not_ using a
;;; process filter, the workaround is to use a pipe by either setting the variable
;;; `process-connection-type' to `nil`; or, using the `make-process' keyword/argument
;;; pair of :connection-type 'pipe. Said workaround, however, has the disadvantage
;;; of having all the output arriving in one fell swoop and window-start of the
;;; process output buffer is point-max of the output -- meaning that the output is
;;; not visible unless using a command such as recenter on the output window buffer.
(defun gls-example (&optional dir)
"Demonstration creating a running process with a let-bound process-environment."
@lawlist
lawlist / is-it-defined.el
Created December 15, 2019 17:59
Are the symbols in the current buffer defined?
(require 'cl)
;; (global-set-key [f1] 'is-it-defined)
(defun is-it-defined ()
(interactive)
(save-excursion
(goto-char (point-min))
(let ((output-buffer (get-buffer-create "*IS-IT-DEFINED*"))
(cleanup (lambda ()
(recenter 1)
@lawlist
lawlist / example.el
Last active September 4, 2019 20:46
Variation of org-todo with minibuffer prompt of choices.
(defun my-basic-org-todo ()
"Doc-string ...."
(interactive)
(let* ((choice (read-char-exclusive "[t] TODO | [n] NEXT | [w] WAITING"))
(chosen-string (cond
((eq choice ?t)
"TODO")
((eq choice ?n)
"NEXT")
((eq choice ?w)
@lawlist
lawlist / aspell_readme
Created July 17, 2019 06:17
A cheat-sheet to install aspell from source and configure Emacs.
OSX -- ASPELL -- DICTIONARY -- Spanish
* unpack aspell6-es-1.11-2.tar.bz2
* cd over to the root directory of the unpacked source
./configure --vars PATH=$PATH:/Users/HOME/.0.data/.0.emacs/.0.macports/bin
make
@lawlist
lawlist / aspell.conf
Created July 17, 2019 05:59
aspell.conf
# /Users/HOME/.0.data/.0.emacs/.0.macports/bin/aspell --lang=en dump config
# conf (string)
# main configuration file
# default: aspell.conf
# conf-dir (string)
# location of main configuration file
# default: <prefix:etc> = /Users/HOME/.0.data/.0.emacs/.0.macports/etc
@lawlist
lawlist / get-bounds.el
Last active July 17, 2019 05:06
Get the bounds of the selected frame using an applescript.
Feature request 18283 was previously added to Emacs 25 and the master branch in
conjunction with feature request 21415. In a nutshell, it is now possible to act
upon Emacs (to some degree) using an applescript.
CAVEAT: Feature request 18283 was implemented primarily to facilitate debugging,
and not to control Emacs per se using applescripts.
(defun get-bounds ()
"Return the bounds of the selected frame."
(let* ((script (concat "tell front window of application \"Emacs\"\n"
@lawlist
lawlist / 36681_a
Created July 16, 2019 00:31
make -C src emacs
make -C src emacs
make: Entering directory `/c/docume~1/admini~1/desktop/emacs/src'
GEN lisp.mk
make: Leaving directory `/c/docume~1/admini~1/desktop/emacs/src'
make: Entering directory `/c/docume~1/admini~1/desktop/emacs/src'
make -C ../lib/ all
make[1]: Entering directory `/c/docume~1/admini~1/desktop/emacs/lib'
GEN alloca.h
GEN byteswap.h
GEN errno.h
@lawlist
lawlist / redisplay_window
Created July 9, 2019 17:33
Feature request 16475.
/* *************************************************************************** */
/* BEGIN Feature Request # 16475: Automatically add/remove scroll bars. */
finish_scroll_bars:
;
// ptrdiff_t bob_disregard_narrow = BUF_BEG (buffer);
ptrdiff_t eob_disregard_narrow = BUF_Z (buffer);
ptrdiff_t bob_respect_narrow = BUF_BEGV (buffer);
@lawlist
lawlist / example.el
Last active June 29, 2019 19:14
Call qlmanage and return focus to Emacs.
(require 'dired)
(defun qlmanage-return-focus-to-emacs ()
"Doc-string."
(let* ((filename (dired-get-file-for-visit))
(emacs-executable (concat invocation-directory "Emacs"))
(emacs-script (concat "tell application \"" emacs-executable "\" to activate")))
(set-process-sentinel
(start-process "qlmanage" nil "/usr/bin/qlmanage" "-p" filename)
`(lambda (p e) (when (= 0 (process-exit-status p))