浏览代码

Merge branch 'master' of github-as-eludom:eludom/elisp

George Jones 6 年之前
父节点
当前提交
b972d2db7b
共有 6 个文件被更改,包括 126 次插入5 次删除
  1. 19 0
      gmj-man.el
  2. 6 0
      gmj-savedKeyboardMacros.org
  3. 1 0
      gmj_emacs_abbrev.el
  4. 51 0
      ob-rust.el
  5. 6 5
      pythonIndent4.el
  6. 43 0
      testing/prog-hooks.el

+ 19 - 0
gmj-man.el

@@ -0,0 +1,19 @@
+(defun gmj-man (&optional @word)
+  "Run man for current word or text selection.
+
+ Derived from xah-lookup-word-on-internet
+ URL `http://ergoemacs.org/emacs/xah-lookup.html'
+Version 2017-08-15"
+  (interactive)
+  (let ($word $refUrl $myUrl)
+    (setq $word
+	  (if @word
+	      @word
+	    (if (region-active-p)
+		(buffer-substring-no-properties (region-beginning) (region-end))
+	      (current-word))))
+
+    (man $word)
+    ))
+
+(define-key help-map (kbd "0") 'gmj-man)

+ 6 - 0
gmj-savedKeyboardMacros.org

@@ -59,3 +59,9 @@
    [escape ?b escape ?b escape ?b escape ?b escape ?b escape ?b ?\C-  escape ?f escape ?f escape ?f escape ?w escape ?f escape ?f escape ?f escape ?f escape ?f escape ?b escape ?b ?\C-y ?_ escape ?b escape ?b escape ?b ?\C-p])
 
 #+END_SRC
+
+#+BEGIN_SRC emacs-lisp
+(fset 'gmj-trim-line
+   "\M-\\\C-e\M-\\\C-n\C-a")
+
+#+END_SRC

+ 1 - 0
gmj_emacs_abbrev.el

@@ -0,0 +1 @@
+(define-global-abbrev "8sv" "\"${}\"") ; insert a shell shell varaible reference

+ 51 - 0
ob-rust.el

@@ -0,0 +1,51 @@
+;;; ob-rust.el --- org-babel functions for rust evaluation
+
+;; Copyright (C) 2015 ZHOU Feng
+
+;; Author: ZHOU Feng <zf.pascal@gmail.com>
+;; URL: http://github.com/zweifisch/ob-rust
+;; Keywords: org babel rust
+;; Version: 0.0.1
+;; Created: 29th May 2015
+;; Package-Requires: ((org "8"))
+
+;;; Commentary:
+;;
+;; org-babel functions for rust evaluation
+;;
+
+;;; Code:
+(require 'ob)
+
+(defun org-babel-execute:rust (body params)
+  (ob-rust-eval (ob-rust-prep body)))
+
+(defun ob-rust-eval (body)
+  (let ((src-tmp (org-babel-temp-file "rust-"))
+        (output-tmp (org-babel-temp-file "rustc-")))
+    (with-temp-file src-tmp (insert body))
+    (shell-command-to-string
+     (format "rustc -A dead_code -o %s %s && %s"
+             output-tmp src-tmp output-tmp))))
+
+(defun ob-rust-prep (body)
+  (with-current-buffer (get-buffer-create "*ob-rust-src*")
+    (erase-buffer)
+    (insert "fn main() {\n")
+    (insert body)
+    (goto-char (point-max))
+    (beginning-of-line)
+    (while (looking-at "\\(^[\t ]*//\\|^[\t ]*$\\)")
+      (forward-line -1))
+    (if (looking-at "[\t ]*\\(println\\|}\\)")
+        (end-of-line)
+      (insert "println!(\"{:?}\", ")
+      (when (search-forward-regexp ";[\t ]*$" nil t)
+        (replace-match "" t t))
+      (end-of-line)
+      (insert ");"))
+    (insert "\n}")
+    (buffer-string)))
+
+(provide 'ob-rust)
+;;; ob-rust.el ends here

+ 6 - 5
pythonIndent4.el

@@ -1,8 +1,9 @@
 ;; http://stackoverflow.com/questions/3684738/how-do-i-set-emacs-tab-size-to-4-chars-wide-for-py-files
 
-(add-hook 'python-mode-hook
-      (lambda ()
-        (setq indent-tabs-mode t)
-        (setq tab-width 4)
-        (setq python-indent 4)))
+;; Unnecessary now?
 
+;;(add-hook 'python-mode-hook
+;;      (lambda ()
+;;        (setq indent-tabs-mode t)
+;;        (setq tab-width 4)
+;;        (setq python-indent 4)))

+ 43 - 0
testing/prog-hooks.el

@@ -0,0 +1,43 @@
+; https://stackoverflow.com/questions/318553/getting-emacs-to-untabify-when-saving-certain-file-types-and-only-those-file-ty
+
+(add-hook 'c++-mode-hook
+	  '(lambda ()
+	     (add-hook 'before-save-hook
+		       (lambda ()
+			 (untabify (point-min) (point-max))))))
+
+(defun untabify-buffer ()
+  "Untabify current buffer"
+  (interactive)
+  (untabify (point-min) (point-max)))
+
+(defun progmodes-hooks ()
+  "Hooks for programming modes"
+  (yas/minor-mode-on)
+  (add-hook 'before-save-hook 'progmodes-write-hooks))
+
+(defun progmodes-write-hooks ()
+  "Hooks which run on file write for programming modes"
+  (prog1 nil
+    (set-buffer-file-coding-system 'utf-8-unix)
+    (untabify-buffer)
+    (copyright-update)
+    (maybe-delete-trailing-whitespace)))
+
+(defun delete-trailing-whitespacep ()
+  "Should we delete trailing whitespace when saving this file?"
+  (save-excursion
+    (goto-char (point-min))
+    (ignore-errors (next-line 25))
+    (let ((pos (point)))
+      (goto-char (point-min))
+      (and (re-search-forward (concat "@author +" user-full-name) pos t) t))))
+
+(defun maybe-delete-trailing-whitespace ()
+  "Delete trailing whitespace if I am the author of this file."
+  (interactive)
+  (and (delete-trailing-whitespacep) (delete-trailing-whitespace)))
+
+(add-hook 'php-mode-hook 'progmodes-hooks)
+(add-hook 'python-mode-hook 'progmodes-hooks)
+(add-hook 'js2-mode-hook 'progmodes-hooks)