(if (not (fboundp 'define-minor-mode)) (defalias 'define-minor-mode 'easy-mmode-define-minor-mode))
(defun eegud-kill-buffer (&optional s)
(interactive)
(let ((buffer (current-buffer)))
(condition-case nil (delete-window (selected-window)) (error nil))
(kill-buffer buffer)))
(defun eegud-show-gud-buffer ()
(interactive)
(if (and (bufferp gud-comint-buffer)
(buffer-name gud-comint-buffer)
(not (eq (current-buffer) gud-comint-buffer)))
(progn
(delete-other-windows)
(split-window-vertically)
(switch-to-buffer gud-comint-buffer))))
(define-minor-mode eegud-keys-mode
"eegud keys mode"
nil
" eegudk"
'(("\M-s" . gud-step)
("\M-n" . gud-next)
("\M-c" . gud-cont)
("\M-f" . gud-finish)
("\M-k" . eegud-kill-buffer)))
(defun ee-gdb-start (dir &optional fname)
(if (= emacs-major-version 21)
(gdb (format "gdb %s%s" dir (or fname "")))
(gdb (format "gdb --annotate=3 %s%s" dir (or fname ""))))
(eegud-keys-mode))
(defun eeb-gdb-start (dir &optional fname)
(eegdb-bounded)
(ee-gdb-start dir fname))
(defun eeb-perldb-start (dir &optional fname)
(if do-eeg-bounded (eeg-bounded))
(perldb (format "perl %s%s" dir (or rest "")))
(eegud-keys-mode))
(code-c-d "phpdoc" "/usr/doc/phpdoc/html/")
(defun find-phpdocpage (page &rest rest)
(apply 'find-w3m (format "/usr/doc/phpdoc/html/%s.html" page) rest))
(defvar ee-file-php "/var/www/ee-tmp.php")
(defvar ee-url-php "http://127.0.0.1/ee-tmp.php")
(defun eephp (s &optional e)
(eev (format "wget -q -O - %s" ee-url-php))
(ee-write-with-nl s e "<?\n" "?>" ee-file-php))
(defun eephp+ (s &optional e)
(eev (format "w3m %s" ee-url-php))
(ee-write-with-nl s e "<?\n" "?>" ee-file-php))
(eeb-define 'eeb-php 'eephp 'ee-delimiter-hash nil t t)
(eeb-define 'eeb-php+ 'eephp+ 'ee-delimiter-hash nil t t)
(eeb-define 'eephp-bounded 'eephp 'ee-delimiter-hash nil t t)
(eeb-define 'eephp+-bounded 'eephp+ 'ee-delimiter-hash nil t t)
(defvar ee-file-lua "$EEVTMPDIR/ee.lua")
(defun eelua (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-lua)
(find-sh (format "lua50 %s" ee-file-lua)))
(defun eelua0 (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-lua)
(find-sh0 (format "lua50 %s" ee-file-lua)))
(eeb-define 'eeb-lua 'eelua "\n--*\n" nil t t)
(eeb-define 'eeb-lua0 'eelua0 "\n--*\n" nil t t)
(eeb-define 'eelua-bounded 'eelua "\n--*\n" nil t t)
(eeb-define 'eelua0-bounded 'eelua0 "\n--*\n" nil t t)
(defun eelua51 (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-lua)
(find-sh (format "lua51 %s" ee-file-lua)))
(eeb-define 'eelua51-bounded 'eelua51 "\n--*\n" nil t t)
(defvar ee-file-tcl "$EEVTMPDIR/ee.tcl")
(defun eetcl (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-tcl))
(eeb-define 'eeb-tcl 'eetcl "\n#*\n" nil t t)
(eeb-define 'eetcl-bounded 'eetcl "\n#*\n" nil t t)
(defun find-tcl (str &rest rest)
(eetcl str)
(apply 'find-sh (format "tclsh %s" ee-file-tcl) rest))
(defun find-tcl0 (str)
(eetcl str)
(find-sh0 (format "tclsh %s" ee-file-tcl)))
(defun find-expcommand (str &rest rest)
(interactive "sExpect command: ")
(apply 'find-man "1 expect" "\nCOMMANDS"
(format "\n %s" str) rest))
(defun ee-choosecolor (&optional initialcolor)
(eetcl (format "puts [tk_chooseColor -initialcolor %s]; exit"
(or initialcolor "gray")))
(find-sh0 (format "wish %s" ee-file-tcl)))
(setq ee-file-mp "$EEVTMPDIR/ee.mp")
(setq ee-script-mp "cd $EEVTMPDIR/ &&
mpost tmp.mp &&
awk '{if (NR==1) {print \"%!PS-Adobe-2.0 EPSF-1.2\"} else print}' \\
< tmp.0 > tmp.0.eps")
(defun eemp (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-mp)
(ee-write-with-nl ee-script-mp nil "" "" ee-file)
(format "eemp: wrote %s and %s" ee-file-mp ee-file))
(defun eemp-now (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-mp)
(find-sh ee-script-mp))
(eeb-define 'eeb-mp 'eemp 'ee-delimiter-percent nil t t)
(eeb-define 'eeb-mp-now 'eemp-now 'ee-delimiter-percent nil t t)
(eeb-define 'eemp-bounded 'eemp 'ee-delimiter-percent nil t t)
(eeb-define 'eemp-now-bounded 'eemp-now 'ee-delimiter-percent nil t t)
(setq ps-run-x '("gs" "-r36" "-sPAPERSIZE=a4"))
(defun eepsrun (s &optional e)
(interactive "r")
(require 'ps-mode)
(unless (equal major-mode 'ps-mode) (ps-mode))
(unless (equal (process-status "ps-run") 'run)
(let ((pop-up-windows t))
(ps-run-start)))
(ps-run-region s e))
(eeb-define 'eeb-psrun 'eepsrun 'ee-delimiter-percent nil t t)
(eeb-define 'eepsrun-bounded 'eepsrun 'ee-delimiter-percent nil t t)
(setq ee-file-icon "~/ICON/ee.icn")
(setq ee-script-icon "cd ~/ICON/ && icont -s tmp.icn -x")
(defun eeicon (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-icon)
(ee-write-with-nl ee-script-icon nil "" "" ee-file)
(format "eeicon: wrote %s and %s" ee-file-icon ee-file))
(defun eeicon-ow (s &optional e)
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-icon)
(find-progoutput-ow ee-script-icon))
(eeb-define 'eeb-icon 'eeicon 'ee-delimiter-hash nil t t)
(eeb-define 'eeb-icon-ow 'eeicon-ow 'ee-delimiter-hash nil t t)
(eeb-define 'eeicon-bounded 'eeicon 'ee-delimiter-hash nil t t)
(eeb-define 'eeicon-ow-bounded 'eeicon-ow 'ee-delimiter-hash nil t t)
(defun eelily (s &optional e)
(ee-write s e "
\\score {
\\notes {
" "
}
\\paper { }
\\midi { }
}" "$EEVTMPDIR/ee-ly.ly")
(eev "cd $EEVTMPDIR && lilypond ee-ly && rexdvi ee-ly.dvi &"))
(eeb-define 'eeb-lily 'eelily 'ee-delimiter-percent nil t t)
(eeb-define 'eelily-bounded 'eelily 'ee-delimiter-percent nil t t)
'
(eelily "\\key g \\major \\time 3/4
g,8^0()d b4 a8^0 b16()c' | b8()a g^4()fis g()d | e8()g c'()a^0 fis()b |
<g, d b>2\\trill <d a>4 | \\break
% 5
a,8()fis^3 c'4^2 b8 c'16()d' | c'8()b a^4()g fis^3()e |
fis8^1 g16()a g8()fis^1 e^1()fis | d4^0 a, d, \\bar \":|:\" |
d8()fis^3 a4^2 g8 a16()b | \\break
")
(defun ee-mgp-command-line (fname &optional page)
(format "cd %s && mgp -x vflib %s %s"
(file-name-directory (expand-file-name fname))
(if (and page (> page 0)) (format "-p %d" page) "")
(file-name-nondirectory fname)))
(defun find-mgp (fname &optional page now)
(interactive "fMagicPoint file: ")
(if now (shell-command-to-string (ee-mgp-command-line fname page))
(eev (ee-mgp-command-line fname page))))
(defun find-mgpnow (fname &optional page)
(interactive "fMagicPoint file: ")
(shell-command-to-string (ee-mgp-command-line fname page)))
(defun eemgp-file-now (&optional page)
(interactive "P") (find-mgpnow (buffer-file-name) page))
(defun ee-count-occurrences (str s e &optional show-it)
(interactive "MString: \nr\np")
(ee-maybe-showing-it
(save-excursion
(let ((count 0) (s (min s e)) (e (max s e)))
(goto-char s)
(while (search-forward str e t)
(setq count (1+ count)))
count))))
(defun eemgp-this-page-number ()
(ee-count-occurrences "\n%page" (point-min) (point)))
(defun eemgp-show (&optional show-it)
(interactive "p")
(save-buffer)
(ee-maybe-showing-it
(eemgp-file-now (eemgp-this-page-number))))
(defvar ee-file-fvwm "~/.fvwm/ee.fvwm"
"See `eefvwm0'.")
(defun eefvwm (s &optional e)
"Write the region between S and E into the temporary Fvwm script file.
See `ee-se-to-string' for the exact definition of \"region\" - if S
is a string instead of a number the use S as the \"region\".
The name of the temporary script file is taken from the variable
`ee-file-fvwm'.
See `eefvwm0'."
(interactive "r")
(ee-write-with-nl s e "" "" ee-file-fvwm)
(format "eefvwm: wrote %s" ee-file-fvwm))
(defun eefvwm0 (s &optional e)
"Execute the commands in the region between S and E as a Fvwm script.
This function calls `eefvwm' to save the \"region\" given by the
pair (S E) into a temporary script file, and then runs
\"FvwmCommand ee\" to make Fvwm execute the script. This only
works if the current window manager is Fvwm, and if it has been
prepared to react to commands sent by \"FvwmCommand\", and if it
interprets \"ee\" as \"read ee.fvwm\". The code that should be
added to the fvwm init file (usually ~/.fvwm/.fvwm2rc) to do all
that is:\n
# See: (find-man \"FvwmCommand\")
# A test: (find-sh0 \"FvwmCommand 'CursorMove +5 +2'\")
AddToFunc StartFunction \"I\" Module FvwmCommandS\n
# Test: (eefvwm0 \"CursorMove +5 +2\")
DestroyFunc ee
AddToFunc ee \"I\" read ee.fvwm"
(interactive "r")
(eefvwm s e)
(find-sh0 "FvwmCommand ee"))
(eeb-define 'eeb-fvwm 'eefvwm 'ee-delimiter-hash nil t t)
(eeb-define 'eeb-fvwm0 'eefvwm0 'ee-delimiter-hash nil t t)
(eeb-define 'eefvwm-bounded 'eefvwm 'ee-delimiter-hash nil t t)
(eeb-define 'eefvwm0-bounded 'eefvwm0 'ee-delimiter-hash nil t t)
(defun find-fvwm0 (str)
(eefvwm str)
(find-sh0 "FvwmCommand ee"))
(defvar ee-fvwmhelp-prefix "\n ")
(defun find-fvwmhelp (&optional str &rest pos-spec-list)
(interactive
(let ((word (read-string "Fvwm command: " (word-at-point))))
(list (if (equal word "") nil word))))
(if str (apply 'find-man "1 fvwm" (concat ee-fvwmhelp-prefix str)
pos-spec-list)
(find-man "1 fvwm")))
(defun eehtml (s &optional e)
(interactive "r")
(ee-write s e
(format "<html>\n<head>\n<title>%s</title>\n</head>\n<body>\n"
ee-file-html)
"\n</body>\n</html>\n"
ee-file-html)
ee-file-html)
(defun eeurl (url)
(interactive (list (car (browse-url-interactive-arg "eeurl "))))
(eehtml (format "<a href=\"%s\">\n%s\n</a>" url url)))
(eeb-define 'eeb-html 'eehtml 'ee-delimiter-hash nil t t)
(eeb-define 'eehtml-bounded 'eehtml 'ee-delimiter-hash nil t t)
(defun ee-send-to-erc-channel (channel line)
(if (not (get-buffer channel))
(error "There's no buffer called \"%s\"" channel))
(if (not (eq 'erc-mode (with-current-buffer channel major-mode)))
(error "The buffer \"%s\" is not an ERC buffer"))
(switch-to-buffer channel)
(goto-char (point-max))
(insert line)
(erc-send-current-line))
(defun find-fsbot-answer (question)
"Ask a question to fsbot, a knowledgebot at the #emacs channel of Freenode"
(interactive "sQuestion: ")
(ee-send-to-erc-channel "fsbot" question))
(defun eeimage-data (fname)
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally fname)
(buffer-string)))
(defun eeimage-set (s e fname)
(add-text-properties s e
`(display (image :type ,(image-type-from-file-header fname)
:data ,(eeimage-data fname)))))
(defun find-eimage0 (fname &optional nlines nchars &rest ignored)
"Display the image given by FNAME in place of the text between point and bol.
This function is meant to be used with \\[eek-eval-sexp-eol], so
by default it will change the appearance of the entire current
line. If NLINES is non-nil then work on that number of lines
instead - e.g., 5 means change this line and the four previous
ones. A non-nil value of NCHARS means to use bol+NCHARS instead
of bol."
(eeimage-set (point)
(+ (or nchars 0) (point-at-bol (- 2 (or nlines 1))))
(ee-expand fname)))
(defun find-inkscape (fname)
(interactive "FSVG file name: ")
(eev (format "cd %s && inkscape %s &"
(file-name-directory (expand-file-name fname))
(file-name-nondirectory fname))))
(defun ee-swf-html-embed (url width height)
(format "<embed src=\"%s\"
width=\"%d\" height=\"%d\" type=\"application/x-shockwave-flash\">"
url width height))
(defun ee-swf-html-full (url width height)
(format "<html><head>
<title>%s</title></html></head>
<body>
%s
</body>
</html>
" url (ee-anim-html-embed url width height)))
(code-c-d "eevanim" "$EEVDIR/anim/")
(defun find-eevanim (fname width height)
(let ((url (ee-eevanimfile fname)))
(write-region (ee-swf-html-full url width height) nil "/tmp/ee.html")
(find-sh0 "firefox /tmp/ee.html")))
(provide 'eev-langs)