diff options
| author | Tharre <tharre3@gmail.com> | 2015-04-06 16:41:29 +0200 | 
|---|---|---|
| committer | Tharre <tharre3@gmail.com> | 2016-10-07 19:42:55 +0000 | 
| commit | 6c9ecd4bc57a318f9b8663cb476efa2945de716b (patch) | |
| tree | 8752a60bd59aff898868139a460678f09464dfd9 /shell/_emacs/site-lisp | |
| parent | b76107ee2d8698671a6fa9d732ea86e32f371e2d (diff) | |
| download | dotfiles-6c9ecd4bc57a318f9b8663cb476efa2945de716b.tar.gz dotfiles-6c9ecd4bc57a318f9b8663cb476efa2945de716b.tar.xz dotfiles-6c9ecd4bc57a318f9b8663cb476efa2945de716b.zip  | |
Initial commit, add everything else
Diffstat (limited to 'shell/_emacs/site-lisp')
| -rw-r--r-- | shell/_emacs/site-lisp/dconf-proxy.el | 14 | ||||
| -rw-r--r-- | shell/_emacs/site-lisp/site-lisp-autoloads.el | 5 | ||||
| -rw-r--r-- | shell/_emacs/site-lisp/util.el | 36 | ||||
| -rw-r--r-- | shell/_emacs/site-lisp/with-package.el | 31 | 
4 files changed, 86 insertions, 0 deletions
diff --git a/shell/_emacs/site-lisp/dconf-proxy.el b/shell/_emacs/site-lisp/dconf-proxy.el new file mode 100644 index 0000000..954852a --- /dev/null +++ b/shell/_emacs/site-lisp/dconf-proxy.el @@ -0,0 +1,14 @@ +(defun refresh-proxy-settings () +  (interactive) +  (if (string= (shell-command-to-string "dconf read /system/proxy/http/enabled") "true\n") +      (setq url-proxy-services +	    `(("http" . +	       ,(concat +		 (car (split-string-and-unquote ;; split string to remove single quotes and newline +		       (shell-command-to-string "dconf read /system/proxy/http/host") '"'")) +		 ":" +		 (car (split-string-and-unquote ;; split string to remove newline +		       (shell-command-to-string "dconf read /system/proxy/http/port") '"\n")))))) +    (setq url-proxy-services nil))) + +(provide 'dconf-proxy) diff --git a/shell/_emacs/site-lisp/site-lisp-autoloads.el b/shell/_emacs/site-lisp/site-lisp-autoloads.el new file mode 100644 index 0000000..2b1e039 --- /dev/null +++ b/shell/_emacs/site-lisp/site-lisp-autoloads.el @@ -0,0 +1,5 @@ + +(autoload 'refresh-proxy-settings "dconf-proxy" "Refresh proxy settings" t) +(autoload 'eval-and-replace "util" "Eval and replace lisp expression" t) + +(provide 'site-lisp-autoloads) diff --git a/shell/_emacs/site-lisp/util.el b/shell/_emacs/site-lisp/util.el new file mode 100644 index 0000000..b5bdc10 --- /dev/null +++ b/shell/_emacs/site-lisp/util.el @@ -0,0 +1,36 @@ +(defun eval-and-replace () +  "Replace the preceding sexp with its value." +  (interactive) +  (forward-char) ;; for evil normal state +  (backward-kill-sexp) +  (condition-case nil +      (prin1 (eval (read (current-kill 0))) +             (current-buffer)) +    (error (message "Invalid expression") +           (insert (current-kill 0))))) + +(defun lorem () +  "Insert a lorem ipsum." +  (interactive) +  (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " +          "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" +          "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +          "aliquip ex ea commodo consequat. Duis aute irure dolor in " +          "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla " +          "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in " +          "culpa qui officia deserunt mollit anim id est laborum.")) + +(defun insert-date () +  "Insert a time-stamp according to locale's date and time format." +  (interactive) +  (insert (format-time-string "%c" (current-time)))) + +(defun indent-buffer () +  (interactive) +  (indent-region (point-min) (point-max))) + +(defun untabify-buffer () +  (interactive) +  (untabify (point-min) (point-max))) + +(provide 'util) diff --git a/shell/_emacs/site-lisp/with-package.el b/shell/_emacs/site-lisp/with-package.el new file mode 100644 index 0000000..3dfc52d --- /dev/null +++ b/shell/_emacs/site-lisp/with-package.el @@ -0,0 +1,31 @@ +(require 'cl) + +;; will be available at emacs 24.4 +(unless (fboundp 'with-eval-after-load) +  "Do magic from the future" +  (defmacro with-eval-after-load (file &rest body) +    `(eval-after-load ,file +       `(funcall (function ,(lambda () ,@body)))))) + +(defmacro with-package (packages &rest body) +  "After pkg macro" +  (declare (indent defun)) +  (when (symbolp packages) ;; make a list if necessary +    (setf packages (list packages))) +  `(progn +     (dolist (p ',packages) +       (when (not (package-installed-p p)) +         (package-install p)) +       (with-eval-after-load p ,@body)))) + +(defmacro with-package* (packages &rest body) +  "After pkg macro*" +  (declare (indent defun)) +  (when (symbolp packages) ;; make a list if necessary +    (setf packages (list packages))) +  `(prog1 +       (with-package ,packages ,@body) +     (dolist (p ',packages) +       (require p)))) + +(provide 'with-package)  | 
