unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Karl Eichwalder <keichwa@gmx.net>
Subject: Re: No line break within [[foo bar]] (wikipedia)
Date: Sun, 20 Apr 2003 06:37:38 +0200	[thread overview]
Message-ID: <shlly5ss19.fsf@tux.gnu.franken.de> (raw)
In-Reply-To: shsmtphir3.fsf@tux.gnu.franken.de

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

  parent reply	other threads:[~2003-04-20  4:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=shlly5ss19.fsf@tux.gnu.franken.de \
    --to=keichwa@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).