Weekly Tips, Tricks, &c. Thread reddit / emacs ---------------------------------------------------------------------- AutoModerator · 2022-12-28 08:15 This is a thread for smaller, miscellaneous items that might not warrant a full post on their own. [See this search for previous "Weekly Tips, Tricks, &c." Threads.](htt ps://www.reddit.com/r/emacs/search?q=Weekly+tips&restrict_sr=on&sort=n ew&t=all) Don't feel constrained in regards to what you post, just keep your post vaguely, generally on the topic of emacs. ---------------------------------------------------------------------- Pay08 · 2022-12-28 12:10 Is there a way to highlight functions and variables in Common Lisp? Lisp-mode only highlights macros. ---------------------------------------------------------------------- phr46 · 2022-12-28 14:05 I've been using Emacs to read manga, and image-next-file and image- previous-file can get a bit slow for large files. I've written these functions based on them, so that after opening one page, they also load the next page in a buffer in the background, so that the next call is just switching to the already loaded buffer: (defun phr-image-next-file (&optional n) (interactive) (unless (derived-mode-p 'image-mode) (error "The buffer is not in Image mode")) (unless buffer-file-name (error "The current image is not associated with a file")) (unless n (setq n 1)) (let ((next (image-mode--next-file buffer-file-name n))) (when (stringp next) (if-let ((buffer (get-file-buffer next))) (switch-to-buffer buffer) (find-file next)) (let ((preload (image-mode--next-file next n))) (when (stringp preload) (make-thread (lambda () (find-file-noselect preload)))))))) (defun phr-image-previous-file (&optional n) (interactive) (phr-image-next-file (if n (- n) -1))) If you keep calling `phr-image-next-file`, then you will always be loading one page ahead. This can get ugly with a lot of buffers open once you finished reading, so I use this to close all the buffers from the same folder: (defun phr-buffers-from-same-folder (x y) (and (buffer-file-name x) (buffer-file-name y) (equal (file-name-directory (buffer-file-name x)) (file-name-directory (buffer-file-name y))))) (defun phr-image-close-folder () (interactive) (unless (derived-mode-p 'image-mode) (error "The buffer is not in Image mode")) (unless buffer-file-name (error "The current image is not associated with a file")) (dolist (buffer (cl-remove-if-not (lambda (b) (phr-buffers-from-same-folder (current-buffer) b)) (buffer-list))) (kill-buffer buffer))) ---------------------------------------------------------------------- MitchellMarquez42 · 2022-12-28 18:12 There's a package called "highlight-defined" that works for elisp, it might work for common lisp too ---------------------------------------------------------------------- 00-11 · 2022-12-28 19:06 See [Highlight Lisp Functions](https://www.emacswiki.org/emacs/HighlightLispFunctions) and [Highlight Elisp Variables](https://www.emacswiki.org/emacs/HighlightElispVariables) -- libraries [`hl- defined.el`](https://www.emacswiki.org/emacs/download/hl-defined.el) and [`hi-var.el`](https://www.emacswiki.org/emacs/download/hi-var.el). * The former lets you highlight symbols that are known to be defined functions and/or variables -- or those that are **not** known to be such. * The latter lets you highlight occurrences of variables: * User options (face `hivar-options`) * Other dynamically scoped variables (face `hivar-dynamic-vars`) * File-local variables (face `hivar-file-local-vars`) * Other buffer-local variables (face `hivar-buffer-local-vars`) ---------------------------------------------------------------------- Pay08 · 2022-12-28 19:13 Don't those two only work with Emacs Lisp? ---------------------------------------------------------------------- 00-11 · 2022-12-28 19:47 Yes, they're designed for Elisp. You can try them with other Lisps, but no guarantees. They use `emacs-lisp-syntax-table` and check the Emacs-Lisp current state using tests such as `fboundp`, `boundp`, and `special-variable-p`, so yeah, they might not get you very far with another Lisp. And certainly other Lisps won't have things like user options and file/buffer-local variables. ---------------------------------------------------------------------- Pay08 · 2022-12-28 22:45 Well, it seems to be working. ---------------------------------------------------------------------- 00-11 · 2022-12-28 22:51 So much the better! And perhaps someone else will have a more helpful suggestion. ---------------------------------------------------------------------- lafrenierejm · 2022-12-31 21:19 When opening a SQLite database file via `find-file`, I'd like to start a new `sql-sqlite` buffer with the selected file as the database. The only approach I can think of so far is to create my own major mode that performs the relevant `sql-sqlite` calls, and then add that major mode to `auto-mode-alist`. Is that a good and reasonable approach, or is there a simpler way to do what I want?