/[emacs]/emacs/lisp/progmodes/tcl.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/tcl.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.69 by monnier, Mon Apr 1 21:01:04 2002 UTC revision 1.69.2.1 by miles, Fri Apr 4 06:20:36 2003 UTC
# Line 318  have three inferior Lisps running: Line 318  have three inferior Lisps running:
318  If you do a \\[tcl-eval-defun] command on some Lisp source code, what  If you do a \\[tcl-eval-defun] command on some Lisp source code, what
319  process do you send it to?  process do you send it to?
320    
321  - If you're in a process buffer (foo, bar, or *inferior-tcl*),  - If you're in a process buffer (foo, bar, or *inferior-tcl*),
322    you send it to that process.    you send it to that process.
323  - If you're in some other buffer (e.g., a source file), you  - If you're in some other buffer (e.g., a source file), you
324    send it to the process attached to buffer `inferior-tcl-buffer'.    send it to the process attached to buffer `inferior-tcl-buffer'.
# Line 441  is a Tcl expression, and the last argume Line 441  is a Tcl expression, and the last argume
441    
442    
443    
444  ;; Its pretty bogus to have to do this, but there is no easier way to  ;; Here's another stab.  I think this one actually works.
445  ;; say "match not syntax-1 and not syntax-2".  Too bad you can't put  ;; We have to be careful that the open-brace following this regexp
446  ;; \s in [...].  This sickness is used in Emacs 19 to match a defun  ;; is indeed the one corresponding to the function's body so
447  ;; starter.  (It is used for this in v18 as well).  ;; that end-of-defun works correctly.  Tricky cases are:
448  ;;(defconst tcl-omit-ws-regexp  ;;    proc foo { {arg1 def} arg2 } {
449  ;;  (concat "^\\(\\s"  ;; as well as
450  ;;        (mapconcat 'char-to-string "w_.()\"\\$'/" "\\|\\s")  ;;    proc foo { \n {arg1 def} \n arg2 } {
451  ;;        "\\)\\S(*")  ;; The current setting handles the first case properly but not the second.
452  ;;  "Regular expression that matches everything except space, comment  ;; It also fails if `proc' is not in column-0 (e.g. it's in a namespace).
453  ;;starter, and comment ender syntax codes.")  (defconst tcl-omit-ws-regexp "^[^] \t\n#}].+[ \t]+")
   
 ;; FIXME?  Instead of using the hairy regexp above, we just use a  
 ;; simple one.  
 ;;(defconst tcl-omit-ws-regexp "^[^] \t\n#}]\\S(*"  
 ;;  "Regular expression used in locating function definitions.")  
   
 ;; Here's another stab.  I think this one actually works.  Now the  
 ;; problem seems to be that there is a bug in Emacs 19.22 where  
 ;; end-of-defun doesn't really use the brace matching the one that  
 ;; trails defun-prompt-regexp.  
 ;; ?? Is there a bug now ??  
 (defconst tcl-omit-ws-regexp "^[^ \t\n#}][^\n}]+}*[ \t]+")  
454    
455    
456    
# Line 494  Uses variables `tcl-proc-regexp' and `tc Line 482  Uses variables `tcl-proc-regexp' and `tc
482           ;; FIXME consider using "not word or symbol", not           ;; FIXME consider using "not word or symbol", not
483           ;; "whitespace".           ;; "whitespace".
484           (cons (concat "\\(\\s-\\|^\\)"           (cons (concat "\\(\\s-\\|^\\)"
485                         ;; FIXME Use regexp-quote?                         ;; FIXME Use regexp-quote?
486                         (regexp-opt tcl-keyword-list t)                         (regexp-opt tcl-keyword-list t)
487                         "\\(\\s-\\|$\\)")                         "\\(\\s-\\|$\\)")
488                 2))))                 2))))
# Line 543  documentation for details): Line 531  documentation for details):
531      If not nil, use a smarter, Tcl-specific way to find the current      If not nil, use a smarter, Tcl-specific way to find the current
532      word when looking up help on a Tcl command.      word when looking up help on a Tcl command.
533    
534  Turning on Tcl mode calls the value of the variable `tcl-mode-hook'  Turning on Tcl mode runs `tcl-mode-hook'.  Read the documentation for
 with no args, if that value is non-nil.  Read the documentation for  
535  `tcl-mode-hook' to see what kinds of interesting hook functions  `tcl-mode-hook' to see what kinds of interesting hook functions
536  already exist.  already exist.
537    
538  Commands:  Commands:
539  \\{tcl-mode-map}"  \\{tcl-mode-map}"
   (set (make-local-variable 'paragraph-start) "$\\| ")  
   (set (make-local-variable 'paragraph-separate) paragraph-start)  
   
540    (unless (and (boundp 'filladapt-mode) filladapt-mode)    (unless (and (boundp 'filladapt-mode) filladapt-mode)
541      (set (make-local-variable 'paragraph-ignore-fill-prefix) t)      (set (make-local-variable 'paragraph-ignore-fill-prefix) t))
     (set (make-local-variable 'fill-paragraph-function)  
          'tcl-do-fill-paragraph))  
542    
543    (set (make-local-variable 'indent-line-function) 'tcl-indent-line)    (set (make-local-variable 'indent-line-function) 'tcl-indent-line)
544    (set (make-local-variable 'comment-indent-function) 'tcl-comment-indent)    (set (make-local-variable 'comment-indent-function) 'tcl-comment-indent)
# Line 565  Commands: Line 547  Commands:
547    ;; (setq require-final-newline t)    ;; (setq require-final-newline t)
548    
549    (set (make-local-variable 'comment-start) "# ")    (set (make-local-variable 'comment-start) "# ")
550    (set (make-local-variable 'comment-start-skip) "#+ *")    (set (make-local-variable 'comment-start-skip)
551    (set (make-local-variable 'comment-column) 40) ;why?  -stef         "\\(\\(^\\|[;{[]\\)\\s-*\\)#+ *")
552    (set (make-local-variable 'comment-end) "")    (set (make-local-variable 'comment-end) "")
553    
554    (set (make-local-variable 'outline-regexp) "[^\n\^M]")    (set (make-local-variable 'outline-regexp) ".")
555    (set (make-local-variable 'outline-level) 'tcl-outline-level)    (set (make-local-variable 'outline-level) 'tcl-outline-level)
556    
557    (set (make-local-variable 'font-lock-defaults)    (set (make-local-variable 'font-lock-defaults)
# Line 579  Commands: Line 561  Commands:
561    
562    (set (make-local-variable 'imenu-generic-expression)    (set (make-local-variable 'imenu-generic-expression)
563         'tcl-imenu-generic-expression)         'tcl-imenu-generic-expression)
564      
565    ;; Settings for new dabbrev code.    ;; Settings for new dabbrev code.
566    (set (make-local-variable 'dabbrev-case-fold-search) nil)    (set (make-local-variable 'dabbrev-case-fold-search) nil)
567    (set (make-local-variable 'dabbrev-case-replace) nil)    (set (make-local-variable 'dabbrev-case-replace) nil)
# Line 795  Returns nil if line starts inside a stri Line 777  Returns nil if line starts inside a stri
777      (beginning-of-line)      (beginning-of-line)
778      (let* ((indent-point (point))      (let* ((indent-point (point))
779             (case-fold-search nil)             (case-fold-search nil)
780             (continued-line             (continued-line
781              (save-excursion              (save-excursion
782                (if (bobp)                (if (bobp)
783                    nil                    nil
# Line 943  Returns nil if line starts inside a stri Line 925  Returns nil if line starts inside a stri
925                    contain-stack (cons nil contain-stack)                    contain-stack (cons nil contain-stack)
926                    last-depth (1+ last-depth)))                    last-depth (1+ last-depth)))
927            (if (null (car contain-stack))            (if (null (car contain-stack))
928                (setcar contain-stack                (setcar contain-stack
929                        (or (car (cdr state))                        (or (car (cdr state))
930                            (save-excursion                            (save-excursion
931                              (forward-sexp -1)                              (forward-sexp -1)
932                              (point)))))                              (point)))))
933            (forward-line 1)            (forward-line 1)
934            (setq continued-line            (setq continued-line
935                  (save-excursion                  (save-excursion
936                    (backward-char)                    (backward-char)
937                    (= (preceding-char) ?\\)))                    (= (preceding-char) ?\\)))
# Line 975  Returns nil if line starts inside a stri Line 957  Returns nil if line starts inside a stri
957                     (setq this-indent (- this-indent 1))))                     (setq this-indent (- this-indent 1))))
958              ;; Put chosen indentation into effect.              ;; Put chosen indentation into effect.
959              (or (null this-indent)              (or (null this-indent)
960                  (= (current-column)                  (= (current-column)
961                     (if continued-line                     (if continued-line
962                         (+ this-indent tcl-indent-level)                         (+ this-indent tcl-indent-level)
963                       this-indent))                       this-indent))
964                  (progn                  (progn
965                    (delete-region (point) (progn (beginning-of-line) (point)))                    (delete-region (point) (progn (beginning-of-line) (point)))
966                    (indent-to                    (indent-to
967                     (if continued-line                     (if continued-line
968                         (+ this-indent tcl-indent-level)                         (+ this-indent tcl-indent-level)
969                       this-indent)))))))))                       this-indent)))))))))
970    )    )
# Line 1234  simpler version that is often right, and Line 1216  simpler version that is often right, and
1216      (beginning-of-defun)      (beginning-of-defun)
1217      (car (tcl-hairy-scan-for-comment nil save nil))))      (car (tcl-hairy-scan-for-comment nil save nil))))
1218    
 (defun tcl-do-fill-paragraph (ignore)  
   "fill-paragraph function for Tcl mode.  Only fills in a comment."  
   (let (in-comment col where)  
     (save-excursion  
       (end-of-line)  
       (setq in-comment (tcl-in-comment))  
       (if in-comment  
           (progn  
             (setq where (1+ (point)))  
             (setq col (1- (current-column))))))  
     (and in-comment  
          (save-excursion  
            (back-to-indentation)  
            (= col (current-column)))  
          ;; In a comment.  Set the fill prefix, and find the paragraph  
          ;; boundaries by searching for lines that look like  
          ;; comment-only lines.  
          (let ((fill-prefix (buffer-substring (progn  
                                                 (beginning-of-line)  
                                                 (point))  
                                               where))  
                p-start p-end)  
            ;; Search backwards.  
            (save-excursion  
              (while (and (looking-at "^[ \t]*#[ \t]*[^ \t\n]")  
                          (not (bobp)))  
                (forward-line -1))  
              (setq p-start (point)))  
   
            ;; Search forwards.  
            (save-excursion  
              (while (looking-at "^[ \t]*#[ \t]*[^ \t\n]")  
                (forward-line))  
              (setq p-end (point)))  
   
            ;; Narrow and do the fill.  
            (save-restriction  
              (narrow-to-region p-start p-end)  
              (fill-paragraph ignore)))))  
   t)  
   
1219    
1220    
1221  ;;  ;;

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.69.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26