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

Diff of /auctex/preview/preview.el

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

revision 1.257 by dak, Mon May 23 23:11:02 2005 UTC revision 1.258 by dak, Fri Jun 17 23:03:56 2005 UTC
# Line 792  Pure borderless black-on-white will retu Line 792  Pure borderless black-on-white will retu
792  (defun preview-gs-dvips-process-setup ()  (defun preview-gs-dvips-process-setup ()
793    "Set up Dvips process for conversions via gs."    "Set up Dvips process for conversions via gs."
794    (unless (preview-supports-image-type preview-gs-image-type)    (unless (preview-supports-image-type preview-gs-image-type)
795      (error "This Emacs lacks '%s image support" preview-gs-image-type))      (error "preview-image-type setting '%s unsupported by this Emacs"
796               preview-gs-image-type))
797    (setq preview-gs-command-line (append    (setq preview-gs-command-line (append
798                                   preview-gs-command-line                                   preview-gs-command-line
799                                   (list (preview-gs-resolution                                   (list (preview-gs-resolution
# Line 817  Pure borderless black-on-white will retu Line 818  Pure borderless black-on-white will retu
818    (if preview-parsed-pdfoutput    (if preview-parsed-pdfoutput
819        (if (preview-supports-image-type preview-gs-image-type)        (if (preview-supports-image-type preview-gs-image-type)
820            (preview-pdf2dsc-process-setup)            (preview-pdf2dsc-process-setup)
821          (error "This Emacs lacks '%s image support" preview-gs-image-type))          (error "preview-image-type setting '%s unsupported by this Emacs"
822                   preview-gs-image-type))
823      (unless (preview-supports-image-type preview-dvipng-image-type)      (unless (preview-supports-image-type preview-dvipng-image-type)
824        (error "This Emacs lacks '%s image support"        (error "preview-dvipng-image-type setting '%s unsupported by this Emacs"
825               preview-dvipng-image-type))               preview-dvipng-image-type))
826      (let ((process (preview-start-dvipng)))      (let ((process (preview-start-dvipng)))
827        (setq TeX-sentinel-function #'preview-dvipng-sentinel)        (setq TeX-sentinel-function #'preview-dvipng-sentinel)
# Line 2590  call, and in its CDR the final stuff for Line 2592  call, and in its CDR the final stuff for
2592          (set (nth 1 var) nil))          (set (nth 1 var) nil))
2593        (goto-char (point-min))        (goto-char (point-min))
2594        (unwind-protect        (unwind-protect
2595            (while            (progn
2596                (re-search-forward "\              (while
2597                    (re-search-forward "\
2598  \\(^! \\)\\|\  \\(^! \\)\\|\
2599  \(\\([^()\r\n{ ]+\\))*\\(?:{[^}\n]*}\\)?\\(?: \\|\r?$\\)\\|\  \(\\([^()\r\n{ ]+\\))*\\(?:{[^}\n]*}\\)?\\(?: \\|\r?$\\)\\|\
2600  )+\\( \\|\r?$\\)\\|\  )+\\( \\|\r?$\\)\\|\
# Line 2632  name(\\([^)]+\\))\\)\\|\ Line 2635  name(\\([^)]+\\))\\)\\|\
2635  ;;; This would have caught overfull box messages that consist of  ;;; This would have caught overfull box messages that consist of
2636  ;;; several lines of context all with 79 characters in length except  ;;; several lines of context all with 79 characters in length except
2637  ;;; of the last one.  prauctex.def kills all such messages.  ;;; of the last one.  prauctex.def kills all such messages.
2638              (cond                (cond
2639               ((match-beginning 1)                 ((match-beginning 1)
2640                (if (looking-at "\                  (if (looking-at "\
2641  \\(?:Preview\\|Package Preview Error\\): Snippet \\([---0-9]+\\) \\(started\\|ended\\(\  \\(?:Preview\\|Package Preview Error\\): Snippet \\([---0-9]+\\) \\(started\\|ended\\(\
2642  \\.? *(\\([---0-9]+\\)\\+\\([---0-9]+\\)x\\([---0-9]+\\))\\)?\\)\\.")  \\.? *(\\([---0-9]+\\)\\+\\([---0-9]+\\)x\\([---0-9]+\\))\\)?\\)\\.")
2643                    (progn                      (progn
2644                      (setq snippet (string-to-number (match-string 1))                        (setq snippet (string-to-number (match-string 1))
2645                            box (unless                              box (unless
2646                                    (string= (match-string 2) "started")                                      (string= (match-string 2) "started")
2647                                  (if (match-string 4)                                    (if (match-string 4)
2648                                      (mapcar #'(lambda (x)                                        (mapcar #'(lambda (x)
2649                                                  (* (preview-get-magnification)                                                    (* (preview-get-magnification)
2650                                                     (string-to-number x)))                                                       (string-to-number x)))
2651                                              (list                                                (list
2652                                               (match-string 4)                                                 (match-string 4)
2653                                               (match-string 5)                                                 (match-string 5)
2654                                               (match-string 6)))                                                 (match-string 6)))
2655                                    t))                                      t))
2656                            counters (mapcar #'cdr preview-parsed-counters)                              counters (mapcar #'cdr preview-parsed-counters)
2657                            error (progn                              error (progn
2658                                    (setq lpoint (point))                                      (setq lpoint (point))
2659                                    (end-of-line)                                      (end-of-line)
2660                                    (buffer-substring lpoint (point)))                                      (buffer-substring lpoint (point)))
2661                                                          
2662                            ;; And the context for the help window.                              ;; And the context for the help window.
2663                            context-start (point)                              context-start (point)
2664                                                          
2665                            ;; And the line number to position the cursor.                              ;; And the line number to position the cursor.
2666  ;;; variant 1: profiling seems to indicate the regexp-heavy solution  ;;; variant 1: profiling seems to indicate the regexp-heavy solution
2667  ;;; to be favorable.  Removing incomplete characters from the error  ;;; to be favorable.  Removing incomplete characters from the error
2668  ;;; context is an absolute nuisance.  ;;; context is an absolute nuisance.
2669                            line (and (re-search-forward "\                              line (and (re-search-forward "\
2670  ^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\(?:\\^?\\(?:[89a-f][0-9a-f]\\|[@-_?]\\)\\|\  ^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\(?:\\^?\\(?:[89a-f][0-9a-f]\\|[@-_?]\\)\\|\
2671  \[0-9a-f]?\\)\\)?\\([^\n\r]*?\\)\r?  \[0-9a-f]?\\)\\)?\\([^\n\r]*?\\)\r?
2672  \\([^\n\r]*?\\)\\(\\.\\.\\.\\|\\^\\(?:\\^[89a-f]?\\)?\\.\\.\\.\\)?\r?$" nil t)  \\([^\n\r]*?\\)\\(\\.\\.\\.\\|\\^\\(?:\\^[89a-f]?\\)?\\.\\.\\.\\)?\r?$" nil t)
2673                                      (string-to-number (match-string 1)))                                        (string-to-number (match-string 1)))
2674                            ;; And a string of the context to search for.                              ;; And a string of the context to search for.
2675                            string (and line (match-string 3))                              string (and line (match-string 3))
2676                            after-string (and line (buffer-substring                              after-string (and line (buffer-substring
2677                                                    (+ (match-beginning 4)                                                      (+ (match-beginning 4)
2678                                                       (- (match-end 3)                                                         (- (match-end 3)
2679                                                          (match-beginning 0)))                                                            (match-beginning 0)))
2680                                                    (match-end 4)))                                                      (match-end 4)))
2681                                                          
2682                            ;; And we have now found to the end of the context.                              ;; And we have now found to the end of the context.
2683                            context (buffer-substring context-start (point))                              context (buffer-substring context-start (point))
2684                            ;; We may use these in another buffer.                              ;; We may use these in another buffer.
2685                            offset (car TeX-error-offset)                              offset (car TeX-error-offset)
2686                            file (car TeX-error-file))                              file (car TeX-error-file))
2687                      (when (and (stringp file)                        (when (and (stringp file)
2688                                 (or (string= file "<none>")                                   (or (string= file "<none>")
2689                                     (TeX-match-extension file)))                                       (TeX-match-extension file)))
2690                        ;; if we are the first time round, check for fast hooks:                          ;; if we are the first time round, check for fast hooks:
2691                        (when (null parsestate)                          (when (null parsestate)
2692                          (setq open-data                            (setq open-data
2693                                (save-excursion (funcall open-closure))                                  (save-excursion (funcall open-closure))
2694                                tempdir TeX-active-tempdir)                                  tempdir TeX-active-tempdir)
2695                          (dolist                            (dolist
2696                              (lst (if (listp TeX-translate-location-hook)                                (lst (if (listp TeX-translate-location-hook)
2697                                       TeX-translate-location-hook                                         TeX-translate-location-hook
2698                                     (list TeX-translate-location-hook)))                                       (list TeX-translate-location-hook)))
2699                            (let ((fast                              (let ((fast
2700                                   (and (symbolp lst)                                     (and (symbolp lst)
2701                                        (get lst 'TeX-translate-via-list))))                                          (get lst 'TeX-translate-via-list))))
2702                              (if fast                                (if fast
2703                                  (setq fast-hook                                    (setq fast-hook
2704                                        (nconc fast-hook (list fast)))                                          (nconc fast-hook (list fast)))
2705                                (setq slow-hook                                  (setq slow-hook
2706                                      (nconc slow-hook (list lst)))))))                                        (nconc slow-hook (list lst)))))))
2707                        (condition-case err                          (condition-case err
2708                            (save-excursion (run-hooks 'slow-hook))                              (save-excursion (run-hooks 'slow-hook))
2709                          (error (preview-log-error err "Translation hook")))                            (error (preview-log-error err "Translation hook")))
2710                        (push (vector file (+ line offset)                          (push (vector file (+ line offset)
2711                                      string after-string                                        string after-string
2712                                      snippet box counters) parsestate)))                                        snippet box counters) parsestate)))
2713                  ;; else normal error message                    ;; else normal error message
2714                  (forward-line)                    (forward-line)
2715                  (re-search-forward "^l\\.[0-9]" nil t)                    (re-search-forward "^l\\.[0-9]" nil t)
2716                  (forward-line 2)))                    (forward-line 2)))
2717               ((match-beginning 2)                 ((match-beginning 2)
2718                ;; New file -- Push on stack                  ;; New file -- Push on stack
2719                (push (match-string-no-properties 2) TeX-error-file)                  (push (match-string-no-properties 2) TeX-error-file)
2720                (push 0 TeX-error-offset)                  (push 0 TeX-error-offset)
2721                (goto-char (match-end 2)))                  (goto-char (match-end 2)))
2722               ((match-beginning 3)                 ((match-beginning 3)
2723                ;; End of file -- Pop from stack                  ;; End of file -- Pop from stack
2724                (pop TeX-error-file)                  (pop TeX-error-file)
2725                (pop TeX-error-offset)                  (pop TeX-error-offset)
2726                (goto-char (1+ (match-beginning 0))))                  (goto-char (1+ (match-beginning 0))))
2727               ((match-beginning 4)                 ((match-beginning 4)
2728                ;; Hook to change line numbers                  ;; Hook to change line numbers
2729                (rplaca TeX-error-offset                  (rplaca TeX-error-offset
2730                        (string-to-number (match-string 4))))                          (string-to-number (match-string 4))))
2731               ((match-beginning 5)                 ((match-beginning 5)
2732                ;; Hook to change file name                  ;; Hook to change file name
2733                (rplaca TeX-error-file (match-string-no-properties 5)))                  (rplaca TeX-error-file (match-string-no-properties 5)))
2734               ((match-beginning 6)                 ((match-beginning 6)
2735                (let ((var                  (let ((var
2736                       (assoc (match-string-no-properties 6)                         (assoc (match-string-no-properties 6)
2737                              preview-parse-variables))                                preview-parse-variables))
2738                      (offset (- (match-beginning 0) (match-beginning 7)))                        (offset (- (match-beginning 0) (match-beginning 7)))
2739                      (str (match-string-no-properties 7)))                        (str (match-string-no-properties 7)))
2740                  ;; paste together continuation lines:                    ;; paste together continuation lines:
2741                  (while (= (- (length str) offset) 79)                    (while (= (- (length str) offset) 79)
2742                    (search-forward-regexp "^\\([^\n\r]*\\)\r?$")                      (search-forward-regexp "^\\([^\n\r]*\\)\r?$")
2743                    (setq offset (- (length str))                      (setq offset (- (length str))
2744                          str (concat str (match-string-no-properties 1))))                            str (concat str (match-string-no-properties 1))))
2745                  (when (and var                    (when (and var
2746                             (string-match (nth 2 var) str))                               (string-match (nth 2 var) str))
2747                    (set (nth 1 var)                      (set (nth 1 var)
2748                         (funcall (nth 4 var)                           (funcall (nth 4 var)
2749                                  (match-string-no-properties                                    (match-string-no-properties
2750                                   (nth 3 var)                                     (nth 3 var)
2751                                   str))))))))                                     str))))))))
2752                (when (null parsestate)
2753                  (error "LaTeX found no preview images")))
2754          (unwind-protect          (unwind-protect
2755              (save-excursion              (save-excursion
               (if (null parsestate)  
                   (error "LaTeX found no preview images"))  
2756                (setq parsestate (nreverse parsestate))                (setq parsestate (nreverse parsestate))
2757                (condition-case err                (condition-case err
2758                    (dolist (fun fast-hook)                    (dolist (fun fast-hook)

Legend:
Removed from v.1.257  
changed lines
  Added in v.1.258

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