summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-31 16:54:07 +0100
committerjao <jao@gnu.org>2021-05-31 16:54:12 +0100
commit83d492d36407588707e41098381328e8b1ebe26c (patch)
treeb5b85efb506c5387768baea1d660bd49ca4c3440
parentdfa4c318529efca52fd2c5a43ff7dd73a63c5b5d (diff)
downloadelibs-83d492d36407588707e41098381328e8b1ebe26c.tar.gz
elibs-83d492d36407588707e41098381328e8b1ebe26c.tar.bz2
section shuffling
-rw-r--r--init.org212
1 files changed, 106 insertions, 106 deletions
diff --git a/init.org b/init.org
index 6bccc59..29e00bc 100644
--- a/init.org
+++ b/init.org
@@ -9,15 +9,6 @@
(package-install 'use-package))
(require 'use-package)
#+end_src
-*** Literate elisp and autotangle
- #+begin_src emacs-lisp
- (use-package poly-org :ensure t)
- ;; (use-package literate-elisp :ensure t)
- (use-package org-auto-tangle
- :ensure t
- :hook (org-mode . org-auto-tangle-mode)
- :diminish)
- #+end_src
*** ELPA Keyring
#+begin_src emacs-lisp
(use-package gnu-elpa-keyring-update :ensure t)
@@ -2254,109 +2245,118 @@
#+end_src
* Programming languages
*** Elisp
- Some helper packages
- #+BEGIN_SRC emacs-lisp
- (use-package edit-list :ensure t)
- (use-package package-lint :ensure t)
- #+END_SRC
+***** Functions to operate on elisp sexps a la slime or geiser
- Functions to operate on elisp sexps a la slime or geiser:
-
- #+begin_src emacs-lisp
- (defun elisp-disassemble (function)
- (interactive (list (function-called-at-point)))
- (disassemble function))
+ #+begin_src emacs-lisp
+ (defun elisp-disassemble (function)
+ (interactive (list (function-called-at-point)))
+ (disassemble function))
+
+ (defun elisp-pp (sexp)
+ (with-output-to-temp-buffer "*Pp Eval Output*"
+ (pp sexp)
+ (with-current-buffer standard-output
+ (emacs-lisp-mode))))
+
+ (defun elisp-macroexpand (form)
+ (interactive (list (form-at-point 'sexp)))
+ (elisp-pp (macroexpand form)))
+
+ (defun elisp-macroexpand-all (form)
+ (interactive (list (form-at-point 'sexp)))
+ (elisp-pp (cl-macroexpand-all form)))
+
+ (defun elisp-push-point-marker ()
+ (require 'etags)
+ (cond ((featurep 'xemacs)
+ (push-tag-mark))
+ (t (ring-insert find-tag-marker-ring (point-marker)))))
+
+ (defun elisp-pop-found-function ()
+ (interactive)
+ (cond ((featurep 'xemacs) (pop-tag-mark nil))
+ (t (pop-tag-mark))))
+
+ (defun elisp-find-definition (name)
+ "Jump to the definition of the function (or variable) at point."
+ (interactive (list (thing-at-point 'symbol)))
+ (cond (name
+ (let ((symbol (intern-soft name))
+ (search (lambda (fun sym)
+ (let* ((r (save-excursion (funcall fun sym)))
+ (buffer (car r))
+ (point (cdr r)))
+ (cond ((not point)
+ (error "Found no definition for %s in %s"
+ name buffer))
+ (t
+ (switch-to-buffer buffer)
+ (goto-char point)
+ (recenter 1)))))))
+ (cond ((fboundp symbol)
+ (elisp-push-point-marker)
+ (funcall search 'find-function-noselect symbol))
+ ((boundp symbol)
+ (elisp-push-point-marker)
+ (funcall search 'find-variable-noselect symbol))
+ (t
+ (message "Symbol not bound: %S" symbol)))))
+ (t (message "No symbol at point"))))
+
+ (defun elisp-bytecompile-and-load ()
+ (interactive)
+ (or buffer-file-name
+ (error "The buffer must be saved in a file first"))
+ (require 'bytecomp)
+ ;; Recompile if file or buffer has changed since last compilation.
+ (when (and (buffer-modified-p)
+ (y-or-n-p (format "save buffer %s first? " (buffer-name))))
+ (save-buffer))
+ (let ((filename (expand-file-name buffer-file-name)))
+ (with-temp-buffer
+ (if (not (native-comp-available-p))
+ (byte-compile-file filename t)
+ (native-compile filename)
+ (load-library (file-name-base filename))))))
- (defun elisp-pp (sexp)
- (with-output-to-temp-buffer "*Pp Eval Output*"
- (pp sexp)
- (with-current-buffer standard-output
- (emacs-lisp-mode))))
+ #+end_src
- (defun elisp-macroexpand (form)
- (interactive (list (form-at-point 'sexp)))
- (elisp-pp (macroexpand form)))
+ Bindinging the functions above to "natural" keys in elisp buffers:
- (defun elisp-macroexpand-all (form)
- (interactive (list (form-at-point 'sexp)))
- (elisp-pp (cl-macroexpand-all form)))
+ #+begin_src emacs-lisp
+ (defvar elisp-extra-keys
+ '(
+ ;; ((kbd "C-c d") 'elisp-disassemble)
+ ((kbd "C-c C-m") 'elisp-macroexpand)
+ ((kbd "C-c C-M") 'elisp-macroexpand-all)
+ ((kbd "C-c C-c") 'compile-defun)
+ ((kbd "C-c C-k") 'elisp-bytecompile-and-load)
+ ((kbd "C-c C-l") 'load-file)
+ ((kbd "C-c C-p") 'pp-eval-last-sexp)
+ ((kbd "M-.") 'elisp-find-definition)
+ ((kbd "M-,") 'elisp-pop-found-function)
+ ((kbd "C-c <") 'list-callers)))
+
+ (dolist (binding elisp-extra-keys)
+ (let ((key (eval (car binding))) (val (eval (cadr binding))))
+ (define-key emacs-lisp-mode-map key val)
+ (define-key lisp-interaction-mode-map key val)))
+ #+end_src
+***** Literate elisp
+ #+begin_src emacs-lisp
+ (use-package poly-org :ensure t)
- (defun elisp-push-point-marker ()
- (require 'etags)
- (cond ((featurep 'xemacs)
- (push-tag-mark))
- (t (ring-insert find-tag-marker-ring (point-marker)))))
+ (use-package org-auto-tangle
+ :ensure t
+ :hook (org-mode . org-auto-tangle-mode)
+ :diminish)
+ #+end_src
+***** Some helper packages
+ #+begin_SRC emacs-lisp
+ (use-package edit-list :ensure t)
+ (use-package package-lint :ensure t)
+ #+end_SRC
- (defun elisp-pop-found-function ()
- (interactive)
- (cond ((featurep 'xemacs) (pop-tag-mark nil))
- (t (pop-tag-mark))))
-
- (defun elisp-find-definition (name)
- "Jump to the definition of the function (or variable) at point."
- (interactive (list (thing-at-point 'symbol)))
- (cond (name
- (let ((symbol (intern-soft name))
- (search (lambda (fun sym)
- (let* ((r (save-excursion (funcall fun sym)))
- (buffer (car r))
- (point (cdr r)))
- (cond ((not point)
- (error "Found no definition for %s in %s"
- name buffer))
- (t
- (switch-to-buffer buffer)
- (goto-char point)
- (recenter 1)))))))
- (cond ((fboundp symbol)
- (elisp-push-point-marker)
- (funcall search 'find-function-noselect symbol))
- ((boundp symbol)
- (elisp-push-point-marker)
- (funcall search 'find-variable-noselect symbol))
- (t
- (message "Symbol not bound: %S" symbol)))))
- (t (message "No symbol at point"))))
-
- (defun elisp-bytecompile-and-load ()
- (interactive)
- (or buffer-file-name
- (error "The buffer must be saved in a file first"))
- (require 'bytecomp)
- ;; Recompile if file or buffer has changed since last compilation.
- (when (and (buffer-modified-p)
- (y-or-n-p (format "save buffer %s first? " (buffer-name))))
- (save-buffer))
- (let ((filename (expand-file-name buffer-file-name)))
- (with-temp-buffer
- (if (not (native-comp-available-p))
- (byte-compile-file filename t)
- (native-compile filename)
- (load-library (file-name-base filename))))))
-
- #+end_src
-
- Bindinging the functions above to "natural" keys in elisp buffers:
-
- #+begin_src emacs-lisp
- (defvar elisp-extra-keys
- '(
- ;; ((kbd "C-c d") 'elisp-disassemble)
- ((kbd "C-c C-m") 'elisp-macroexpand)
- ((kbd "C-c C-M") 'elisp-macroexpand-all)
- ((kbd "C-c C-c") 'compile-defun)
- ((kbd "C-c C-k") 'elisp-bytecompile-and-load)
- ((kbd "C-c C-l") 'load-file)
- ((kbd "C-c C-p") 'pp-eval-last-sexp)
- ((kbd "M-.") 'elisp-find-definition)
- ((kbd "M-,") 'elisp-pop-found-function)
- ((kbd "C-c <") 'list-callers)))
-
- (dolist (binding elisp-extra-keys)
- (let ((key (eval (car binding))) (val (eval (cadr binding))))
- (define-key emacs-lisp-mode-map key val)
- (define-key lisp-interaction-mode-map key val)))
- #+end_src
*** Erlang
#+begin_src emacs-lisp
(use-package erlang