Mercurial > hgrepos > hgweb.cgi > yatex
comparison yatexlib.el @ 366:77a2fd4fd634
merged
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 26 Dec 2014 01:06:32 +0900 |
parents | d69fd7b1ac4d |
children | e8f95c375526 |
comparison
equal
deleted
inserted
replaced
300:30f1a2659a39 | 366:77a2fd4fd634 |
---|---|
1 ;;; yatexlib.el --- YaTeX and yahtml common libraries | 1 ;;; yatexlib.el --- YaTeX and yahtml common libraries |
2 ;;; | 2 ;;; |
3 ;;; (c)1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] | 3 ;;; (c)1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] |
4 ;;; Last modified Mon Apr 1 22:44:06 2013 on firestorm | 4 ;;; Last modified Sun Dec 21 23:55:30 2014 on firestorm |
5 ;;; $Id$ | 5 ;;; $Id$ |
6 | 6 |
7 ;;; Code: | 7 ;;; Code: |
8 ;; General variables | 8 ;; General variables |
9 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) | 9 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) |
285 (goto-char (point-max)) | 285 (goto-char (point-max)) |
286 (search-backward (concat "(setq " name) nil t) | 286 (search-backward (concat "(setq " name) nil t) |
287 (delete-region (point) (progn (forward-sexp) (point))) | 287 (delete-region (point) (progn (forward-sexp) (point))) |
288 (delete-blank-lines) | 288 (delete-blank-lines) |
289 (insert "(setq " name " '(\n") | 289 (insert "(setq " name " '(\n") |
290 (mapcar '(lambda (s) | 290 (mapcar (function (lambda (s) |
291 (insert (format "%s\n" (prin1-to-string s)))) | 291 (insert (format "%s\n" (prin1-to-string s))))) |
292 value) | 292 value) |
293 (insert "))\n\n") | 293 (insert "))\n\n") |
294 (delete-blank-lines) | 294 (delete-blank-lines) |
295 (basic-save-buffer) | 295 (basic-save-buffer) |
296 (kill-buffer local-table-buf) | 296 (kill-buffer local-table-buf) |
479 | 479 |
480 ;;;###autoload | 480 ;;;###autoload |
481 (defun point-end-of-line () | 481 (defun point-end-of-line () |
482 (save-excursion (end-of-line)(point))) | 482 (save-excursion (end-of-line)(point))) |
483 | 483 |
484 | 484 (defun YaTeX-showup-buffer-bottom-most (x) (nth 3 (window-edges x))) |
485 ;;;###autoload | 485 ;;;###autoload |
486 (defun YaTeX-showup-buffer (buffer &optional func select) | 486 (defun YaTeX-showup-buffer (buffer &optional func select) |
487 "Make BUFFER show up in certain window (but current window) | 487 "Make BUFFER show up in certain window (but current window) |
488 that gives the maximum value by the FUNC. FUNC should take an argument | 488 that gives the maximum value by the FUNC. FUNC should take an argument |
489 of its window object. Non-nil for optional third argument SELECT selects | 489 of its window object. Non-nil for optional third argument SELECT selects |
512 (or select (select-window window))) | 512 (or select (select-window window))) |
513 ((= (length wlist) 2) | 513 ((= (length wlist) 2) |
514 ;(other-window 1);This does not work properly on Emacs-19 | 514 ;(other-window 1);This does not work properly on Emacs-19 |
515 (select-window (get-lru-window)) | 515 (select-window (get-lru-window)) |
516 (switch-to-buffer buffer) | 516 (switch-to-buffer buffer) |
517 (if (< (window-height) (/ YaTeX-default-pop-window-height 2)) | |
518 (enlarge-window (- YaTeX-default-pop-window-height | |
519 (window-height)))) | |
517 (or select (select-window window))) | 520 (or select (select-window window))) |
518 (t ;if one-window | 521 (t ;if one-window |
519 (cond | 522 (cond |
520 ((and YaTeX-emacs-19 window-system (get-buffer-window buffer t)) | 523 ((and YaTeX-emacs-19 window-system (get-buffer-window buffer t)) |
521 nil) ;if found in other frame | 524 nil) ;if found in other frame |
778 (while l | 781 (while l |
779 (if (equal key (cdr (car l))) | 782 (if (equal key (cdr (car l))) |
780 (throw 'found (car l))) | 783 (throw 'found (car l))) |
781 (setq l (cdr l))))))))) | 784 (setq l (cdr l))))))))) |
782 | 785 |
786 (defun YaTeX-set-file-coding-system (code coding) | |
787 "Set current buffer's coding system according to symbol." | |
788 (cond ((null code) | |
789 nil) | |
790 ((boundp 'MULE) | |
791 (set-file-coding-system coding)) | |
792 ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system)) | |
793 (setq buffer-file-coding-system | |
794 (or (and (fboundp 'set-auto-coding) buffer-file-name | |
795 (save-excursion | |
796 (goto-char (point-min)) | |
797 (set-auto-coding buffer-file-name (buffer-size)))) | |
798 coding))) | |
799 ((featurep 'mule) | |
800 (set-file-coding-system coding)) | |
801 ((boundp 'NEMACS) | |
802 (make-local-variable 'kanji-fileio-code) | |
803 (setq kanji-fileio-code code)))) | |
804 | |
783 (defun YaTeX-insert-file-contents (file visit &optional beg end) | 805 (defun YaTeX-insert-file-contents (file visit &optional beg end) |
784 (cond | 806 (cond |
785 ((and (string< "19" emacs-version) (not (featurep 'xemacs))) | 807 ((and (string< "19" emacs-version) (not (featurep 'xemacs))) |
786 (insert-file-contents file visit beg end)) | 808 (insert-file-contents file visit beg end)) |
787 ((string-match "unix\\|linux" (symbol-name system-type)) | 809 ((string-match "unix\\|linux" (symbol-name system-type)) |
842 ;;; | 864 ;;; |
843 ;;;###autoload | 865 ;;;###autoload |
844 (fset 'YaTeX-last-key | 866 (fset 'YaTeX-last-key |
845 (if (fboundp 'win:last-key) | 867 (if (fboundp 'win:last-key) |
846 'win:last-key | 868 'win:last-key |
847 '(lambda () (if (boundp 'last-command-char) | 869 (function (lambda () (if (boundp 'last-command-char) |
848 last-command-char | 870 last-command-char |
849 last-command-event)))) | 871 last-command-event))))) |
850 (defun YaTeX-switch-to-window () | 872 (defun YaTeX-switch-to-window () |
851 "Switch to windows.el's window decided by last pressed key." | 873 "Switch to windows.el's window decided by last pressed key." |
852 (interactive) | 874 (interactive) |
853 (or (featurep 'windows) (error "Why don't you use `windows.el'?")) | 875 (or (featurep 'windows) (error "Why don't you use `windows.el'?")) |
854 (win-switch-to-window 1 (- (YaTeX-last-key) win:base-key))) | 876 (win-switch-to-window 1 (- (YaTeX-last-key) win:base-key))) |
1462 (face-font 'default) | 1484 (face-font 'default) |
1463 (face-font 'italic) | 1485 (face-font 'italic) |
1464 (face-font 'bold) | 1486 (face-font 'bold) |
1465 "giveup!")) | 1487 "giveup!")) |
1466 sz medium-i bold-r) | 1488 sz medium-i bold-r) |
1467 (string-match | 1489 (if (string-match |
1468 "^-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-\\(\\([0-9]+\\)\\)" df) | 1490 "^-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-\\(\\([0-9]+\\)\\)" df) |
1469 (setq sz (or (match-string 1 df) "16")) | 1491 (setq sz (or (match-string 1 df) "16")) |
1492 (setq sz "16")) | |
1470 (setq medium-i (format "-medium-i-[^-]+--%s" sz) | 1493 (setq medium-i (format "-medium-i-[^-]+--%s" sz) |
1471 bold-r (format "-bold-r-[^-]+--%s" sz)) | 1494 bold-r (format "-bold-r-[^-]+--%s" sz)) |
1472 (while flist | 1495 (while flist |
1473 (setq fnt (car flist)) | 1496 (setq fnt (car flist)) |
1474 (condition-case err | 1497 (condition-case err |