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: Jean Louis
Subject: Re: RFE: Editing string literals like org-mode?
Date: Sat, 27 Mar 2021 21:08:55 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Tim Landscheidt <tim@tim-landscheidt.de> [2021-03-27 19:33]:
> 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.

Do you mean like a function maybe, that works everywhere?

(defun my-insert-string-literal (&optional string)
  "Asks for STRING if not supplied and inserts it as literal
  string with quotes."
  (interactive)
  (let ((string (or string (read-string "String: "))))
    (insert (prin1-to-string string))))

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

thing-at-point would need to be defined, I would not know now how
to define it universally to find out string with quote on both
sides and that it works over new lines.

"Some string✗ here \"Mo✗re\" and more."
"Then again✗ maybe \"one\" here".

What would be then string with quotes if cursor is at second ✗ on
first line or first, or in the second line?

Should program count all quotes, and what about others? It is
hard to find general boundaries.

It would be easier to find boundaries in a sexp like
'(Something "String \"more\" here"). 

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

For that I have tried with:

#+BEGIN_SRC shell-script
  Something
#+END_SRC

And I do not see how it helps with quoting, maybe I
misunderstood. What I could see is that it is making new buffer
and edits it maybe with a different mode.

Do you mean to temporarily, during editing, change the mode and
then come back to original mode?




reply via email to

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