texmacs-dev
[Top][All Lists]
Advanced

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

[Texmacs-dev] More about Nix' patches


From: Joris van der Hoeven
Subject: [Texmacs-dev] More about Nix' patches
Date: Fri, 18 Apr 2003 17:35:50 +0200 (CEST)

1) The fix for cal*, cal**, bbb*, etc. is not yet perfect.
We really should use the additional packages when
they are really needed. To a lesser extent, this also
holds for some of the other packages by the way.

2) As to bracket-auto-closing mode, I think that
closing brackets should be replaced by new closing
brackets if the cursor is just before it.
In other words, if you type '(a,b]', then you should
successively see the following texts (*=cursor):

        *
        (*)
        (a*)
        (a,*)
        (a,b*)
        (a,b]*

I did not have time to make these two improvements yet;
maybe a nice exercise for a hacker :^)
Here is the new tm-bracket.scm:


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MODULE      : tm-brackets.scm
;; DESCRIPTION : auto-close brackets
;; COPYRIGHT   : (C) 2001  Joris van der Hoeven
;;
;; This software falls under the GNU general public license and comes  WITHOUT
;; ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for  details.
;; If you don't have this file, write to the Free Software Foundation,  Inc.,
;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texmacs-module (texmacs tools tm-bracket)
  (:export
    make-bracket-open make-bracket-close))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; User preferences for bracket behaviour
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define auto-close-brackets? #f)

(define (notify-auto-close-brackets var val)
  (set! auto-close-brackets? (== val "on")))

(define-preferences
  ("auto-close brackets" "off" notify-auto-close-brackets))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Opening brackets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (make-bracket-open l r . opt)
  (let ((large? (== opt '(#t)))
        (sel? (selection-active-normal?)))
    (if auto-close-brackets?
        (begin
          (if sel? (cut "temp"))
          (if large?
              (insert-object-go-to `(concat (left ,l) (right ,r)) '(1 0))
              (insert-object-go-to (string-append l r)
                                   (list (string-length l))))
          (if sel? (paste "temp")))
        (if large?
            (insert-object `(left ,l))
            (insert-object l)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Closing brackets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (make-bracket-close r l . opt)
  (let ((large? (== opt '(#t))))
    (if large?
        (insert-object `(right ,r))
        (insert-object r))))





reply via email to

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