yatex

changeset 248:b9771459243e dev

Automatic `bb=...' generation for jpg/png/gif/bmp files.
author yuuji@gentei.org
date Fri, 10 Feb 2012 16:45:04 +0900
parents 3e3ccba06ca1
children c2aa2457a74b
files yatexadd.el
diffstat 1 files changed, 25 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/yatexadd.el	Fri Feb 10 12:31:58 2012 +0900
     1.2 +++ b/yatexadd.el	Fri Feb 10 16:45:04 2012 +0900
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; YaTeX add-in functions.
     1.5  ;;; yatexadd.el rev.20
     1.6  ;;; (c)1991-2012 by HIROSE Yuuji.[yuuji@yatex.org]
     1.7 -;;; Last modified Fri Feb 10 09:50:00 2012 on firestorm
     1.8 +;;; Last modified Fri Feb 10 16:30:39 2012 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;;;
    1.12 @@ -1885,14 +1885,13 @@
    1.13  				 (format "%s=%s" s (symbol-value s))))
    1.14  			 '(width height scale angle)))
    1.15  	   ","))
    1.16 -    (setq YaTeX-section-name "caption")
    1.17      (if (string= "" str) ""
    1.18        (concat "[" str "]"))))
    1.19  
    1.20  (defun YaTeX::includegraphics (argp)
    1.21    "Add-in for \\includegraphics"
    1.22    (let ((imgfile (YaTeX::include argp "Image File: "))
    1.23 -	(case-fold-search t) info bb)
    1.24 +	(case-fold-search t) info bb noupdate needclose)
    1.25      (and (string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\)$" imgfile)
    1.26  	 (file-exists-p imgfile)
    1.27  	 (or (fboundp 'yahtml-get-image-info)
    1.28 @@ -1902,7 +1901,29 @@
    1.29  	 (car info)			;if has width value
    1.30  	 (car (cdr info))		;if has height value
    1.31  	 (setq bb (format "bb=%d %d %d %d" 0 0 (car info) (car (cdr info))))
    1.32 -	 (YaTeX-push-to-kill-ring bb))
    1.33 +	 (save-excursion
    1.34 +	   (cond
    1.35 +	    ((and (YaTeX-re-search-active-backward
    1.36 +		   "\\\\\\(includegraphics\\)\\|\\(bb=[ \t0-9]+\\)"
    1.37 +		   YaTeX-comment-prefix nil t)
    1.38 +		  (match-beginning 2)
    1.39 +		  (not (setq noupdate (equal (YaTeX-match-string 2) bb)))
    1.40 +		  (y-or-n-p (format "Update `bb=' line to `%s'?: " bb)))
    1.41 +	     (message "")
    1.42 +	     (replace-match bb))
    1.43 +	    (noupdate nil)
    1.44 +	    ((and (match-beginning 1)
    1.45 +		  (y-or-n-p "Insert `bb=...' line?: "))
    1.46 +	     (goto-char (match-end 0))
    1.47 +	     (message "")
    1.48 +	     (if (looking-at "\\[") (forward-char 1)
    1.49 +	       (insert-before-markers "[")
    1.50 +	       (setq needclose t))
    1.51 +	     (insert-before-markers bb)
    1.52 +	     (if needclose (insert-before-markers "]")
    1.53 +	       (or (looking-at "\\]") (insert-before-markers ","))))
    1.54 +	    (t (YaTeX-push-to-kill-ring bb)))))
    1.55 +    (setq YaTeX-section-name "caption")
    1.56      imgfile))
    1.57   
    1.58  (defun YaTeX::verbfile (argp)