diff --git a/init.el b/init.el index d942ac4..33b9af3 100644 --- a/init.el +++ b/init.el @@ -22,6 +22,8 @@ (require 'coding-utf8) ;;; call 1row-scroll (require '1row-scroll) +;;; call reload +(require 'reload) ;;; Set language (set-language-environment "Japanese") diff --git a/lisp/1row-scroll.el b/lisp/1row-scroll.el index 7828cc0..0419415 100644 --- a/lisp/1row-scroll.el +++ b/lisp/1row-scroll.el @@ -1,9 +1,9 @@ -;;; 1row-scroll.el --- -;;;-*- coding:utf-8 -*- +;-*- coding:utf-8 -*- +;;; 1row-scroll.el --- -*- lexical-binding: t; -*- -;; Copyright (C) 2015 toshiki KAWAI +;; Copyright (C) 2015 toshiki kawai -;; Author: toshiki KAWAI +;; Author: toshiki kawai ;; Keywords: ;; This program is free software; you can redistribute it and/or modify @@ -24,15 +24,11 @@ ;; ;;; Code: - (global-set-key "\C-z" '(lambda (arg) (interactive "p") (scroll-up arg))) (global-set-key "\C-o" '(lambda (arg) (interactive "p") (scroll-down arg))) -;;;(global-set-key "\C-u" -;;;'suspend-emacs) - (provide '1row-scroll) ;;; 1row-scroll.el ends here diff --git a/lisp/coding-utf8.el b/lisp/coding-utf8.el index 232ee73..aa47488 100644 --- a/lisp/coding-utf8.el +++ b/lisp/coding-utf8.el @@ -1,11 +1,30 @@ ;;-*- coding:utf-8 -*- -;; Copyright (C) 2014 Toshiki KAWAI +;;; coding-utf8.el --- -*- lexical-binding: t; -*- -;; Author: Toshiki KAWAI +;; Copyright (C) 2014 toshiki kawai + +;; Author: toshiki kawai ;; Keywords: coding utf-8 -;; val -> pos :: 未実装 +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;; val -> pos :: undefine (defun insert-utf8 () (goto-char (point-min)) (insert comment-start) @@ -20,6 +39,8 @@ (insert-utf8) (insert "-*- coding:utf-8 -*- ")))) +;; keybinding: C-c u +;; Insert an comment of 'coding:utf-8'. (define-key global-map "\C-cu" 'insert-string-utf8) (provide 'coding-utf8) diff --git a/lisp/reload.el b/lisp/reload.el new file mode 100644 index 0000000..945f0b9 --- /dev/null +++ b/lisp/reload.el @@ -0,0 +1,53 @@ +;-*- coding:utf-8 -*- +;;; reload.el --- -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 toshiki kawai + +;; Author: toshiki kawai +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +;;; reference: https://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init +;;; Order to find Emacs init file. +;;; 1. ~/.emacs +;;; 2. ~/.emacs.el +;;; 3. ~/.emacs.d/init.el +(setq init-files '("~/.emacs" "~/.emacs.el" "~/.emacs.d/init.el")) + +(defun load-init-file (list) + "load init file for Emacs." + (interactive) + (when list ;; recursive. + (let ((f (car list))) ;; get a first element. + ;; if (f is not nil) and (f is file) + (when (and f (file-readable-p f)) + (load-file f) + ;; output message to mini buffer. + (message (concat "reload " f " complete!"))) + (load-init-file (cdr list))) + )) + +;;(define-key global-map "\C-c\C-r" 'load-init-file) +(define-key global-map "\C-c\C-r" + '(lambda () (interactive) (load-init-file init-files))) + +(provide 'reload) +;;; reload.el ends here diff --git a/lisp/satysfi.el b/lisp/satysfi.el new file mode 100644 index 0000000..82ce46e --- /dev/null +++ b/lisp/satysfi.el @@ -0,0 +1,111 @@ +;;; satysfi.el --- SATySFi -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2018 Takashi SUWA + +(provide 'satysfi) + + +(defface satysfi-row-command-face + '((t (:foreground "#8888ff" :background "dark"))) + "SATySFi row command") + +(defface satysfi-column-command-face + '((t (:foreground "#ff8888" :background "dark"))) + "SATySFi column command") + +(defface satysfi-var-in-string-face + '((t (:foreground "#44ff88" :background "dark"))) + "SATySFi variable in string") + +(defface satysfi-escaped-character + '((t (:foreground "#cc88ff" :background "dark"))) + "SATySFi escaped character") + +(defface satysfi-literal-area + '((t (:foreground "#ffff44" :background "dark"))) + "SATySFi literal area") + +(defvar satysfi-pdf-viewer-command "open") + +(defvar satysfi-command "satysfi -b") + +(defun satysfi-mode/insert-pair-scheme (open-string close-string) + (cond ((use-region-p) + (let ((rb (region-beginning))) + (let ((re (region-end))) + (progn + (goto-char rb) + (insert open-string) + (goto-char (+ (length open-string) re)) + (insert close-string) + (forward-char -1))))) + (t + (progn + (insert (format "%s%s" open-string close-string)) + (forward-char -1))))) + +(defun satysfi-mode/insert-paren-pair () + (interactive) + (satysfi-mode/insert-pair-scheme "(" ")")) + +(defun satysfi-mode/insert-brace-pair () + (interactive) + (satysfi-mode/insert-pair-scheme "{" "}")) + +(defun satysfi-mode/insert-square-bracket-pair () + (interactive) + (satysfi-mode/insert-pair-scheme "[" "]")) + +(defun satysfi-mode/insert-angle-bracket-pair () + (interactive) + (satysfi-mode/insert-pair-scheme "<" ">")) + +(defun satysfi-mode/insert-math-brace-pair () + (interactive) + (satysfi-mode/insert-pair-scheme "${" "}")) + +(defun satysfi-mode/open-pdf () + (interactive) + (let ((pdf-file-path (concat (file-name-sans-extension buffer-file-name) ".pdf"))) + (progn + (message "Opening '%s' ..." pdf-file-path) + (async-shell-command (format "%s %s\n" satysfi-pdf-viewer-command pdf-file-path))))) + +(defun satysfi-mode/typeset () + (interactive) + (progn + (message "Typesetting '%s' ..." buffer-file-name) + (async-shell-command (format "%s %s\n" satysfi-command buffer-file-name)))) + +(defvar satysfi-mode-map (copy-keymap global-map)) +(define-key satysfi-mode-map (kbd "(") 'satysfi-mode/insert-paren-pair) +(define-key satysfi-mode-map (kbd "[") 'satysfi-mode/insert-square-bracket-pair) +(define-key satysfi-mode-map (kbd "<") 'satysfi-mode/insert-angle-bracket-pair) +(define-key satysfi-mode-map (kbd "{") 'satysfi-mode/insert-brace-pair) +(define-key satysfi-mode-map (kbd "$") 'satysfi-mode/insert-math-brace-pair) +(define-key satysfi-mode-map (kbd "C-c C-t") 'satysfi-mode/typeset) +(define-key satysfi-mode-map (kbd "C-c C-f") 'satysfi-mode/open-pdf) + +(define-generic-mode satysfi-mode + '(?%) + + '("let" "let-rec" "let-mutable" "let-inline" "let-block" "let-math" "in" "and" + "match" "with" "when" "as" "if" "then" "else" "fun" + "type" "constraint" "val" "direct" "of" + "module" "struct" "sig" "end" + "before" "while" "do" + "controls" "cycle") + + '(("\\(\\\\\\(?:\\\\\\\\\\)*[a-zA-Z0-9\\-]+\\)\\>" + (1 'satysfi-row-command-face t)) + ("\\(\\+[a-zA-Z0-9\\-]+\\)\\>" + (1 'satysfi-column-command-face t)) + ("\\(@[a-z][0-9A-Za-z\\-]*\\)\\>" + (1 'satysfi-var-in-string-face t)) + ("\\(\\\\\\(?:@\\|`\\|\\*\\| \\|%\\||\\|;\\|{\\|}\\|\\\\\\)\\)" + (1 'satysfi-escaped-character t)) +; ("\\(`\\(?:[^`]\\|\\n\\)+`\\)" (1 'satysfi-literal-area t)) + ) + + nil + '((lambda () (use-local-map satysfi-mode-map))))