Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; This file: ;; http://angg.twu.net/dednat5/dednat-eev.el.html ;; http://angg.twu.net/dednat5/dednat-eev.el ;; (find-dn5 "dednat-eev.el") ;; ;; Author: Eduardo Ochs <eduardoochs@gmail.com> ;; Version: 2011apr24 ;; License: GPL3 ;; ;; This is a reduced, single-file version of eev, made to be used in ;; conjunction with dednat5 by people who feel that the full version ;; of eev may be too complex. ;; This is not ready yet!!! It is _INCOMPLETE_ and _UNTESTED_!!! ;; ;; By loading this file you will get the following side-effects: ;; (1) a minor mode called `eev-mini' will be defined and turned on; ;; while that mode is active the eev-keymap will be active and ;; `pop-up-windows' will be nil; ;; (2) three "glyphs" will be defined in the standard-display-table: ;; `*', `«', and `»'; ;; (3) several functions and variables will be defined. All of them ;; have names that start with either `ee-' or `find-', except ;; for one: `to'. ;; UPDATE, 2011nov16: DON'T TRY TO USE THIS! ;; This is abandoned code! The basic way of interacting with dednat ;; from within Emacs without loading a lot of cruft will be ;; restructured around this: ;; http://angg.twu.net/eev-current/eepitch.el.html ;; (find-eev "eev.el" "find-eev-mode-links") ;; ;; (find-eev "eev-mini.el") ;; (find-efunction 'figlet) ;; Quick index: ;; «.glyphs» (to "glyphs") ;; «.compose» (to "compose") ;; «.eepitch» (to "eepitch") ;; «.wrap» (to "wrap") ;; «.ee-goto-position» (to "ee-goto-position") ;; «.find-sh» (to "find-sh") ;; «.find-xpdf» (to "find-xpdf") ;; «.keymap» (to "keymap") ;; «.eev-mini-mode» (to "eev-mini-mode") ;;; _ _ ;;; __ _| |_ _ _ __ | |__ ___ ;;; / _` | | | | | '_ \| '_ \/ __| ;;; | (_| | | |_| | |_) | | | \__ \ ;;; \__, |_|\__, | .__/|_| |_|___/ ;;; |___/ |___/|_| ;; ;; «glyphs» (to ".glyphs") ;; See: (find-TH "eev-article" "glyphs") ;; (find-eev "eev-glyphs.el" "eev-set-glyph") ;; (find-eev "eev-mini.el" "eev-set-glyph") (defface eev-glyph-face-red '((t (:foreground "red"))) "Face used for the red star glyph (char 15).") (defface eev-glyph-face-green '((t (:foreground "green"))) "Face used for the '<<' and '>>' glyphs (char 171 and 187).") (defun ee-glyph (char &optional face) (if (stringp char) (setq char (string-to-char char))) (make-glyph-code char face)) (defun eev-set-glyph (pos &optional char face) (aset standard-display-table pos (if char (vector (ee-glyph char face))))) ;; Make `^O's appear at red stars, and '«' and '»' be green. ;; Note that the chars 171 and 187 are only '«' and '»' in ;; "raw-text" (a.k.a. "unibyte") buffers. (eev-set-glyph ?\^O ?* 'eev-glyph-face-red) (eev-set-glyph 171 171 'eev-glyph-face-green) (eev-set-glyph 187 187 'eev-glyph-face-green) ;; To cancel that run this: ;; (eev-set-glyph ?\^O) ;; (eev-set-glyph 171) ;; (eev-set-glyph 187) ;;; ;;; ___ ___ _ __ ___ _ __ ___ ___ ___ ;;; / __/ _ \| '_ ` _ \| '_ \ / _ \/ __|/ _ \ ;;; | (_| (_) | | | | | | |_) | (_) \__ \ __/ ;;; \___\___/|_| |_| |_| .__/ \___/|___/\___| ;;; |_| ;; ;; «compose» (to ".compose") ;; A practical way to type '«' and '»': `M-, < <' and `M-, > >'. ;; See: (find-TH "eev-article" "compose-pairs") ;; (find-eev "eev-compose.el") ;; (defvar eev-composes-all '("<<" 171 ">>" 187)) (defun eev-compose-pair (pair) (let ((sublist (member pair eev-composes-all))) (if sublist (insert (nth 1 sublist)) (error "Pair \"%s\" not in `eev-composes-all'" pair)))) (defun eev-compose-two-keys () (interactive) (eev-compose-pair (format "%c%c" (read-event "Compose key 1: " t) (read-event "Compose key 2: " t)))) ;;; _ _ _ ;;; ___ ___ _ __ (_) |_ ___| |__ ;;; / _ \/ _ \ '_ \| | __/ __| '_ \ ;;; | __/ __/ |_) | | || (__| | | | ;;; \___|\___| .__/|_|\__\___|_| |_| ;;; |_| ;; ;; «eepitch» (to ".eepitch") ;; (find-eev "eev-compose.el") ;; (find-eev "eev-mini.el" "eev-set-glyph") ;; (find-eev "eev-mini-steps.el" "eev-set-glyph") ;; See: (find-eev "eev-mini-steps.el" "eepitch-prepare-target-buffer") ;; A really minimal version: (find-TH "comint") (defvar eepitch-code '(error "eepitch not set up")) (defvar eepitch-target-buffer nil) (defun eepitch-prepare-target-buffer () "Run `eepitch-code' and store the name of the resulting buffer in `eepitch-target-buffer'." (save-window-excursion (eval eepitch-code) (setq eepitch-target-buffer (current-buffer)))) (defun eepitch-display-target-buffer () "Display the buffer `eepitch-target-buffer' in another window." (if (not (get-buffer-window eepitch-target-buffer)) (let ((pop-up-windows t) (same-window-buffer-names nil)) (display-buffer eepitch-target-buffer)))) (defun eepitch (code) "Set the target buffer for pitching lines to; CODE is something like `(shell)'." (setq eepitch-code code) (eepitch-prepare-target-buffer) (eepitch-display-target-buffer)) (defun eepitch-line (line) (save-selected-window (select-window (get-buffer-window eepitch-target-buffer)) (insert line) ; "type" the line (call-interactively (key-binding "\r")))) ; then do a RET (defun eepitch-not-this-buffer () (if (eq (current-buffer) eepitch-target-buffer) (error "Can't pitch to the current buffer"))) (defun eepitch-this-line () "Pitch this line to the target buffer, or eval it as lisp if it starts with `*'. See `eepitch' and the source code." (interactive) (let ((line (buffer-substring (ee-bol) (ee-eol)))) ; contents of this line (if (string-match "^*\\(.*\\)" line) ; lines with a red star (ee-eval-string (match-string 1 line)) ; are eval'ed - (eepitch-prepare-target-buffer) ; for other lines reconstruct the (eepitch-display-target-buffer) ; target buffer, display it, make (eepitch-not-this-buffer) ; sure it's a different buffer, and (eepitch-line line))) ; pitch the line to the target. (ee-next-line 1)) (defun eepitch-kill () "Kill the `eepitch-target-buffer'. See `eepitch' and the source code." (interactive) (eepitch-prepare-target-buffer) ; Prepare (maybe reconstruct) the (eepitch-display-target-buffer) ; target buffer, display it, make (eepitch-not-this-buffer) ; sure it's a different buffer... (save-selected-window ; Then temporarily switch to the (select-window (get-buffer-window eepitch-target-buffer)) ; right window, (ee-kill-this-buffer))) ; and kill the buffer that is there. ;; convenience (defun eepitch-comint (name program-and-args) "Set `eepitch' to run PROGRAM-AND-ARGS in comint mode, in the buffer \"*NAME*\"." (eepitch `(find-comintprocess ,name ',program-and-args))) (defun eepitch-shell () "Same as (eepitch '(shell)). See `eepitch' and `ee-wrap-eepitch'." (interactive) (eepitch '(shell))) (defun eepitch-shell2 () (interactive) (eepitch '(shell "*shell 2*"))) (defun eepitch-eshell () (interactive) (eepitch '(eshell))) (defun eepitch-lua51 () (interactive) (eepitch-comint "lua51" "lua51")) ;;; ;;; __ ___ __ __ _ _ __ ;;; \ \ /\ / / '__/ _` | '_ \ ;;; \ V V /| | | (_| | |_) | ;;; \_/\_/ |_| \__,_| .__/ ;;; |_| ;; ;; «wrap» (to ".wrap") ;; (find-eev "eev-insert.el" "ee-delete-extract-wrap") ;; (find-efunction 'ee-delete-and-extract-line) ;;; _ ;;; ___ ___ __ _ ___ | |_ ___ _ __ ___ ___ ;;; / _ \/ _ \_____ / _` |/ _ \| __/ _ \ _____| '_ \ / _ \/ __| ;;; | __/ __/_____| (_| | (_) | || (_) |_____| |_) | (_) \__ \ ;;; \___|\___| \__, |\___/ \__\___/ | .__/ \___/|___/ ;;; |___/ |_| ;; ;; «ee-goto-position» (to ".ee-goto-position") ;; (find-eev "eev-mini.el" "ee-goto-position") ;; (find-eev "eev.el" "ee-goto-position") ;;; __ _ _ _ ;;; / _(_)_ __ __| | ___| |__ ;;; | |_| | '_ \ / _` |_____/ __| '_ \ ;;; | _| | | | | (_| |_____\__ \ | | | ;;; |_| |_|_| |_|\__,_| |___/_| |_| ;;; ;; «find-sh» (to ".find-sh") ;; (find-eev "eev-mini.el" "find-eoutput-rerun") ;; (find-eev "eev-mini.el" "find-sh") (defun find-eoutput-rerun (buffer-name code &rest pos-spec-list) (if (get-buffer buffer-name) ; if the buffer exists (if (not (kill-buffer buffer-name)) ; try to kill it; confirm if needed (error "Not killing the buffer %s" buffer-name))) (switch-to-buffer buffer-name) ; create the buffer (eval code) ; always run CODE on the empty buffer (goto-char (point-min)) (apply 'ee-goto-position pos-spec-list)) (defun find-eoutput-reuse (buffer-name code &rest pos-spec-list) (if (get-buffer buffer-name) ; if the buffer exists (switch-to-buffer buffer-name) ; then just switch to it (switch-to-buffer buffer-name) ; otherwise switch to it and (eval code) ; run CODE to produce its contents (goto-char (point-min))) (apply 'ee-goto-position pos-spec-list)) (defun find-sh (command &rest pos-spec-list) (apply 'find-eoutput-reuse (ee-no-trailing-nl command) `(insert (shell-command-to-string ,command)) pos-spec-list)) (defun find-sh00 (command) (shell-command-to-string command)) (defun find-sh0 (command) (ee-no-trailing-nl (find-sh00 command))) ;;; __ _ _ _ __ ;;; / _(_)_ __ __| | __ ___ __ __| |/ _| ;;; | |_| | '_ \ / _` |____\ \/ / '_ \ / _` | |_ ;;; | _| | | | | (_| |_____> <| |_) | (_| | _| ;;; |_| |_|_| |_|\__,_| /_/\_\ .__/ \__,_|_| ;;; |_| ;; ;; «find-xpdf» (to ".find-xpdf") ;; (find-eev "eev-mini.el" "find-bgprocess-ne") ;;; _ ;;; | | _____ _ _ _ __ ___ __ _ _ __ ;;; | |/ / _ \ | | | '_ ` _ \ / _` | '_ \ ;;; | < __/ |_| | | | | | | (_| | |_) | ;;; |_|\_\___|\__, |_| |_| |_|\__,_| .__/ ;;; |___/ |_| ;; ;; «keymap» (to ".keymap") ;; (find-eev "eev.el" "find-eev-mode-links" "eev-mode-map") ;; (find-eev "eev-mini.el" "find-eev-mode-links" "eev-mode-map") ;; F8 M-e M-k M-K M-, ;; M-T M-S ;;; _ ;;; _ __ ___ ___ __| | ___ ;;; | '_ ` _ \ / _ \ / _` |/ _ \ ;;; | | | | | | (_) | (_| | __/ ;;; |_| |_| |_|\___/ \__,_|\___| ;;; ;; «eev-mini-mode» (to ".eev-mini-mode") ;; (find-eev "eev.el" "find-eev-mode-links") ;; to ;; diagskel ;; dednames ;; Local Variables: ;; coding: raw-text-unix ;; ee-anchor-format: "«%s»" ;; no-byte-compile: t ;; End: