diff --git a/.emacs b/.emacs new file mode 100644 index 0000000..2a85ea8 --- /dev/null +++ b/.emacs @@ -0,0 +1,650 @@ +;; Setup some handy functions + +;; for multiple shells +(defun unique-shell () + (interactive) + (shell) + (rename-uniquely) + ) + +;; for tab complete in C/C++ code +;(add-hook 'c-mode-common-hook (function (lambda () (local-set-key (kbd "") 'indent-or-complete) ))) + + +;; Handle OS-specific settings +(if (eq system-type 'windows-nt) + (list ; WINDOWS settings + ;; add my Windows elisp area + (add-to-list 'load-path "c:/data/rcfiles-hg/elisp") + + ;; Cygwin shell + (setq explicit-shell-file-name "C:/cygwin/bin/bash.exe") + + ;; For subprocesses invoked via the shell (e.g., "shell -c command") + (setq shell-file-name "C:/cygwin/bin/bash.exe") + (setenv "PATH" (concat (getenv "PATH") + ";C:/cygwin/bin" + ";C:/cygwin/usr/bin" + ";C:/cygwin/usr/local/bin")) + ; may want to use cygstart instead? + + ; kill shell-quote-argument: we need a Cygwin-specific version that does + ; not quote the ':' in "c:/data/..." + (defalias 'shell-quote-argument (lambda (a) a)) + + (defun my-shell-setup () + "For Cygwin bash under Emacs 20" + (setq comint-scroll-show-maximum-output 'this) + (setq comint-completion-addsuffix t) + ;; (setq comint-process-echoes t) ;; reported that this is no longer needed + (setq comint-eol-on-send t) + (setq w32-quote-process-args ?\") + (make-variable-buffer-local 'comint-completion-addsuffix)) + + (setq shell-mode-hook 'my-shell-setup) + + ; include Cygwin executables in Emacs' repertoire, and turn off 'diff' DOS file warnings + (add-to-list 'exec-path "c:/cygwin/bin") + (setenv "nodosfilewarning" "1") + + ; setup AUCTeX to use gsview to show typeset results + (eval-after-load "tex" + '(progn + (push (list 'output-pdf "gsview") TeX-view-program-selection) + (push (list "gsview" "gsview32 %o") TeX-view-program-list))) + ) + (list ; *NIX settings + ;; add my *NIX elisp area + (add-to-list 'load-path "~/rcfiles-hg/elisp") + )) + + +;; Set some default variables for all buffers +;(load-library "other-functions") + +;; Set some default variables for all buffers +(setq auto-save-interval 100000) +(setq c-default-mode 'c-mode) + +(setq ada-default-mode 'ada-mode) +(setq default-fill-column 70) +(setq search-exit-char ?\^L) + +(setq require-final-newline t) +(setq inhibit-startup-message t) +(setq-default wrap-lines t) ;; don't truncate lines, wrap them +;(setq default-truncate-lines t) +(setq-default indent-tabs-mode nil) ;; always use spaces instead of tabs +(setq-default lpr-command "lp") ;; Set default printer stuff +(setq-default print-buffer "lp") ;; Set default printer stuff +(setq-default print-region "lp") ;; Set default printer stuff +(setq-default lpr-switches '("-dsla7")) ;; Set default printer stuff +(setq-default lpr-header-switches '("")) ;; Set default printer stuff +;(put 'eval-expression 'disabled nil) ;; enable the ESC-ESC command +;(setq dired-listing-switches "-alFL") ;; switches to pass to ls from dired +(setq next-line-add-newlines nil) ;; Don't extend file if cursor moves off bottom +(setq next-screen-context-lines 5) ;; number of lines of the previous screen to show on this +(setq compilation-window-height 5) ;; set the size of the compilation window to 5 lines +(setq scroll-step 5) ;; number of lines to scroll screen +(setq require-final-newline t) ;; make sure that all files end with a newline +(setq line-number-mode t) +(setq column-number-mode t) +(transient-mark-mode nil) +(setq ring-bell-function 'ignore) ; turn off the annoying bell sound! + +(setq lisp-mode-hook 'emacs-lisp-mode-setup) +(local-set-key "" (quote newline-and-indent)) + +(global-set-key "\C-x\C-o" 'find-file-at-point) +;(global-set-key "\C-x4\C-g" 'find-file-at-point-other-window) +(global-set-key "\C-xk" 'kill-current-buffer) +(global-set-key "\C-x\C-k" 'bury-buffer) +(global-set-key "\C-x\M-b" 'rename-buffer) +(global-set-key "\C-xy" 'yank-rectangle) +(global-set-key "\C-xw" 'kill-rectangle) +(global-set-key "\C-xg" 'goto-line) +(global-set-key "\C-x!" 'highlight-region) +(global-set-key "\C-x\C-x" 'exchange-point-and-mark-mk) +(global-set-key "\C-z" 'unique-shell) +(global-set-key "\C-x@" 'unhighlight-region) +(global-set-key "\C-xrw" 'copy-to-register) +(global-set-key "\C-xry" 'insert-register) +(global-set-key (quote [27 f2]) 'name-last-kbd-macro) +(global-set-key (quote [f2]) 'call-last-kbd-macro) +(global-set-key (quote [f3]) 'isearch-repeat-forward) +(global-set-key (quote [f4]) 'f4) +(global-set-key (quote [f5]) 'revert-buffer) +(global-set-key (quote [f6]) 'copy-to-register-1) +(global-set-key (quote [f7]) 'yank-from-register-1) +(global-set-key (quote [f8]) 'toggle-truncate-lines) +(global-set-key (quote [f9]) 'call-last-kbd-macro) +(global-set-key (quote [f10]) 'f10) +(global-set-key (quote [f11]) 'sage-send-doctest-line-and-forward) +(global-set-key (quote [f12]) 'sage-send-region) +(global-set-key (quote [delete]) 'delete-char) +;(global-set-key (quote [delete]) (quote backward-delete-char-untabify)) +;(global-set-key (quote [backspace]) 'backward-delete-char) +(global-set-key "\C-x\C-l" 'font-lock-fontify-buffer) +(global-set-key "\C-x\C-v" (require 'vhdl-mode)) +(global-set-key "\C-c\C-r" 'vhdl-comment-uncomment-region) +(global-set-key (quote [(meta backspace)]) 'backward-kill-word) +;(global-set-key "\C-c]" 'reftex-citation);RWH:: overridden by LaTeX mode + +(load-library "dired") +(load-library "man") + +(defun text-mode-tabs () + (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60)) +) + +(defun append-mode-hook (hook-name new-defun) + (cond + ((not (boundp hook-name)) + (set hook-name (list new-defun))) + ((listp (symbol-value hook-name)) + (set hook-name (append (symbol-value hook-name) (list new-defun)))) + (t + (set hook-name (list (symbol-value hook-name) new-defun)) + ) + ) + ) + + +;(append-mode-hook 'text-mode-hook 'turn-on-auto-fill) +(setq default-major-mode 'indented-text-mode) +(append-mode-hook 'text-mode-hook 'text-mode-tabs) + + +;; RWH misc macros +; copy to/yank from register 1, mostly copied from +; http://xahlee.org/emacs/emacs_esoteric.html +(defun copy-to-register-1 (p1 p2) + "Copy selected text to register named ``1''." + (interactive "r") + (copy-to-register ?1 p1 p2) + (setq deactivate-mark t) + ) +(defun yank-from-register-1 () + "Yank text from register named ``1''." + (interactive) + (insert-register ?1) + ) + + +;;; Enhance the operation of incremental searching. +;;; ----------------------------------------------- +;;; The following lines force emacs incremental searches to pop up a small +;;; window when doing incremental searches. Under most circumstances this +;;; is desireable because it reduces the length of screen refreshes during +;;; incremental searches. +(setq search-slow-speed 38400) ; essentially always +(setq search-slow-window-lines 10) + + +;;; put time status in mode line +;;;-------------------------------------- + +(display-time) + +(setq display-time-day-and-date t) ;; print the date and time, not just the time + +; - - - - - {Dis,En}able Functions +(put 'eval-expression 'disabled nil) ; for those that lisp +(put 'narrow-to-region 'disabled nil) ; if you understand narrowing + + + +(setq remembering-keystrokes nil) ; for remember-toggle function + +;(substitute-key-definition 'next-line 'next-line-KD global-map) +(substitute-key-definition 'kill-line 'kill-line-KD global-map) + +(defun kill-line-KD (lines) + "Same as kill-line except kills whole line if at beginning of line." + (interactive "p") (kill-line (if (and (not (bolp)) (= lines 1)) nil lines))) + +(defun next-line-KD (lines) + "Same as next-line except does not create new lines at end-of-buffer." + (interactive "p") + (next-line (- lines (save-excursion (forward-line lines)))) + (if (eobp) (ding)) + ) + +(defun remember-toggle () + "Start/Stop remembering keystrokes for kbd macro named 'one-key-bd-macro'." + (interactive) + (setq remembering-keystrokes (not remembering-keystrokes)) + (if remembering-keystrokes (start-kbd-macro nil) + (end-kbd-macro nil) + (name-last-kbd-macro 'one-key-bd-macro)) + ) + +;; (setq vhdl-font-lock-highlight-level 1) ;; (1 or 2 or 3) +;; (setq vhdl-font-lock-highlight-level 3) + + +;;;; Web-related modes (PHP, HTML, JavaScript, etc.) +;;(require 'web-mode) +;;(add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) +;;(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) + +;;; +;;; Visual Basic mode (incl. SysView) +;;; +(autoload 'visual-basic-mode "visual-basic-mode" "Visual Basic mode." t) +(setq auto-mode-alist (append '(("\\.\\(frm\\|bas\\|cls\\|svi\\|svs\\)$" . + visual-basic-mode)) auto-mode-alist)) + +; add this to your .emacs file if you would like to be able to switch from DOS +; to UNIX or back for any file +;(require 'eol-conversion) +; +;;RWH: (13 Sep 2010) use M-x set-buffer-file-coding-system or (C-x RET f) and +;;specify "unix", "dos" or "mac". + + +;;; +;;; C-mode and relatives +;;; +(setq comment-empty-lines t) + + +;;; +;;; LaTeX mode (AUCTeX, preview-latex, and reftex) +;;; +; try to load tex-site (AUCTeX top-level load) +(when (not (featurep 'tex-site)) + (load "tex-site" t)) +; what to do when tex-site (i.e. AUCTeX) is available +(when (featurep 'tex-site) + (setq TeX-auto-save t) + (setq TeX-parse-self t) + (setq-default TeX-master nil) + (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; RefTeX hook into AUCTeX LaTeX + (setq reftex-plug-into-AUCTeX t) + (setq TeX-PDF-mode 1) ;turn on PDF mode. + ;(when (eq system-type 'windows-nt);(string= OS "WIN") + ; ;(setq TeX-output-view-style (quote (("^dvi$" ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$") "%(o?)dvips -t landscape %d -o && gv %f") ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%(o?)dvips %d -o && gv %f") ("^dvi$" ("^\\(?:a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4\\)$" "^landscape$") "%(o?)xdvi %dS -paper a4r -s 0 %d") ("^dvi$" "^\\(?:a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4\\)$" "%(o?)xdvi %dS -paper a4 %d") ("^dvi$" ("^\\(?:a5\\(?:comb\\|paper\\)\\)$" "^landscape$") "%(o?)xdvi %dS -paper a5r -s 0 %d") ("^dvi$" "^\\(?:a5\\(?:comb\\|paper\\)\\)$" "%(o?)xdvi %dS -paper a5 %d") ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d") ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d") ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d") ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") ("^dvi$" "." "%(o?)xdvi %dS %d") ("^pdf$" "." "gsview32 %o") ("^html?$" "." "netscape %o")))) + ; (push (list 'output-pdf "gsview") TeX-view-program-selection) + ; (push (list "gsview" "gsview32 %o") TeX-view-program-list) + ) + +; X-symbol (optional) +;(defvar x-symbol-root-directory (expand-file-name "/home/ryan/rcfiles/elisp/x-symbol")) +;(defvar x-symbol-lisp-directory +; (expand-file-name "lisp/x-symbol" x-symbol-root-directory)) +;(setq load-path (cons x-symbol-lisp-directory load-path)) +;(setq x-symbol-data-directory +; (expand-file-name "etc/x-symbol" x-symbol-root-directory)) +;(load (expand-file-name "auto-autoloads" x-symbol-lisp-directory)) +;(or (fboundp 'custom-add-loads) +; (defun custom-add-loads (symbol list) +; (dolist (load list) (custom-add-load symbol load)))) +;(load (expand-file-name "custom-load" x-symbol-lisp-directory)) +;(x-symbol-initialize) +;RWH:: turned off because my plus/minus symbols disappeared from my TeX-ified document. + +;;; +;;; Ruby mode +;;; +(autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t) +;error? (autoload 'ruby-electric "ruby-electric" "Ruby editing helper minor mode." t) +(autoload 'ruby-electric "ruby-electric" "Ruby editing helper minor mode." t) +;(require 'ruby-electric) +;(autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process") ;broken +;(autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode") ;broken +;(autoload 'rubydb "rubydb3x" "Ruby debugger" t) ;broken +;(set-default 'auto-mode-alist (append '(("\\.rb$" . ruby-mode)) auto-mode-alist)) +;(set-default 'auto-mode-alist (append '(("[Rr]akefile" . ruby-mode)) auto-mode-alist)) +(add-to-list 'auto-mode-alist '("\\.\\(rb\\|tt\\|treetop\\)$" . ruby-mode)) +(add-to-list 'auto-mode-alist '("^[Rr]akefile$" . ruby-mode)) +(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode)) +;(add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys))) +;error? (add-to-list 'ruby-mode-hook 'turn-on-font-lock) +(defun ruby-eval-buffer () (interactive) + "Evaluate the buffer with ruby." + (shell-command-on-region (point-min) (point-max) "ruby")) +;;PRE-1.8.5;;(defun ruby-xmp-region (reg-start reg-end) +;;PRE-1.8.5;; "Pipe the region through Ruby's xmp utility and replace +;;PRE-1.8.5;; the region with the result." +;;PRE-1.8.5;; (interactive "r") +;;PRE-1.8.5;; (shell-command-on-region reg-start reg-end +;;PRE-1.8.5;; "ruby -r xmp -n -e 'xmp($_, \"%l\t\t# %r\n\")'" t)) +;;PRE-1.8.5;;(defun ruby-visit-source () +;;PRE-1.8.5;; "If the current line contains text like '../src/program.rb:34', visit +;;PRE-1.8.5;;that file in the other window and position point on that line." +;;PRE-1.8.5;; (interactive) +;;PRE-1.8.5;; (let* ((start-boundary (save-excursion (beginning-of-line) (point))) +;;PRE-1.8.5;; (regexp (concat "\\([ \t\n\r\"'([<{]\\|^\\)" ; non file chars or +;;PRE-1.8.5;; ; effective +;;PRE-1.8.5;; ; beginning of file +;;PRE-1.8.5;; "\\(.+\\.rb\\):\\([0-9]+\\)")) ; file.rb:NNN +;;PRE-1.8.5;; (matchp (save-excursion +;;PRE-1.8.5;; (end-of-line) +;;PRE-1.8.5;; ;; if two matches on line, the second is most likely +;;PRE-1.8.5;; ;; to be useful, so search backward. +;;PRE-1.8.5;; (re-search-backward regexp start-boundary t)))) +;;PRE-1.8.5;; (cond (matchp +;;PRE-1.8.5;; (let ((file (buffer-substring (match-beginning 2) +;;PRE-1.8.5;; (match-end 2))) +;;PRE-1.8.5;; (line (buffer-substring (match-beginning 3) +;;PRE-1.8.5;; (match-end 3)))) +;;PRE-1.8.5;; ; Windows: Find-file doesn't seem to work with Cygwin +;;PRE-1.8.5;; ; /// format or the odd /cygdrive// format +;;PRE-1.8.5;; (if (or (string-match "//\\(.\\)\\(.*\\)" file) +;;PRE-1.8.5;; (string-match "/cygdrive/\\(.\\)\\(.*\\)" file)) +;;PRE-1.8.5;; (setq file +;;PRE-1.8.5;; (concat (substring file +;;PRE-1.8.5;; (match-beginning 1) +;;PRE-1.8.5;; (match-end 1)) +;;PRE-1.8.5;; ":" +;;PRE-1.8.5;; (substring file +;;PRE-1.8.5;; (match-beginning 2) +;;PRE-1.8.5;; (match-end 2))))) +;;PRE-1.8.5;; +;;PRE-1.8.5;; (find-file-other-window file) +;;PRE-1.8.5;; (goto-line (string-to-int line)))) +;;PRE-1.8.5;; (t +;;PRE-1.8.5;; (error "No ruby location on line."))))) +;;PRE-1.8.5;;(defun ruby-send-block-or-line () +;;PRE-1.8.5;; (save-excursion +;;PRE-1.8.5;; (if (re-search-backward "[\n\t ]\\(.*\\)[\n\t ]" nil t) +;;PRE-1.8.5;; (let ((foo (match-string 0))) +;;PRE-1.8.5;; (set-text-properties 0 (length foo) nil foo) +;;PRE-1.8.5;; (if (string= foo "end") +;;PRE-1.8.5;; (begin +;;PRE-1.8.5;; (previous-line -1) +;;PRE-1.8.5;; (ruby-send-definition)) +;;PRE-1.8.5;; (ruby-send-region (line-beginning-position) (line-end-position))))))) + +;;; +;;; end Ruby mode +;;; + + + +;;; +;;; Python mode +;;; +;(autoload 'python "python-21" "Python Mode." t) +;(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) +;(add-to-list 'interpreter-mode-alist '("python" . python)) +;sage:(add-to-list 'load-path (expand-file-name "/home/ryan/sage/data/emacs")) +;sage:(require 'sage "sage") +;sage:(setq sage-command "/home/ryan/sage/sage") +;sage:(when (not (featurep 'sage-mode)) ; if we don't have sage-mode available +;sage: (add-to-list 'auto-mode-alist '("\\.\\(sage\\|pyx\\|spyx\\|pxd\\|pxi\\)$" +;sage: . python-mode))) + +;; If you want sage-view to typeset all your output and have plot() +;; commands inline, uncomment the following line and configure sage-view: +;; (require 'sage-view "sage-view") +;; (add-hook 'sage-startup-hook 'sage-view) +;; You can use commands like +;; (add-hook 'sage-startup-hook 'sage-view +;; 'sage-view-disable-inline-output 'sage-view-disable-inline-plots) +;; to have some combination of features. In future, the customize interface +;; will make this simpler... hint, hint! + + +;;; +;;; Mathematica mode +;;; +(autoload 'mathematica-mode "mathematica" "Mathematica package editing mode." t) +(add-to-list 'auto-mode-alist '("\\.nb$" . mathematica-mode)) +; Note: Don't add Mathematica package files, *.m to this list because I am much +; more likely to see/use Matlab files, which use the same extension. + + +;;; +;;; VHDL mode +;;; + +(autoload 'vhdl-mode "vhdl-mode" "VHDL Editing Mode" t) + +;(setq LaTeX-command "latex") +;(setq LaTeX-command "pdflatex") +;(setq latex-run-command "pdflatex") +;(setq auto-mode-alist (append '(("\\.vhdl?$" . vhdl-mode)) auto-mode-alist)) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(LaTeX-amsmath-label "") + '(LaTeX-command "latex") + '(LaTeX-eqnarray-label "eqn:") + '(LaTeX-equation-label "eqn:") + '(LaTeX-label-alist + '(("figure" . LaTeX-figure-label) ("table" . LaTeX-table-label) + ("figure*" . LaTeX-figure-label) ("table*" . LaTeX-table-label) + ("equation" . LaTeX-equation-label) ("eqnarray" . LaTeX-eqnarray-label))) + '(TeX-master nil t) + '(TeX-view-style + '(("." "kpdf %d") + ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "%(o?)xdvi %dS -paper a4 %d") + ("^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d") + ("^b5paper$" "%(o?)xdvi %dS -paper b5 %d") + ("^letterpaper$" "%(o?)xdvi %dS -paper us %d") + ("^legalpaper$" "%(o?)xdvi %dS -paper legal %d") + ("^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") + ("^landscape$" "%(o?)xdvi %dS -paper a4r -s 0 %d") + ("." "%(o?)xdvi %dS %d"))) + '(c-basic-offset 2) + '(fill-column 79) + '(global-auto-revert-mode t nil (autorevert)) + '(inferior-octave-startup-args nil) + '(make-backup-files nil) + '(mediawiki-site-alist + '(("Homestead" "http://www.hintonclan.org/homestead2/index.php/" "Ryan" "" ""))) + '(mouse-buffer-menu-mode-mult 0) + '(package-selected-packages + '(auctex dockerfile-mode haml-mode inf-ruby markdown-mode typescript-mode + yaml-mode)) + '(reftex-default-label-alist-entries + '(AMSTeX amsmath endnotes fancybox floatfig longtable picinpar rotating sidecap + subfigure supertab wrapfig LaTeX)) + '(reftex-plug-into-AUCTeX t t) + '(safe-local-variable-values '((TeX-master . t))) + '(tex-default-mode 'latex-mode) + '(tex-start-options-string "--clean --pdf" t) + '(vhdl-actual-port-name '(".*" . "\\&")) + '(vhdl-auto-align t) + '(vhdl-basic-offset 2) + '(vhdl-compiler "ModelSim") + '(vhdl-compiler-alist + '(("Cadence" "cv -file" "" "" "./" + ("duluth: \\*E,[0-9]+ (\\(.+\\),\\([0-9]+\\)):" 1 2) ("" 0)) + ("Ikos" "analyze" "" "" "./" ("E L\\([0-9]+\\)/C[0-9]+:" 0 1) + ("^analyze +\\(.+ +\\)*\\(.+\\)$" 2)) + ("ModelSim" "vcom" "" "vmake > Makefile" "./" + ("\\(ERROR\\|WARNING\\)[^:]*: \\(.+\\)(\\([0-9]+\\)):" 2 3) ("" 0)) + ("QuickHDL" "qvhcom" "" "qhmake >! Makefile" "./" + ("\\(ERROR\\|WARNING\\)[^:]*: \\(.+\\)(\\([0-9]+\\)):" 2 3) ("" 0)) + ("Synopsys" "vhdlan" "" "" "./" + ("\\*\\*Error: vhdlan,[0-9]+ \\(.+\\)(\\([0-9]+\\)):" 1 2) ("" 0)) + ("Vantage" "analyze -libfile vsslib.ini -src" "" "" "./" + ("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" 0 1) + ("^ *Compiling \"\\(.+\\)\" " 1)) + ("Viewlogic" "analyze -libfile vsslib.ini -src" "" "" "./" + ("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" 0 1) + ("^ *Compiling \"\\(.+\\)\" " 1)))) + '(vhdl-compiler-options "-explicit -2002 -work ../msim/work") + '(vhdl-date-format "%m/%d/%Y") + '(vhdl-electric-mode t) + '(vhdl-end-comment-column 79) + '(vhdl-highlight-keywords t) + '(vhdl-highlight-signals t) + '(vhdl-include-port-comments nil) + '(vhdl-prompt-for-comments nil) + '(vhdl-reset-active-high t) + '(vhdl-reset-kind 'sync) + '(vhdl-self-insert-comments nil) + '(vhdl-standard '(8 (math))) + '(vhdl-stutter-mode nil) + '(vhdl-underscore-is-part-of-word t) + '(vhdl-upper-case-attributes nil) + '(vhdl-upper-case-constants t) + '(vhdl-upper-case-enum-values t) + '(vhdl-upper-case-keywords nil) + '(vhdl-upper-case-types nil) + '(vhdl-use-default-colors t)) + + +;; +;; Fonts and appearance +;; +(show-paren-mode 1) +(setq show-paren-style 'parenthesis) +(unless (equal window-system nil) + (set-face-foreground 'default "ivory");"white");"lightyellow1") + (set-face-background 'default "black");"gray10");"midnight blue"); + (set-face-background 'show-paren-match "blue");"gray10");"midnight blue"); + ;(set-face-foreground 'font-lock-comment-face "red") + (set-cursor-color "green") + ) +; remove menubar, toolbar and scrollbar +(menu-bar-mode -1) +(when (fboundp 'tool-bar-mode) + (tool-bar-mode -1)) +(when (fboundp 'scroll-bar-mode) + (scroll-bar-mode -1)) +; C-x C-e at the end of the line to turn these back on if wanted +;(menu-bar-mode 1) +;(tool-bar-mode 1) +;(scroll-bar-mode -1) + +;; +;; Octave mode +;; +(autoload 'octave-mode "octave-mod" nil t) +;RWH:: Matlab mode below is much nicer;(setq auto-mode-alist +;RWH:: Matlab mode below is much nicer; (cons '("\\.m$" . octave-mode) auto-mode-alist)) +(add-hook 'octave-mode-hook + (lambda () + (abbrev-mode 1) + ;(auto-fill-mode 1) + (font-lock-mode 1))) +(add-hook 'inferior-octave-mode-hook + (lambda () + (turn-on-font-lock) + (define-key inferior-octave-mode-map [up] + 'comint-previous-input) + (define-key inferior-octave-mode-map [down] + 'comint-next-input))) +(autoload 'run-octave "octave-inf" nil t) + + +;; +;; Metapost Mode +;; +(defun metapost-compile-buffer () + "Compile current buffer with Metapost." + (interactive) + ;Notes: + ; - We should have a "save buffer?" dialog if the current buffer is modified. + ; - It would be nice to clear the compile buffer before a recompile. + (setq curbuf-fname (shell-quote-argument buffer-file-name)) + (setq mpbuf-name (concat "*Metapost-" curbuf-fname "*")) + (save-excursion + (set-buffer (get-buffer-create mpbuf-name)) + (erase-buffer)) + (if (= 0 (call-process "mpost" nil mpbuf-name nil curbuf-fname)) + (message (concat "Metapost compiled " curbuf-fname " successfully.")) + (message (concat "Metapost compile of " curbuf-fname " FAILED."))) + ) +(add-hook 'metapost-mode-hook + (lambda () + (define-key meta-mode-map "\C-c\C-c" 'metapost-compile-buffer))) + +;; +;; MediaWiki mode +;; +;(load "mediawiki") +;RWH: takes a long time to load, and doesn't work. + +;; +;; Matlab Mode +;; +;; Edit the path in the following line to reflect the +;; actual location of the MATLAB root directory on your system. +;; Edit the path in the following line to reflect the +;; ;; actual location of the MATLAB root directory on your system. +;RWH:: old Windows setting;(add-to-list 'load-path "c:\\MATLAB6p5\\java\\extern\\EmacsLink\\lisp") +;RWH:: old Windows setting;(autoload 'matlab-eei-connect "matlab-eei" "Connects Emacs to MATLAB's external editor interface.") +(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t) +(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) +(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t) + +;; User Level customizations (You need not use them all): +(setq matlab-indent-function nil) ; if you want function bodies indented +(setq matlab-verify-on-save-flag nil) ; turn off auto-verify on save +(defun my-matlab-mode-hook () + (setq fill-column 79) ; where auto-fill should wrap + (auto-fill-mode 0)) ; turn off annoying auto-fill-mode +(add-hook 'matlab-mode-hook 'my-matlab-mode-hook) +(defun my-matlab-shell-mode-hook () + '()) +(add-hook 'matlab-shell-mode-hook 'my-matlab-shell-mode-hook) +(setq matlab-shell-command-switches '("-nojvm")) ; turn off Matlab desktop + +; Please read the mode help for matlab-mode for additional +; configuration options. + +; Syntax highlighting: +; To get font-lock try adding this for older emacsen: +; (font-lock-mode 1) +; Or for newer versions of Emacs: +(global-font-lock-mode t) +; To get hilit19 support try adding: +; (matlab-mode-hilit) + +;; +;; end of Matlab Mode customizations +;; + +(setq mh-yank-hooks 'sc-cite-original) +(setq sc-load-hook 'sc-setup) + +(put 'upcase-region 'disabled nil) + +(put 'downcase-region 'disabled nil) + +;; Setup persistent Emacs sessions (start from where I left off) +;(desktop-load-default) +;(desktop-read) + + +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) + +;;; +; Voodoo to get around " Wrong type argument: frame-live-p, # +(setq menu-updating-frame nil) + + +(add-hook 'before-save-hook 'delete-trailing-whitespace) + +; 5 space indent for assembly + '(asm-basic-offset 5) + + +; ruby mode insert debug +(global-set-key (kbd "C-c d") + (lambda () + (interactive) + (let ((indentation (current-indentation))) ; Get current line's indentation + (end-of-line) + (newline) ; Insert a new line + (indent-to indentation) ; Match the indentation + (insert "require 'byebug'; debugger")))) ; Insert the string diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0f57144 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +tensorflow diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..7b21c13 --- /dev/null +++ b/setup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Make virtual env + +python3 -m venv venv + +venv/bin/python3 -m pip install -r requirements.txt diff --git a/train.py b/train.py index 2d289b2..8ca0426 100644 --- a/train.py +++ b/train.py @@ -29,6 +29,7 @@ RNN_UNITS = 512 # Pipeline & Training Hyperparameters TEXT_FILE = "saved_files/pg14314.txt" +FILE_URL = 'https://www.gutenberg.org/cache/epub/14314/pg14314.txt' VOCAB_FILE = "vocab.txt" # DYNAMICALLY MANGLED DIRECTORY: @@ -77,7 +78,15 @@ if os.path.exists(VOCAB_FILE): vocab = json.load(f) else: if not os.path.exists(TEXT_FILE): - sys.exit(f"Error: Neither '{VOCAB_FILE}' nor '{TEXT_FILE}' was found.") + print(f"File '{TEXT_FILE}' not found locally. Downloading it.") + # Download the file\mn", + downloaded_path = tf.keras.utils.get_file('tmp', FILE_URL) + + # Save the downloaded file to the designated local directory + with open(downloaded_path, 'rb') as source_file: + with open(local_path, 'wb') as dest_file: + dest_file.write(source_file.read()) + print(f"Loading raw text from {TEXT_FILE} to build vocabulary...") with open(TEXT_FILE, 'r', encoding='utf-8') as f: