/[auctex]/auctex/tex.el
ViewVC logotype

Diff of /auctex/tex.el

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

revision 5.502 by angeli, Sun Apr 10 18:00:49 2005 UTC revision 5.503 by angeli, Sat Apr 23 09:14:45 2005 UTC
# Line 3946  in the buffer." Line 3946  in the buffer."
3946  If LOWER-BOUND is given, do not search backward further than this  If LOWER-BOUND is given, do not search backward further than this
3947  point in buffer.  Arguments enclosed in brackets or braces are  point in buffer.  Arguments enclosed in brackets or braces are
3948  considered part of the macro."  considered part of the macro."
3949    (save-excursion    (let ((orig-point (point))
3950      (let ((orig-point (point))          start-point)
3951            opening-brace      ;; Point is located directly at the start of a macro. (-!-\foo{bar})
3952            start-point)      (when (and (eq (char-after) (aref TeX-esc 0))
       (if (and (eq (char-after) (aref TeX-esc 0))  
3953                 (not (TeX-escaped-p)))                 (not (TeX-escaped-p)))
3954            ;; Point is located directly at the start of a macro.        (setq start-point (point)))
3955            (setq start-point (point))      ;; Point is located on a macro. (\fo-!-o{bar})
3956          ;; Search backward for a macro start.      (unless start-point
3957          (setq start-point (TeX-find-macro-start-helper lower-bound))        (save-excursion
3958          (setq opening-brace (TeX-find-opening-brace nil lower-bound))          (skip-chars-backward "A-Za-z@*")
3959          ;; Cases {\foo ba-!-r} or \foo{bar\baz{bla}bl-!-u}          (when (and (eq (char-before) (aref TeX-esc 0))
3960          ;; FIXME: Fails on \foo{\bar}{ba-!-z} constructs.                     (not (TeX-escaped-p (1- (point)))))
3961          (when (and opening-brace start-point            (setq start-point (1- (point))))))
3962                     (> start-point opening-brace)      ;; Point is located in the argument of a macro. (\foo{ba-!-r})
3963                     (>= (point) (TeX-find-macro-end-helper start-point)))      (unless start-point
3964            (goto-char opening-brace)        (save-excursion
3965            (setq start-point (TeX-find-macro-start-helper lower-bound))))          (catch 'abort
3966              (when (condition-case nil (progn (up-list) t) (error nil))
3967        (when start-point              (while (progn
3968          ;; Search forward for the end of the macro.                       (condition-case nil (backward-sexp)
3969                           (error (throw 'abort nil)))
3970                         (forward-comment -1)
3971                         (and (memq (char-before) '(?\] ?\}))
3972                              (not (TeX-escaped-p (1- (point)))))))
3973                (skip-chars-backward "A-Za-z@*")
3974                (when (and (eq (char-before) (aref TeX-esc 0))
3975                           (not (TeX-escaped-p (1- (point)))))
3976                  (setq start-point (1- (point))))))))
3977        ;; Search forward for the end of the macro.
3978        (when start-point
3979          (save-excursion
3980          (goto-char (TeX-find-macro-end-helper start-point))          (goto-char (TeX-find-macro-end-helper start-point))
3981          (if (< orig-point (point))          (if (< orig-point (point))
3982              (cons start-point (point))              (cons start-point (point))
3983            nil)))))            nil)))))
3984    
 (defun TeX-find-macro-start-helper (&optional limit)  
    "Find the starting token of a macro.  
 If LIMIT is given, do not search backward further than this point  
 in buffer.  
   
 In TeX, LaTeX or ConTeXt the token is a `\\' character, in  
 Texinfo it is the character `@'.  In case an escaped character is  
 found, return the position before the escaping character."  
    (save-excursion  
      (save-match-data  
        (and (search-backward TeX-esc limit t)  
             (- (point)  
                (mod (skip-chars-backward (regexp-quote TeX-esc)) 2))))))  
   
3985  (defun TeX-find-macro-end-helper (start)  (defun TeX-find-macro-end-helper (start)
3986    "Find the end of a macro given its START.    "Find the end of a macro given its START.
3987  START is the position just before the starting token of the macro.  START is the position just before the starting token of the macro.

Legend:
Removed from v.5.502  
changed lines
  Added in v.5.503

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