From: Tim Landscheidt <tim@tim-landscheidt.de>
To: help-gnu-emacs@gnu.org
Subject: RFE: Editing string literals like org-mode?
Date: Sat, 27 Mar 2021 14:05:12 +0000 [thread overview]
Message-ID: <87ft0gofon.fsf@passepartout.tim-landscheidt.de> (raw)
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
next reply other threads:[~2021-03-27 14:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-27 14:05 Tim Landscheidt [this message]
2021-03-27 14:25 ` RFE: Editing string literals like org-mode? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ft0gofon.fsf@passepartout.tim-landscheidt.de \
--to=tim@tim-landscheidt.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).