Useful for editing e.g. SQLite (with -*- mode: sql -*-
) embedded in Lisp 26.
(defun my-edit-string-at-point () "Edit string at point in an indirect buffer." (interactive) (let* ((point (point)) (outer-bounds (save-excursion (unless (looking-at "\"") (search-backward-regexp "\"")) (bounds-of-thing-at-point 'sexp))) (inner-bounds (cons (1+ (car outer-bounds)) (1- (cdr outer-bounds))))) (with-current-buffer (edit-indirect-region (car inner-bounds) (cdr inner-bounds) 'display-buffer) (goto-char (- point (car outer-bounds))))))
(keymap-set prog-mode-map "C-c '" #'my-edit-string-at-point)
Before, I tried and failed with