From: martin rudalics <rudalics@gmx.at>
Subject: adaptive-fill-mode and auto-fill-mode
Date: Sat, 07 Oct 2006 12:00:18 +0200 [thread overview]
Message-ID: <wkzmc8xx71.fsf@gmx.at> (raw)
To reproduce with Emacs -Q insert the following text ...
(auto-fill-mode 1)
(setq fill-column 60)
;; x
;; x
(defun foo (from to)
(yes-or-no-p (format "..... should we foo from %s to %s?" from to
;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yy
;;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zz
)))
... in *scratch* and evaluate *scratch*.
(1) Typing SPC at the end of the `yes-or-no-p' line gets me
(defun foo (from to)
(yes-or-no-p (format "..... should we foo from %s to %s?"
;; from to
;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yy
;;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zz
)))
(2) Typing SPC after yy breaks the comment as
(defun foo (from to)
(yes-or-no-p (format "..... should we foo from %s to %s?" from to
;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;; yy
;;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zz
)))
(3) Typing SPC after zz breaks the comment as
(defun foo (from to)
(yes-or-no-p (format "..... should we foo from %s to %s?" from to
;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yy
;;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;; zz
)))
(4) Changing the definition of foo to
(defun foo (from to)
(yes-or-no-p (format "....... should we foo from %s to %s?" from to
;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yy
;;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zz
)))
and typing SPC at the end of the `yes-or-no-p' line gets me
(defun foo (from to)
(yes-or-no-p (format "....... should we foo from %s to
;; %s?" from to
;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yy
;;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx zz
)))
The patch below is an attempt to resolve these problems with minimal
invasiveness (but for the removal of the `fill-nobreak-predicate' let
binding in `fill-move-to-break-point' which, IMHO, breaks the purpose of
`fill-nobreak-predicate' anyway).
*** textmodes/fill.el.~1.191.~ Fri Sep 8 18:07:28 2006
--- textmodes/fill.el Fri Oct 6 19:42:22 2006
***************
*** 520,526 ****
;; Ok, skip at least one word or one \c| character.
;; Meanwhile, don't stop at a period followed by one space.
(let ((to (line-end-position))
- (fill-nobreak-predicate nil) ;to break sooner.
(first t))
(goto-char linebeg)
(while (and (< (point) to) (or first (fill-nobreak-p)))
--- 520,525 ----
*** newcomment.el.~1.96.~ Mon Aug 21 14:35:24 2006
--- newcomment.el Fri Oct 6 19:49:14 2006
***************
*** 1182,1187 ****
--- 1182,1202 ----
;; If there's an adaptive prefix, use it unless we're inside
;; a comment and the prefix is not a comment starter.
((and fill-prefix
+ ;; Don't use the adaptive prefix if we are not in a comment and
+ ;; the adaptive prefix matches `comment-start'.
+ (or compos (null comment-start)
+ (not (string-match
+ (regexp-quote comment-start) fill-prefix)))
+ ;; Don't use the adaptive prefix if we are in an end-of-line
+ ;; comment that doesn't start at the left margin or whose start
+ ;; sequence doesn't match the prefix.
+ (or (not compos) (not (string-equal comment-end ""))
+ (and (<= compos
+ (+ (line-beginning-position 0)
+ (if (numberp left-margin) left-margin 0)))
+ (save-excursion
+ (goto-char compos)
+ (looking-at (regexp-quote fill-prefix)))))
(or (not compos)
(comment-valid-prefix-p fill-prefix compos)))
(indent-to-left-margin)
*** emacs-lisp/lisp-mode.el.~1.194.~ Tue Aug 15 10:00:52 2006
--- emacs-lisp/lisp-mode.el Fri Oct 6 12:21:32 2006
***************
*** 210,215 ****
--- 210,222 ----
;; because lisp-fill-paragraph should do the job.
;; I believe that newcomment's auto-fill code properly deals with it -stef
;;(set (make-local-variable 'adaptive-fill-mode) nil)
+ (set (make-local-variable 'fill-nobreak-predicate)
+ (lambda ()
+ (and (eq (get-text-property (point) 'face)
+ 'font-lock-string-face)
+ (or (= (point) (point-min))
+ (eq (get-text-property (1- (point)) 'face)
+ 'font-lock-string-face)))))
(make-local-variable 'indent-line-function)
(setq indent-line-function 'lisp-indent-line)
(make-local-variable 'indent-region-function)
next reply other threads:[~2006-10-07 10:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-07 10:00 martin rudalics [this message]
2006-10-07 16:22 ` adaptive-fill-mode and auto-fill-mode Stefan Monnier
2006-10-07 18:43 ` martin rudalics
2006-10-08 4:29 ` Stefan Monnier
2006-10-08 10:29 ` martin rudalics
2006-10-08 16:21 ` Stefan Monnier
2006-10-08 19:03 ` martin rudalics
2006-10-09 1:37 ` Stefan Monnier
2006-10-09 12:35 ` martin rudalics
2006-10-09 16:45 ` Stefan Monnier
2006-10-09 21:04 ` martin rudalics
2006-10-10 0:32 ` Stefan Monnier
2006-10-08 4:30 ` 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=wkzmc8xx71.fsf@gmx.at \
--to=rudalics@gmx.at \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).