changeset 247:3e3ccba06ca1 dev

Construct `bb=...' line automatically and push it into kill-ring.
author yuuji@gentei.org
date Fri, 10 Feb 2012 12:31:58 +0900
parents 9105918e45a2
children b9771459243e
files yatexadd.el yatexlib.el
diffstat 2 files changed, 29 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/yatexadd.el	Fri Feb 10 09:09:08 2012 +0900
+++ b/yatexadd.el	Fri Feb 10 12:31:58 2012 +0900
@@ -2,7 +2,7 @@
 ;;; YaTeX add-in functions.
 ;;; yatexadd.el rev.20
 ;;; (c)1991-2012 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Thu Feb  9 09:33:55 2012 on firestorm
+;;; Last modified Fri Feb 10 09:50:00 2012 on firestorm
 ;;; $Id$
 
 ;;;
@@ -1225,17 +1225,11 @@
 		  (format "New %s name: " (or labname "label"))
 		  (cons dlab 1))))
       (if (string< "" label)
-	  (let ((refstr (format "\\%s{%s}" (or refname "ref") label))
-		(key (key-description (where-is-internal 'yank nil t)))
-		(msg
-		 (if YaTeX-japan
-		     "をkill-ringに入れました。yank(%s)で取り出せます。"
-		   " is stored into kill-ring.  Paste it by yank(%s).")))
-	    (kill-new refstr)
+	  (let ((refstr (format "\\%s{%s}" (or refname "ref") label)))
+	    (YaTeX-push-to-kill-ring refstr)
 	    (and chmode
 		 (not (equal old label))
-		 (YaTeX::label-rename-refs old label))
-	    (message (concat "`%s'" msg) refstr key)))
+		 (YaTeX::label-rename-refs old label))))
       label))))
       
 
@@ -1897,7 +1891,19 @@
 
 (defun YaTeX::includegraphics (argp)
   "Add-in for \\includegraphics"
-  (YaTeX::include argp "Image File: "))
+  (let ((imgfile (YaTeX::include argp "Image File: "))
+	(case-fold-search t) info bb)
+    (and (string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\)$" imgfile)
+	 (file-exists-p imgfile)
+	 (or (fboundp 'yahtml-get-image-info)
+	     (progn
+	       (load "yahtml" t) (featurep 'yahtml))) ;(require 'yahtml nil t)
+	 (setq info (yahtml-get-image-info imgfile))
+	 (car info)			;if has width value
+	 (car (cdr info))		;if has height value
+	 (setq bb (format "bb=%d %d %d %d" 0 0 (car info) (car (cdr info))))
+	 (YaTeX-push-to-kill-ring bb))
+    imgfile))
  
 (defun YaTeX::verbfile (argp)
   "Add-in for \\verbfile"
--- a/yatexlib.el	Fri Feb 10 09:09:08 2012 +0900
+++ b/yatexlib.el	Fri Feb 10 12:31:58 2012 +0900
@@ -2,7 +2,7 @@
 ;;; YaTeX and yahtml common libraries, general functions and definitions
 ;;; yatexlib.el
 ;;; (c)1994-2012 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Thu Feb  9 08:32:18 2012 on firestorm
+;;; Last modified Fri Feb 10 12:30:49 2012 on firestorm
 ;;; $Id$
 
 ;; General variables
@@ -1523,6 +1523,17 @@
 	    (throw 'found (car alist)))
 	(setq alist (cdr alist))))))
 
+(defun YaTeX-push-to-kill-ring (string)
+  "Push STRING to kill-ring, then show guidance message."
+  (and (stringp string) (string< "" string)
+       (let ((key (key-description (where-is-internal 'yank nil t)))
+	     (msg
+	      (if YaTeX-japan
+		  " をkill-ringに入れました。次のyank(%s)で貼付できます"
+		" is stored into kill-ring.  Paste it by yank(%s).")))
+	 (kill-new string)
+	 (message (concat "`%s'" msg) string key))))
+
 ;;;
 ;; Functions for the Installation time
 ;;;

yatex.org