Gnuplot Mode

キーバインド

C-c C-l		現在の行をgnuplotに送る
C-c C-v		現在の行をgnuolotに送って1行下へ移動
C-c C-r		現在の領域をgnuplotに送る
C-c C-b		バッファ全体をgnuplotに送る
C-c C-f		ファイルをgnuplotに送る
C-c C-i		現在の位置にファイル名を挿入
C-c C-n		現在の行のオプションを反転
C-c C-c		領域をコメントアウト
C-c C-o		現在の位置にコマンドの引数を設定
S-mouse-2		マウスポインタの位置にコマンドの引数を設定
C-c C-h		gnuplot infoファイルを読む
C-c C-e		show-gnuplot-buffer
C-c C-k		gnuplotプロセスをkillする
C-c C-u		gnuplot-modeについてのバグレポートを送る
M-tab or M-ret	その場所の前にあるキーワードを補完
ret		改行してインデント
tab		現在の行をインデント

gnuplot-modeは以下の2つのキーバインドをcomint(通信)バッファに追加します:
M-C-p		1行ごとに現在のスクリプトバッファを描画
M-C-f		現在のスクリプトバッファを保存して再度読み込む

導入

  1. ここからこれをとってきます. 現時点で0.6.0です.
  2. Win9x/pgnuplot.cに修正を2箇所
  3. cygwinなgccでコンパイル
    gcc -o pgnuplot pgnuplot.c -luser32 -s
    
  4. pgnuplot.exeを/usr/local/bin/へ, *.elを /usr/local/site-lisp/gnuplot/へコピー
  5. ここのような設定を.emacsに追加.

使いかた

gnuplot-modeを始めるには以下の2つの関数を利用します:

M-x gnuplot-mode
現在のバッファでgnuplot-modeを始めます.
M-x gnuplot-make-buffer
(ファイルを作るのではなく)新しいバッファを 作って, そのバッファでgnuplot-modeを始めます.

先程のキーバインドで, F9がgnuplot-make-bufferに割当てられているので, F9を押すと, 新しいバッファができます. そこで例えば

plot x
とタイプしてC-c C-lすると, y=xがプロットされます. あとはgpelcardを参照 しましょう:

参考

