unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* No line break within [[foo bar]] (wikipedia)
@ 2003-03-14 19:04 Karl Eichwalder
  2003-03-15  9:45 ` Kai Großjohann
  2003-04-20  4:37 ` Karl Eichwalder
  0 siblings, 2 replies; 10+ messages in thread
From: Karl Eichwalder @ 2003-03-14 19:04 UTC (permalink / raw)


For editint wikipedia articles I sometimes use emacs-wiki.el with some
customizations.  The wikipedia file format allows links with spaces
like [[GNU Project]] -- who can I instruct Emacs to treat all spaces
within "[[...]]" as non-breakable while filling?

-- 
ke@suse.de (work) / keichwa@gmx.net (home):              |
http://www.gnu.franken.de/ke/                            |      ,__o
Free Translation Project:                                |    _-\_<,
http://www.iro.umontreal.ca/contrib/po/HTML/             |   (*)/'(*)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-03-14 19:04 No line break within [[foo bar]] (wikipedia) Karl Eichwalder
@ 2003-03-15  9:45 ` Kai Großjohann
  2003-04-20  4:37 ` Karl Eichwalder
  1 sibling, 0 replies; 10+ messages in thread
From: Kai Großjohann @ 2003-03-15  9:45 UTC (permalink / raw)


Karl Eichwalder <keichwa@gmx.net> writes:

> For editint wikipedia articles I sometimes use emacs-wiki.el with some
> customizations.  The wikipedia file format allows links with spaces
> like [[GNU Project]] -- who can I instruct Emacs to treat all spaces
> within "[[...]]" as non-breakable while filling?

Maybe see fill-nobreak-predicate?
-- 
A preposition is not a good thing to end a sentence with.

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-03-14 19:04 No line break within [[foo bar]] (wikipedia) Karl Eichwalder
  2003-03-15  9:45 ` Kai Großjohann
@ 2003-04-20  4:37 ` Karl Eichwalder
  2003-04-20  8:40   ` Kai Großjohann
  2003-04-20 16:06   ` Stefan Monnier
  1 sibling, 2 replies; 10+ messages in thread
From: Karl Eichwalder @ 2003-04-20  4:37 UTC (permalink / raw)


Karl Eichwalder <keichwa@gmx.net> writes:

> For editint wikipedia articles I sometimes use emacs-wiki.el with some
> customizations.  The wikipedia file format allows links with spaces
> like [[GNU Project]] -- who can I instruct Emacs to treat all spaces
> within "[[...]]" as non-breakable while filling?

