all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RFE: Editing string literals like org-mode?
@ 2021-03-27 14:05 Tim Landscheidt
  2021-03-27 14:25 ` Jean Louis
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Landscheidt @ 2021-03-27 14:05 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

motivation: I was editing some Ansible files that are in
YAML syntax with yaml-mode
(https://github.com/yoshiki/yaml-mode).  I found the YAML
type of quoting rather confusing so I mused that there
should be a yaml-yank-quoted function that, with no prefix
argument, inserts the last kill in double quotes, with a
prefix argument, inserts the last kill as a multiline block,
etc. so that I could edit the "value" in another buffer,
kill it there and yank it properly quoted in my YAML buffer.

Ideally, there would be a corresponding
kill-yaml-value-at-point function (or an extension to
thing-at-point) so that I could copy the "value" dequoted to
that other buffer.  And org-mode has that nice feature
org-edit-special (C-c ') for inter alia #+BEGIN_SRC blocks
where you can edit the block's contents in another buff-
er--so why couldn't there be an equivalent for yaml-mode?

Thinking of other modes, I recalled that I have often yearn-
ed for a way to insert/edit a properly quoted string liter-
al, whether in SQL or shell scripts that call sed or perl,
just like I can in emacs-lisp-mode with prin1 et al.  And
Emacs has already a notion for what a string literal looks
like in different modes by marking them up with
font-lock-string-face.

And, to complete the circle, #+BEGIN_SRC blocks in org-mode
could be interpreted as just another form of string literal.

So Emacs seems to be missing (to be bikeshedded):

- an (optional) function foo-quote for each major mode so
  that (insert (foo-quote (read-string "String: ")))
  inserts the input properly quoted in the current buffer,

- an (optional) function foo-read-string-literal-at-point
  that returns the dequoted string literal at point, and

- a function bound to C-c ' that edits the string literal at
  point just like org-mode does (if the major mode provides
  the necessary foo-quote and
  foo-read-string-literal-at-point functions).

Now this suggestion appears to be so obvious that it is
either already implemented or could not work :-).  Comments?

Tim




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-28 12:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-27 14:05 RFE: Editing string literals like org-mode? Tim Landscheidt
2021-03-27 14:25 ` Jean Louis
2021-03-27 16:32   ` Tim Landscheidt
2021-03-27 17:09     ` Stefan Monnier
2021-03-28 11:42       ` Tim Landscheidt
2021-03-27 18:08     ` Jean Louis
2021-03-28 12:31       ` Tim Landscheidt

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.