Combining string-edit
with a bit of custom elisp can provide the feature you
want. For example, the function below will enable you to edit the value of a
variable in string-edit-mode
, provided that this variable is string-valued.
(defun my/edit-string-variable-at-point ()
"If the symbol at point is a string-valued variable, update it
using `string-edit' to provide the new value."
(interactive)
(let ((variable (intern (thing-at-point 'symbol t))))
(with-current-buffer (get-buffer-create "*edit-variable*")
(erase-buffer)
(print `(setq ,variable ,(symbol-value variable))
(current-buffer))
(goto-char (- (point-max) 3))
(if (string-edit-at-point)
;; Variable value is a string
;; Overrides C-c C-c so that the new value is evaluated after `string-edit-conclude'
(let ((oldmap (cdr (assoc 'string-edit-mode minor-mode-map-alist)))
(newmap (make-sparse-keymap)))
(set-keymap-parent newmap oldmap)
(define-key newmap (kbd "C-c C-c")
#'(lambda ()
(interactive)
(string-edit-conclude)
(eval-buffer)
(kill-buffer)))
(make-local-variable 'minor-mode-overriding-map-alist)
(push `(string-edit-mode . ,newmap) minor-mode-overriding-map-alist))
;; Variable value was not a string
(message "`%s' is not a string!" variable)
(kill-buffer)))))