root/lang/elisp/hamazou-mode/hamazou-mode.el @ 1984

Revision 1984, 3.0 kB (checked in by iwaim, 6 years ago)

lang/elisp/hamazou-mode: fix indent using space character

Line 
1;;; -*- coding: utf-8; mode: emacs-lisp; indent-tabs-mode: nil -*-
2;;; hamazou-mode.el --- Emacs minor mode for hamazou script
3
4;; Copyright (C) 2007 IWAI, Masaharu
5;; Author: IWAI, Masaharu <iwaim.sub@gmail.com>
6;; Keywords: blog, hatena, はてな
7
8;; This file is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published
10;; by the Free Software Foundation; either version 2, or (at your
11;; option) any later version.
12
13;; This file is distributed in the hope that it will be useful, but
14;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16;; General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs; see the file COPYING.  If not, write to the
20;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21;; Boston, MA 02111-1307, USA.
22
23;; hamazou script
24;;   <http://d.hatena.ne.jp/syou6162/20071118/1195353605>
25
26(defconst hamazou-mode-version "0.0.1"
27  "Version number of hamazou-mode")
28
29(defvar hamazou-mode nil)
30
31;;; mode-line
32(if (not (assq 'hamazou-mode minor-mode-alist))
33    (setq minor-mode-alist
34          (cons '(hamazou-mode " hamazou")
35                minor-mode-alist)))
36
37(defun hamazou-mode (&optional arg)
38  "hamazou minor-mode"
39  (interactive)
40  ;; mode variable settings
41  (cond
42   ((< (prefix-numeric-value arg) 0)
43    (setq hamazou-mode nil))
44   (arg
45    (setq hamazou-mode t))
46   (t
47    (setq hamazou-mode (not hamazou-mode))))
48
49  (if hamazou-mode
50      (progn
51        (setq hamazou-mode-map (make-keymap)))
52    nil))
53
54;; variable
55(defvar hamazou-bin "hamazou"
56  "*set hamazou script path")
57
58(defvar hamazou-process-buffer-name "*Hamazou*"
59  "*hamazou script process buffer name")
60
61;; function
62(defun hamazou ()
63  (interactive)
64  (let
65      ((search-word (read-string "hamazou search: ")))
66    (hamazou-execute search-word)))
67
68;; internal function
69(defun hamazou-execute (search-word)
70  (let*
71      ((buffer (get-buffer-create hamazou-process-buffer-name))
72       (proc (get-buffer-process buffer)))
73    (if (and
74         proc
75         (eq (process-status proc) 'run))
76        (if (yes-or-no-p (format "A %s process is running; kill it?"
77                                 (process-name proc)))
78            (progn
79              (interrupt-process proc)
80              (sit-for 1)
81              (delete-process proc))
82          (error nil)))
83    (with-current-buffer buffer
84      (progn
85        (erase-buffer)
86        (buffer-disable-undo (current-buffer)))
87      (make-comint-in-buffer
88       "hamazou search" buffer shell-file-name nil
89       shell-command-switch (hamazou-build-command search-word)))
90    (hamazou-split-window)))
91
92(defun hamazou-build-command (search-word)
93  (format "%s %s" hamazou-bin search-word))
94
95(defun hamazou-split-window ()
96  (if
97      (get-buffer-window hamazou-process-buffer-name)
98      nil
99    (and (split-window-vertically)
100         (set-window-buffer (next-window) hamazou-process-buffer-name))))
101
102(provide 'hamazou-mode)
Note: See TracBrowser for help on using the browser.