yatex
diff yatexlib.el @ 70:44e3a5e1e883
Fix makefile for Windows
Brush up label completion
\cite completion
Support much more about LaTeX2e
---
[yahtml]
English Info (By Jun Ohya)
Automatic pixel size detection for <img src="...">
Aware global-class of css definition
& for char-entity reference
author | yuuji |
---|---|
date | Sun, 09 Apr 2000 03:37:47 +0000 |
parents | 807c1e7e68b7 |
children | 0aaebd07dad0 |
line diff
1.1 --- a/yatexlib.el Thu Jul 15 04:58:26 1999 +0000 1.2 +++ b/yatexlib.el Sun Apr 09 03:37:47 2000 +0000 1.3 @@ -1,8 +1,8 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; YaTeX and yahtml common libraries, general functions and definitions 1.6 ;;; yatexlib.el 1.7 -;;; (c )1994-1999 by HIROSE Yuuji.[yuuji@gentei.org] 1.8 -;;; Last modified Tue May 4 10:25:55 1999 on firestorm 1.9 +;;; (c )1994-2000 by HIROSE Yuuji.[yuuji@yatex.org] 1.10 +;;; Last modified Sun Apr 9 12:36:25 2000 on firestorm 1.11 ;;; $Id$ 1.12 1.13 ;; General variables 1.14 @@ -16,6 +16,9 @@ 1.15 (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) YaTeX-emacs-20) 1.16 "Whether yatex mode is running on Japanese environment or not.") 1.17 1.18 +;; autoload from yahtml.el 1.19 +(autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t) 1.20 + 1.21 (defvar YaTeX-kanji-code-alist 1.22 (cond 1.23 ((boundp '*junet*) 1.24 @@ -318,7 +321,14 @@ 1.25 "Switch to buffer if buffer exists, find file if not. 1.26 Optional second arg SETBUF t make use set-buffer instead of switch-to-buffer." 1.27 (interactive "Fswitch to file: ") 1.28 - (if (bufferp file) (setq file (buffer-file-name file))) 1.29 + (if (bufferp file) 1.30 + (setq file (buffer-file-name file)) 1.31 + (and (string-match "^[^/].*/" file) 1.32 + (eq major-mode 'yatex-mode) 1.33 + YaTeX-search-file-from-top-directory 1.34 + (save-excursion 1.35 + (YaTeX-visit-main t) 1.36 + (setq file (expand-file-name file))))) 1.37 (let (buf (hilit-auto-highlight (not setbuf))) 1.38 (cond 1.39 ((setq buf (get-file-buffer file)) 1.40 @@ -337,6 +347,13 @@ 1.41 (defun YaTeX-switch-to-buffer-other-window (file) 1.42 "Switch to buffer if buffer exists, find file if not." 1.43 (interactive "Fswitch to file: ") 1.44 + (and (eq major-mode 'yatex-mode) 1.45 + (stringp file) 1.46 + (string-match "^[^/].*/" file) 1.47 + YaTeX-search-file-from-top-directory 1.48 + (save-excursion 1.49 + (YaTeX-visit-main t) 1.50 + (setq file (expand-file-name file)))) 1.51 (if (bufferp file) (setq file (buffer-file-name file))) 1.52 (cond 1.53 ((get-file-buffer file) 1.54 @@ -347,13 +364,24 @@ 1.55 (t (message "%s was not found in this directory." file) 1.56 nil))) 1.57 1.58 +(defun YaTeX-get-file-buffer (file) 1.59 + "Return the FILE's buffer. 1.60 +Base directory is that of main file or current directory." 1.61 + (let (dir main (cdir default-directory)) 1.62 + (or (and (eq major-mode 'yatex-mode) 1.63 + YaTeX-search-file-from-top-directory 1.64 + (save-excursion 1.65 + (YaTeX-visit-main t) 1.66 + (get-file-buffer file))) 1.67 + (get-file-buffer file)))) 1.68 + 1.69 (defun YaTeX-replace-format-sub (string format repl) 1.70 (let ((beg (or (string-match (concat "^\\(%" format "\\)") string) 1.71 (string-match (concat "[^%]\\(%" format "\\)") string))) 1.72 (len (length format))) 1.73 (if (null beg) string ;no conversion 1.74 (concat 1.75 - (substring string 0 (match-beginning 1)) repl 1.76 + (substring string 0 (match-beginning 1)) (or repl "") 1.77 (substring string (match-end 1)))))) 1.78 1.79 ;;;###autoload 1.80 @@ -367,6 +395,15 @@ 1.81 string)) 1.82 1.83 ;;;###autoload 1.84 +(defun YaTeX-replace-formats (string replace-list) 1.85 + (let ((list replace-list)) 1.86 + (while list 1.87 + (setq string (YaTeX-replace-format 1.88 + string (car (car list)) (cdr (car list))) 1.89 + list (cdr list))) 1.90 + string)) 1.91 + 1.92 +;;;###autoload 1.93 (defun YaTeX-replace-format-args (string &rest args) 1.94 "Translate the argument mark #1, #2, ... #n in the STRING into the 1.95 corresponding real arguments ARGS." 1.96 @@ -643,13 +680,49 @@ 1.97 (fset 'YaTeX-rassoc 1.98 (if (and nil (fboundp 'rassoc) (subrp (symbol-function 'rassoc))) 1.99 (symbol-function 'rassoc) 1.100 - (lambda (key list) 1.101 - (let ((l list)) 1.102 - (catch 'found 1.103 - (while l 1.104 - (if (equal key (cdr (car l))) 1.105 - (throw 'found (car l))) 1.106 - (setq l (cdr l)))))))) 1.107 + (function 1.108 + (lambda (key list) 1.109 + (let ((l list)) 1.110 + (catch 'found 1.111 + (while l 1.112 + (if (equal key (cdr (car l))) 1.113 + (throw 'found (car l))) 1.114 + (setq l (cdr l))))))))) 1.115 + 1.116 +(defun YaTeX-insert-file-contents (file visit &optional beg end) 1.117 + (cond 1.118 + ((string< "19" emacs-version) 1.119 + (insert-file-contents file visit beg end)) 1.120 + ((string-match "unix" (symbol-name system-type)) 1.121 + (let ((default-process-coding-system 1.122 + (and (boundp '*noconv*) (list *noconv*))) 1.123 + file-coding-system (and (boundp '*noconv*) *noconv*) 1.124 + kanji-fileio-code 1.125 + (default-process-kanji-code 0)) 1.126 + (call-process shell-file-name file (current-buffer) nil 1.127 + (or (and (boundp 'shell-command-option) 1.128 + shell-command-option) 1.129 + "-c") 1.130 + (format "head -c %d | tail -c +%d" end beg)))) 1.131 + (t (insert-file-contents file)))) 1.132 + 1.133 +(defun YaTeX-split-string (str &optional sep null) 1.134 + "Split string STR by every occurrence of SEP(regexp). 1.135 +If the optional second argument SEP is nil, it defaults to \"[ \f\t\n\r\v]+\". 1.136 +Do not include null string by default. Non-nil for optional third argument 1.137 +NULL includes null string in a list." 1.138 + (let ((sep (or sep "[ \f\t\n\r\v]+")) 1.139 + list m) 1.140 + (while str 1.141 + (if (setq m (string-match sep str)) 1.142 + (progn 1.143 + (if (or (> m 0) null) 1.144 + (setq list (cons (substring str 0 m) list))) 1.145 + (setq str (substring str (match-end 0)))) 1.146 + (if (or null (string< "" str)) 1.147 + (setq list (cons str list))) 1.148 + (setq str nil))) 1.149 + (nreverse list))) 1.150 1.151 ;;; 1.152 ;; Interface function for windows.el 1.153 @@ -752,6 +825,52 @@ 1.154 (YaTeX-replace-format-args YaTeX-struct-begin env "" "") 1.155 (count-lines (point-min) (point)))))))) 1.156 1.157 +(defun YaTeX-beginning-of-environment (&optional limit-search-bound end) 1.158 + "Goto the beginning of the current environment. 1.159 +Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to 1.160 +most recent sectioning command. Non-nil for optional third argument END 1.161 +goes to end of environment." 1.162 + (interactive) 1.163 + (let ((op (point))) 1.164 + (if (YaTeX-inner-environment limit-search-bound) 1.165 + (progn 1.166 + (goto-char (get 'YaTeX-inner-environment 'point)) 1.167 + (and end (YaTeX-goto-corresponding-environment)) 1.168 + (if (interactive-p) (push-mark op)) 1.169 + t)))) 1.170 + 1.171 +(defun YaTeX-end-of-environment (&optional limit-search-bound) 1.172 + "Goto the end of the current environment. 1.173 +Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound 1.174 +to most recent sectioning command." 1.175 + (interactive) 1.176 + (YaTeX-beginning-of-environment limit-search-bound t)) 1.177 + 1.178 +(defun YaTeX-mark-environment () 1.179 + "Mark current position and move point to end of environment." 1.180 + (interactive) 1.181 + (let ((curp (point))) 1.182 + (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin 1.183 + (forward-line 1) 1.184 + (beginning-of-line)) 1.185 + (if (not (YaTeX-end-of-environment)) ;arg1 turns to match-beginning 1 1.186 + (progn 1.187 + (goto-char curp) 1.188 + (error "Cannot found the end of current environment.")) 1.189 + (YaTeX-goto-corresponding-environment) 1.190 + (beginning-of-line) ;for confirmation 1.191 + (if (< curp (point)) 1.192 + (progn 1.193 + (message "Mark this environment?(y or n): ") 1.194 + (if (= (read-char) ?y) nil 1.195 + (goto-char curp) 1.196 + (error "Abort. Please call again at more proper position.")))) 1.197 + (set-mark-command nil) 1.198 + (YaTeX-goto-corresponding-environment) 1.199 + (end-of-line) 1.200 + (if (eobp) nil (forward-char 1))))) 1.201 + 1.202 + 1.203 ;;;VER2 1.204 (defun YaTeX-insert-struc (what env) 1.205 (cond 1.206 @@ -817,5 +936,4 @@ 1.207 (mapcar 'byte-compile-file command-line-args-left) 1.208 (kill-emacs)))) 1.209 1.210 - 1.211 (provide 'yatexlib)