gnuplot.elのCommentaryの抄訳

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Commentary:
;;
;; This is a major mode for composing gnuplot scripts and displaying
;; their results using gnuplot.  It is optimized for use with gnuplot
;; 3.7 or one of the later patchlevels of "version 3.6".  It should
;; also work very handily with version 3.5.  This mode offers several
;; tools to help you compose your scripts, including syntax
;; colorization using either font-lock or hilit19, a syntax table
;; appropriate to gnuplot, key bindings, pull-down menus, indentation,
;; keyword completions and variable customization using the Custom
;; package.  Once the script is composed, there are several function
;; for sending some or all of the script to gnuplot.  The interaction
;; with the gnuplot process is within a comint buffer.
;;
;;    C-c C-l       send current line to gnuplot
;;    C-c C-v       send current line to gnuplot and move forward 1 line
;;    C-c C-r       send current region to gnuplot
;;    C-c C-b       send entire buffer to gnuplot
;;    C-c C-f       send a file to gnuplot
;;    C-c C-i       insert filename at point
;;    C-c C-n       negate set option on current line
;;    C-c C-c       comment region
;;    C-c C-o       set arguments for command at point
;;   S-mouse-2      set arguments for command under mouse cursor
;;    C-c C-h       read the gnuplot info file
;;    C-c C-e       show-gnuplot-buffer
;;    C-c C-k       kill gnuplot process
;;    C-c C-u       submit a bug report about gnuplot-mode
;; M-tab or M-ret   complete keyword before point
;;      ret         newline and indent
;;      tab         indent current line
;;
;; Gnuplot-mode adds two key bindings to the comint buffer:
;;     M-C-p        plot the current script buffer line-by-line
;;     M-C-f        save the current script buffer and load that file
;;
;; These two functions are useful for starting up gnuplot-mode.
;;
;; M-x gnuplot-mode
;;         start gnuplot-mode in the current buffer
;;
;; M-x gnuplot-make-buffer
;;         open a new buffer (which is not visiting a file) and start
;;         gnuplot-mode in that buffer
;;
;; ---------------------------------------------------------------------
;;
;; Other lisp files used by gnuplot.el
;;
;; info-look.el (comes with GNU Emacs 20):
;;   This provides the interface to the gnuplot-info file and provides
;;   on-line help and keyword completion functionality.  The version
;;   of info-look.el that comes with version 20.2 of Emacs contains a
;;   bug that will impede its interaction with the gnuplot info file.
;;   You should use the version from the gnuplot-mode homepage
;;   instead.  info-look is not distributed with XEmacs and so should
;;   be installed along with gnuplot-mode when using XEmacs.
;;
;; gnuplot-gui.el (written by Bruce):
;;   Defines the GUI interface for setting setting arguments to
;;   gnuplot options.  This uses the widget package extensively.
;;
;; ---------------------------------------------------------------------
;;
;; This mode was inspired by the original gnu-plot-mode by Gershon
;; Elber, which is distributed with gnuplot itself and which dates
;; back to the early 90's.  Although this mode encompasses the
;; functionality of the original, the two share no code and the
;; current implementation takes advantage of many features of modern
;; versions of emacs and adheres (or so I intend) to the major mode
;; conventions described in the emacs-lisp reference for version 19
;; and later.
;;
;; ---------------------------------------------------------------------
;;
;;                         Installation
;;                         ============
;;
;; A recent version of this file can be found at
;;   http://feff.phys.washington.edu/~ravel/software/gnuplot-mode/
;;
;; To autoload gnuplot-mode on any file with gp extension, put this in
;; your .emacs file
;;   (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
;;   (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)
;;
;; Something like
;;   (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode))
;;			           auto-mode-alist))
;; is useful for having files ending in .gp start up in gnuplot-mode.
;;
;; Something like
;;   (global-set-key [(f9)] 'gnuplot-make-buffer)
;; may be useful.  This binds f9 to the function that opens a scratch
;; buffer (i.e. one that is not visiting a file) in gnuplot-mode.
;; This is handy for your quick 'n' dirty plotting chores.
;;
;; To use the `gnuplot-info-lookup-symbol' function, the file
;; gnuplot.info MUST be installed somewhere that info can find it.
;; This means you must either:
;;   1.  Copy gnuplot.info to the normal info directory or
;;   2.  Make sure info can find gnuplot.info by putting this in your
;;       .emacs file:
;;         (setenv "INFOPATH"
;;	      (concat (getenv "INFOPATH") ":"
;;                    (expand-file-name "/path/to/file")))
;;       where "/path/to/file" is the location of gnuplot.info
;;
;; This had been tested extensively with Emacs 19.34 and 20.2 and
;; XEmacs 20.3 and in a limited manner with Emacs 19.30 and XEmacs
;; 19.14.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

INSTALLの抄訳

	
To install gnuplot-mode:
	
1. At the command line:

      > configure
      > make

   If you use XEmacs, do "make EMACS=xemacs" (or change the EMACS
   variable to "xemacs" in the Makefile, the run "make").

   If "configure" doesn't work for you, the file "Makefile.dst" can be
   used.  In that case do, "make -f Makefile.dst".

2. Move the .elc files to a place where emacs can find them, for
   example /usr/share/emacs/site-lisp or your personal emacs
   directory.

3. Insert the contents of the `dotemacs' file into your .emacs file
   or system start-up file to enable gnuplot mode.

4. The function `gnuplot-info-lookup-symbol' looks at the Gnuplot
   info file that comes with this package or that can be made from
   the Gnuplot distribution.  For that function to work, the file
   gnuplot.info must be placed somewhere where info can find it, for
   example /usr/info.  A line like this in your .emacs allows you to
   put gnuplot.info any place convenient:
     (add-to-list 'Info-default-directory-list "/path/to/file")



The "configure; make" sequence may not work on all systems,
particularly Win32 systems.  The long-winded way of making the .elc
gpelcard.ps files is to edit each of the .el files with emacs and do
`M-x byte-compile-file'.  Then "latex gpelcard.tex" and
"dvips gpelcard.dvi".

You will need to follow the instructions contained in the file
Win9x/INSTALL.Win9x to get gnuplot working with Emacs on a Windows 95
or 98 machine.