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

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

Re: Newline-phobic text help.


From: John Mastro
Subject: Re: Newline-phobic text help.
Date: Thu, 14 Jul 2016 18:43:41 -0700

R. Clayton <address@hidden> wrote:
> I use emacs and firefox's it's all text add-on to fill in web text-entry 
> forms.
> Because those forms break text to the line width, I use the enriched-text 
> minor
> mode under the assumption that soft newlines don't show up in the resulting
> text.  That assumption seems to be incomplete: the soft newlines are gone, but
> the text in the form has (hard) newlines at the places the text in the buffer
> had soft newlines (resizing the form verifies this claim).
>
> Enriched text saved to a local disk file has the same property -
> intra-paragraph soft newlines are replaced by hard newlines - which leads me 
> to
> believe I don't understand enriched text.  What are the emacs incantations 
> that
> keep hard newlines out of paragraphs when the buffer's written to wherever?

[ I think your scenario boils down to the fact that you don't want the
  intra-paragraph newlines in your buffer to end up in your web form; if
  I got that wrong, you can ignore what I wrote below. ]

I don't know the answer to your question about controlling how newlines
are written, but perhaps another approach would be to:

(auto-fill-mode -1)
(visual-line-mode)

In the relevant buffers, so the unwanted newlines are never inserted at
all. The only trick would be identifying when you've got an "It's All
Text!" buffer so you can evaluate that code. If the buffers are
text-mode buffers with somewhat predictable names as suggested here[1],
it might work to do something like:

(defun my-its-all-text-settings ()
  (let ((file (buffer-file-name)))
    (when (and file
               (file-in-directory-p file "/tmp/")
               (string-match-p "\\.[A-Za-z0-9]\\{10\\}\\.txt\\'" file))
      (auto-fill-mode -1)
      (visual-line-mode))))

(with-eval-after-load 'text-mode
  (add-hook 'text-mode-hook #'my-its-all-text-settings))

Of course, that regexp could easily match files other than those created
by It's All Text!. But we're not doing anything dangerous, so unless you
often edit text files in /tmp it's probably okay.

Actually, I'm not sure that It's All Text! puts its temporary files in
/tmp, so you should confirm that (and adjust the file-in-directory-p
call if not).

        John

[1] 
https://psung.blogspot.com/2009/05/using-itsalltext-with-emacsemacsclient.html



reply via email to

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