(make-local-variable 'paragraph-ignore-fill-prefix)
(make-local-variable 'adaptive-fill-mode)
(make-local-variable 'adaptive-fill-regexp)
+ (make-local-variable 'fill-paragraph-handle-comment)
;; now set their values
(set (make-local-variable 'parse-sexp-ignore-comments) t)
(set (make-local-variable 'comment-line-break-function)
'c-indent-new-comment-line)
+ ;; For the benefit of adaptive file, which otherwise mis-fills.
+ (setq fill-paragraph-handle-comment nil)
+
;; Install `c-fill-paragraph' on `fill-paragraph-function' so that a
;; direct call to `fill-paragraph' behaves better. This still
;; doesn't work with filladapt but it's better than nothing.
;; inside a string, comment, or macro.
(setq new-bounds (c-extend-font-lock-region-for-macros
c-new-BEG c-new-END old-len))
- (setq c-new-BEG (car new-bounds)
- c-new-END (cdr new-bounds))
+ (setq c-new-BEG (max (car new-bounds) (c-determine-limit 500 begg))
+ c-new-END (min (cdr new-bounds) (c-determine-+ve-limit 500 endd)))
;; Clear all old relevant properties.
(c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
(c-clear-char-property-with-value c-new-BEG c-new-END 'category 'c-cpp-delimiter)
(goto-char (c-point 'bol new-pos))
(when lit-limits ; Comment or string.
(goto-char (car lit-limits)))
- (setq bod-lim (max (- (point) 500) (point-min)))
+ (setq bod-lim (c-determine-limit 500))
(while
;; Go to a less nested declaration each time round this loop.
;; Try and go out a level to search again.
(progn
(c-backward-syntactic-ws bod-lim)
- (or (memq (char-before) '(?\( ?\[))
- (and (eq (char-before) ?\<)
- (eq (c-get-char-property
- (1- (point)) 'syntax-table)
- c-<-as-paren-syntax))))
+ (and (> (point) bod-lim)
+ (or (memq (char-before) '(?\( ?\[))
+ (and (eq (char-before) ?\<)
+ (eq (c-get-char-property
+ (1- (point)) 'syntax-table)
+ c-<-as-paren-syntax)))))
(not (bobp)))
(backward-char))
new-pos)) ; back over (, [, <.
;; Effectively advice around `font-lock-fontify-region' which extends the
;; region (BEG END), for example, to avoid context fontification chopping
;; off the start of the context. Do not do anything if it's already been
- ;; done (i.e. from and after-change fontification. An example (C++) where
+ ;; done (i.e. from an after-change fontification. An example (C++) where
;; this used to happen is this:
;;
;; template <typename T>