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: Stefan Monnier
Subject: Re: No line break within [[foo bar]] (wikipedia)
Date: 20 Apr 2003 12:06:31 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

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


reply via email to

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