emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch: Syntax and Hard Newlines


From: Herbert Euler
Subject: Re: Patch: Syntax and Hard Newlines
Date: Thu, 16 Nov 2006 23:12:03 +0800

The major modes I've been talking about (including ada, cperl, python)
use `make-local-variable' to make `parse-sexp-lookup-properties' local
to the buffer they're operating on.  When you do `kill-local-variable'
you kill their local binding too and they will see the global binding
which is usually not what they want.

What about this?

       * longlines.el (longlines-mode): Set
       `parse-sexp-lookup-properties' so that syntax parsing uses text
       properties.
       (longlines-parse-sexp-lookup-properties)
       (longlines-pslp-was-local): New variables.
       (longlines-soft-newline): New constant.
       (longlines-wrap-line): Use `longlines-soft-newline' to make syntax
       parsing regard soft newlines the same as spaces.

*** longlines.el.orignal        2006-11-16 23:00:49.000000000 +0000
--- longlines.el        2006-11-16 23:00:55.000000000 +0000
***************
*** 79,89 ****
--- 79,100 ----
 (defvar longlines-wrap-end nil)
 (defvar longlines-wrap-point nil)
 (defvar longlines-showing nil)
+ (defvar longlines-parse-sexp-lookup-properties nil)
+ ;; PSLP: Parse-Sexp-Lookup-Properties.
+ (defvar longlines-pslp-was-local nil)

 (make-variable-buffer-local 'longlines-wrap-beg)
 (make-variable-buffer-local 'longlines-wrap-end)
 (make-variable-buffer-local 'longlines-wrap-point)
 (make-variable-buffer-local 'longlines-showing)
+ (make-variable-buffer-local 'longlines-parse-sexp-lookup-properties)
+ (make-variable-buffer-local 'longlines-pslp-was-local)
+
+ (defconst longlines-soft-newline
+   (propertize "\n"
+             'syntax-table
+             '(0))
+   "The soft newline character for wrapping long lines.")

 ;; Mode

***************
*** 112,117 ****
--- 123,137 ----
         (make-local-variable 'buffer-substring-filters)
       (set (make-local-variable 'isearch-search-fun-function)
            'longlines-search-function)
+       (if (local-variable-p 'parse-sexp-lookup-properties)
+           (setq longlines-parse-sexp-lookup-properties
+                 parse-sexp-lookup-properties
+                 longlines-pslp-was-local
+                 t
+                 parse-sexp-lookup-properties
+                 t)
+         (setq longlines-pslp-was-local nil)
+         (set (make-local-variable 'parse-sexp-lookup-properties) t))
         (add-to-list 'buffer-substring-filters 'longlines-encode-string)
         (when longlines-wrap-follows-window-size
           (set (make-local-variable 'fill-column)
***************
*** 156,161 ****
--- 176,185 ----
           (add-hook 'post-command-hook
                     'longlines-post-command-function nil t)))
     ;; Turn off longlines mode
+     (if longlines-pslp-was-local
+       (setq parse-sexp-lookup-properties
+             longlines-parse-sexp-lookup-properties)
+       (kill-local-variable 'parse-sexp-lookup-properties))
     (setq buffer-file-format (delete 'longlines buffer-file-format))
     (if longlines-showing
         (longlines-unshow-hard-newlines))
***************
*** 240,246 ****
 If wrapping is performed, point remains on the line.  If the line does
 not need to be wrapped, move point to the next line and return t."
   (if (longlines-set-breakpoint)
!       (progn (insert-before-markers ?\n)
            (backward-char 1)
              (delete-char -1)
            (forward-char 1)
--- 264,270 ----
 If wrapping is performed, point remains on the line.  If the line does
 not need to be wrapped, move point to the next line and return t."
   (if (longlines-set-breakpoint)
!       (progn (insert-before-markers longlines-soft-newline)
            (backward-char 1)
              (delete-char -1)
            (forward-char 1)

Regards,
Guanpeng Xu

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/





reply via email to

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