Now I have found a way (modelled after `latex-fill-nobreak-predicate' in
tex-mode.el):

(defun fill-open-link-nobreak-p () 
  "Don't break a line after an unclosed \"[[link \"."
  (save-excursion
    (skip-chars-backward " ")
    (let ((opoint (point))
	  spoint inside)
      (save-excursion
	(beginning-of-line)
	(setq spoint (point)))
      (when (re-search-backward "\\[\\[" spoint t)
	;; (message "found") (sit-for 2)
	(unless (re-search-forward "\\]\\]" opoint t)
	  (setq inside t)))
      inside)))

(add-to-list 'fill-nobreak-predicate 'fill-open-link-nobreak-p)

Next open issue: How can I use this mechanism to prevent Emacs from
breaking lines starting with "*" or "#"?

-- 
                                                         |      ,__o
http://www.gnu.franken.de/ke/                            |    _-\_<,
ke@suse.de (work) / keichwa@gmx.net (home)               |   (*)/'(*)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-20  4:37 ` Karl Eichwalder
@ 2003-04-20  8:40   ` Kai Großjohann
  2003-04-20  9:35     ` Karl Eichwalder
  2003-04-20 16:06   ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-04-20  8:40 UTC (permalink / raw)


Karl Eichwalder <keichwa@gmx.net> writes:

> Next open issue: How can I use this mechanism to prevent Emacs from
> breaking lines starting with "*" or "#"?

??

I guess it's obvious how to change the code to look for * or # at
beginning of line.  So I guess you did that, but it didn't work.
What exactly did you try, and what happened when you tried it?

(save-excursion
  (beginning-of-line)
  (member (char-after (point)) '(?\* ?\#)))
...seems to be code that looks whether the line starts with * or #.
-- 
file-error; Data: (Opening input file no such file or directory ~/.signature)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-20  8:40   ` Kai Großjohann
@ 2003-04-20  9:35     ` Karl Eichwalder
  2003-04-20 13:21       ` Kai Großjohann
  0 siblings, 1 reply; 10+ messages in thread
From: Karl Eichwalder @ 2003-04-20  9:35 UTC (permalink / raw)


kai.grossjohann@gmx.net (Kai Großjohann) writes:

Thanks for advise!

> I guess it's obvious how to change the code to look for * or # at
> beginning of line.  So I guess you did that, but it didn't work.
> What exactly did you try, and what happened when you tried it?
>
> (save-excursion
>   (beginning-of-line)
>   (member (char-after (point)) '(?\* ?\#)))
> ...seems to be code that looks whether the line starts with * or #.

I tried serveral way (w/o understanding what I'm actually doing); here
is the last experiment:

(defun fill-list-item-nobreak-p () 
  (save-excursion
    (beginning-of-line)
    (member (char-after (point)) '(?\* ?\#))))

(add-to-list 'fill-nobreak-predicate 'fill-list-item-nobreak-p)

The result is (let's assume the limit is at the word "limit"):

   * this is a very long line, longer than the fill limit

==>

   *
     this is a very long line, longer than the fill
     limit

Thus Emacs will break the line after "* " and that's not what I want.

-- 
                                                         |      ,__o
http://www.gnu.franken.de/ke/                            |    _-\_<,
ke@suse.de (work) / keichwa@gmx.net (home)               |   (*)/'(*)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-20  9:35     ` Karl Eichwalder
@ 2003-04-20 13:21       ` Kai Großjohann
  2003-04-20 17:15         ` Karl Eichwalder
  0 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-04-20 13:21 UTC (permalink / raw)


Karl Eichwalder <keichwa@gmx.net> writes:

> I tried serveral way (w/o understanding what I'm actually doing); here
> is the last experiment:
>
> (defun fill-list-item-nobreak-p () 
>   (save-excursion
>     (beginning-of-line)
>     (member (char-after (point)) '(?\* ?\#))))
>
> (add-to-list 'fill-nobreak-predicate 'fill-list-item-nobreak-p)

After some thinking, it occurs to me that it prevents breaking the
line *anywhere* in the `*' line.  But maybe you only want to prevent
breaking at the `*' character?

-- 
file-error; Data: (Opening input file no such file or directory ~/.signature)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-20  4:37 ` Karl Eichwalder
  2003-04-20  8:40   ` Kai Großjohann
@ 2003-04-20 16:06   ` Stefan Monnier
  2003-04-21  6:49     ` Karl Eichwalder
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2003-04-20 16:06 UTC (permalink / raw)


> (defun fill-open-link-nobreak-p () 
>   "Don't break a line after an unclosed \"[[link \"."
>   (save-excursion
>     (skip-chars-backward " ")
>     (let ((opoint (point))
> 	  spoint inside)
>       (save-excursion
> 	(beginning-of-line)
> 	(setq spoint (point)))
>       (when (re-search-backward "\\[\\[" spoint t)
> 	;; (message "found") (sit-for 2)
> 	(unless (re-search-forward "\\]\\]" opoint t)
> 	  (setq inside t)))
>       inside)))

(defun fill-open-link-nobreak-p ()
  (save-excursion
    (and (re-search-backward "\\(\\[\\[\\)\\|\\]\\]"
                             (line-beginning-position)
                             t)
         (match-end 1))))

> Next open issue: How can I use this mechanism to prevent Emacs from
> breaking lines starting with "*" or "#"?

You can't.  It is meant to pinpoint places where breaking is a bad idea,
but if there's no good place to break the line, the line will be broken
at a bad point.

Try to use auto-fill-inhibit-regexp instead (although I don't think
it's obeyed by M-q).


        Stefan

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-20 13:21       ` Kai Großjohann
@ 2003-04-20 17:15         ` Karl Eichwalder
  0 siblings, 0 replies; 10+ messages in thread
From: Karl Eichwalder @ 2003-04-20 17:15 UTC (permalink / raw)


kai.grossjohann@gmx.net (Kai Großjohann) writes:

>> (defun fill-list-item-nobreak-p () 
>>   (save-excursion
>>     (beginning-of-line)
>>     (member (char-after (point)) '(?\* ?\#))))
>>
>> (add-to-list 'fill-nobreak-predicate 'fill-list-item-nobreak-p)
>
> After some thinking, it occurs to me that it prevents breaking the
> line *anywhere* in the `*' line.

No, that's exactly what I want; but this does not work ;-(

> But maybe you only want to prevent breaking at the `*' character?

No, no.  This stupid wiki resp. wikipedia file format is fond of long
lines; to build lists with list items you must not wrap ("fill") those
lines; cf. the German description:

    http://de.wikipedia.org/wiki/Wikipedia:Textgestaltung

-- 
                                                         |      ,__o
http://www.gnu.franken.de/ke/                            |    _-\_<,
ke@suse.de (work) / keichwa@gmx.net (home)               |   (*)/'(*)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-20 16:06   ` Stefan Monnier
@ 2003-04-21  6:49     ` Karl Eichwalder
  2003-04-21 13:52       ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Karl Eichwalder @ 2003-04-21  6:49 UTC (permalink / raw)


"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:

> (defun fill-open-link-nobreak-p ()
>   (save-excursion
>     (and (re-search-backward "\\(\\[\\[\\)\\|\\]\\]"
>                              (line-beginning-position)
>                              t)
>          (match-end 1))))

Thanks!

> You can't.  It is meant to pinpoint places where breaking is a bad idea,
> but if there's no good place to break the line, the line will be broken
> at a bad point.

Okay, I see.

> Try to use auto-fill-inhibit-regexp instead (although I don't think
> it's obeyed by M-q).

This somehow works, at least for "^\\*"; it does not work for ":" or
"#" -- these signs seem to interfere with other line breaking rules.

I guess I'll have to disable filling for wikipedia text files all
together and to go for a longlines or flowed mode.

-- 
                                                         |      ,__o
http://www.gnu.franken.de/ke/                            |    _-\_<,
ke@suse.de (work) / keichwa@gmx.net (home)               |   (*)/'(*)

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

* Re: No line break within [[foo bar]] (wikipedia)
  2003-04-21  6:49     ` Karl Eichwalder
@ 2003-04-21 13:52       ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2003-04-21 13:52 UTC (permalink / raw)


>> Try to use auto-fill-inhibit-regexp instead (although I don't think
>> it's obeyed by M-q).
> This somehow works, at least for "^\\*"; it does not work for ":" or
> "#" -- these signs seem to interfere with other line breaking rules.

I'm not sure what you mean by "somehow work", so I can't be sure about
what you mean by "does not work" either, but it sounds like there's
a bug.  Please report it.


        Stefan

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

end of thread, other threads:[~2003-04-21 13:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-14 19:04 No line break within [[foo bar]] (wikipedia) Karl Eichwalder
2003-03-15  9:45 ` Kai Großjohann
2003-04-20  4:37 ` Karl Eichwalder
2003-04-20  8:40   ` Kai Großjohann
2003-04-20  9:35     ` Karl Eichwalder
2003-04-20 13:21       ` Kai Großjohann
2003-04-20 17:15         ` Karl Eichwalder
2003-04-20 16:06   ` Stefan Monnier
2003-04-21  6:49     ` Karl Eichwalder
2003-04-21 13:52       ` Stefan Monnier

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