Created
September 5, 2011 05:52
-
-
Save pogin503/1194191 to your computer and use it in GitHub Desktop.
OmmWritterの機能をEmacsで出来ないかと思い作ったモード。執筆作業に最適。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; omm-mode.el | |
;; -*- Mode: Emacs-Lisp -*- | |
;; Copyright (C) pogin | |
;; Author: pogin | |
;; Maintainer: pogin | |
;; Keywords: convenience, frames | |
;; Created: 2011/07/04 | |
;; Version: 0.1.2 | |
;; URL: | |
;; Site: http://d.hatena.ne.jp/pogin/ | |
;;; License | |
;; | |
;; This file 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 2, or (at your option) | |
;; any later version. | |
;; This file 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 GNU Emacs; see the file COPYING. If not, write to the | |
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
;; Boston, MA 02110-1301, USA. | |
;;; Installation: | |
;; Put this file into load-path'ed directory, and byte compile it if | |
;; desired. And put the following expression into your ~/.emacs. | |
;; | |
;; (require 'omm-mode) | |
;; | |
;;; Commentary: | |
;; | |
;; Tested on Emacs 23. | |
;; | |
;;; Commands: | |
;; | |
;; `omm-mode-toggle' | |
;; toggle omm-mode on/off | |
;; | |
;; `omm-mode-style-on' | |
;; omm-mode-style on | |
;;; Keybinds | |
;; | |
;; C-c C-o: omm-mode-toggle | |
;;; Customizable Options: | |
;; | |
;; None | |
;; | |
;;; Change log: | |
;; Add function; omm-mode-linum-toggle 2011/09/05 | |
;; Add function: omm-mode-change-mode-line 2011/09/05 | |
;; Created: 2011/07/04 | |
;;; TODO | |
;; | |
;; play-music function | |
;; Change Background Picture function? | |
;; make Timer function | |
;; make defcustom etc | |
;;; Code | |
(defvar omm-mode-line-conf-list mode-line-format | |
"Save mode-line-format") | |
;;omm-mode-line-conf-list | |
(defvar omm-mode-toggle-var nil | |
"If omm-mode-toggle-var variable is nil, omm-mode is off. | |
If you eval omm-mode-toggle function, omm-mode is on. | |
If this variable is t, omm-mode is on. | |
If you eval omm-mode-toggle, omm-mode-toggle-var change nil") | |
(defconst omm-init-list-flag | |
(list | |
(eq linum-mode t) | |
(eq scroll-bar-mode t) | |
(eq tool-bar-mode t) | |
(eq menu-bar-mode t) | |
omm-mode-line-conf-list | |
(if (fboundp 'elscreen-mode) | |
(list t (eq elscreen-mode t)) | |
(list nil nil)) | |
(if (fboundp 'tabbar-mode) | |
(list t (eq tabbar-mode t)) | |
(list nil nil)) | |
)) | |
(defun omm-mode-change-mode-line (apply-state) | |
(save-excursion | |
(dolist (buf (buffer-list)) | |
(set-buffer buf) | |
(setq mode-line-format apply-state)))) | |
;;test code | |
;; (omm-mode-change-mode-line omm-mode-line-conf-list) | |
;; (omm-mode-change-mode-line nil) | |
(defun omm-mode-linum-toggle (num) | |
(save-excursion | |
(dolist (buf (buffer-list)) | |
(set-buffer buf) | |
(linum-mode num)) | |
(if (equal num -1) | |
(global-linum-mode -1) | |
(global-linum-mode 1)))) | |
;;test code | |
;; (omm-mode-linum-toggle -1) | |
;; (omm-mode-linum-toggle 1) | |
(defun omm-mode-style-on () | |
(interactive) | |
(progn | |
(omm-mode-linum-toggle -1) | |
(scroll-bar-mode -1) | |
(tool-bar-mode -1) | |
(menu-bar-mode -1) | |
(omm-mode-change-mode-line nil) | |
(setq mode-line-format nil) | |
(if (fboundp 'elscreen-mode) | |
(elscreen-mode -1)) | |
(if (fboundp 'tabbar-mode) | |
(tabbar-mode -1)) | |
(setq omm-mode-toggle-var t))) | |
(defun omm-mode-style-off () | |
(progn | |
(if (eq (nth 0 omm-init-list-flag) t) | |
(omm-mode-linum-toggle 1)) | |
(if (eq (nth 1 omm-init-list-flag) t) | |
(scroll-bar-mode 1)) | |
(if (eq (nth 2 omm-init-list-flag) t) | |
(tool-bar-mode 1)) | |
(if (eq (nth 3 omm-init-list-flag) t) | |
(menu-bar-mode 1)) | |
(omm-mode-change-mode-line omm-mode-line-conf-list) | |
(if (and (eq (first (nth 5 omm-init-list-flag)) t) | |
(eq (second (nth 5 omm-init-list-flag)) t)) | |
(elscreen-mode t)) | |
(if (and (eq (first (nth 6 omm-init-list-flag)) t) | |
(eq (second (nth 6 omm-init-list-flag)) t)) | |
(tabbar-mode t)) | |
(setq omm-mode-toggle-var nil))) | |
(defun omm-mode-toggle () | |
(interactive) | |
(if (eq omm-mode-toggle-var t) | |
(omm-mode-style-off) | |
(omm-mode-style-on))) | |
(defvar omm-mode-map nil) | |
(unless omm-mode-map | |
(let ((map (make-sparse-keymap))) | |
(define-key map "\C-c\C-o" 'omm-mode-toggle) | |
(setq omm-mode-map map))) | |
(define-minor-mode omm-mode | |
:keymap omm-mode-map | |
:group omm-mode) | |
(provide 'omm-mode) | |
;;; filename ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment