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

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

Re: No line break within [[foo bar]] (wikipedia)


From: Karl Eichwalder
Subject: Re: No line break within [[foo bar]] (wikipedia)
Date: Sun, 20 Apr 2003 06:37:38 +0200
User-agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.3.50 (gnu/linux)

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)               |   (*)/'(*)


reply via email to

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