help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFE: Editing string literals like org-mode?


From: Tim Landscheidt
Subject: Re: RFE: Editing string literals like org-mode?
Date: Sat, 27 Mar 2021 16:32:35 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Jean Louis <bugs@gnu.support> wrote:

>> - 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,

> (insert (prin1-to-string (read-string "String: "))) → "Some \"New\" string"

> Is that?

That is the existing solution for Emacs Lisp.  I'm looking
for a universal one.

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

> Do you mean that it works on quote strings like: "Some \"New\" string"?

For example.

>> - 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).

> I have tried searching in the manual, so can you help me, is it
> in source block? Or in table?

For example in source blocks (#+BEGIN_SRC).

> If I got it right, it would be useful to be able to edit strings
> without observing quotations.

That would be the point; assuming a shell-script-mode buffer
with the text:

| ls 'string"literal""'

or a python-mode buffer with the text:

| print("string\"literal\"\"")

or a sql-mode buffer with the text:

| SELECT 'string"literal""';

or a perl-mode buffer with the text:

| print "string\"literal\"\"";

hitting C-c ' on any of those string literals would open a
new buffer with the text:

| string"literal""

where one could edit that string literal and hit C-c ' again
to replace the string literal in the original buffer.

(There are lots of edge cases where it is harder to DWIM,
but I'm fine with something that approximates the success
rate of Emacs's fontification.)

Tim




reply via email to

[Prev in Thread] Current Thread [Next in Thread]