[Emacs] Add functions section to highlights

This commit is contained in:
Ivan Malison 2016-10-24 16:16:23 -07:00
parent 80607467a1
commit c8eec96f6a
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -8,6 +8,11 @@ others may find to be useful.
** Highlights ** Highlights
These sections are the ones that have the most potential to be interesting to These sections are the ones that have the most potential to be interesting to
others: others:
*** [[Functions][My functions section]]
...has a bunch of generally useful functions:
+ [[downloadfile][Download a file into a buffer]] (curl straight into a file)
+ [[editscript][Edit a script on $PATH]]
+ [[namedbuild][Named Build of Builder Macros]] and [[composemacros][A Compose Supporting Macros]]
*** Configuration of My Own Packages *** Configuration of My Own Packages
- [[term-projectile][term-projectile]] and [[term-manager][term-manager]] - [[term-projectile][term-projectile]] and [[term-manager][term-manager]]
- [[org-projectile][org-projectile]] - [[org-projectile][org-projectile]]
@ -377,8 +382,8 @@ This is disabled for now until I figure out what to do with emit.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package request) (use-package request)
#+END_SRC #+END_SRC
** Macros ** Named Build
*** Named Build <<namedbuild>>
imalison:named-build provides a way to invoke a macro in such a way imalison:named-build provides a way to invoke a macro in such a way
that the lambda that it produces is given a name. that the lambda that it produces is given a name.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -409,7 +414,7 @@ new macro name and the -fn suffix.
`(imalison:named-builder-builder `(imalison:named-builder-builder
,name ,(intern (concat (symbol-name name) "-fn")))) ,name ,(intern (concat (symbol-name name) "-fn"))))
#+END_SRC #+END_SRC
*** Emacs Version Predicate ** Emacs Version Predicate
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defmacro imalison:emacs-version-predicate-fn (major-version minor-version) (defmacro imalison:emacs-version-predicate-fn (major-version minor-version)
`(lambda () `(lambda ()
@ -422,8 +427,9 @@ new macro name and the -fn suffix.
(imalison:named-builder imalison:emacs-version-predicate) (imalison:named-builder imalison:emacs-version-predicate)
#+END_SRC #+END_SRC
*** Compose Functions ** Compose Functions
**** A version supporting macros *** A version supporting macros
<<composemacros>>
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun imalison:help-function-arglist (fn) (defun imalison:help-function-arglist (fn)
(let ((result (help-function-arglist fn))) (let ((result (help-function-arglist fn)))
@ -465,7 +471,7 @@ new macro name and the -fn suffix.
(imalison:named-builder imalison:compose) (imalison:named-builder imalison:compose)
(imalison:named-builder imalison:compose-macro) (imalison:named-builder imalison:compose-macro)
#+END_SRC #+END_SRC
**** Arbitrary arguments at every step *** Arbitrary arguments at every step
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun imalison:make-list (thing) (defun imalison:make-list (thing)
(if (listp thing) (if (listp thing)
@ -484,7 +490,7 @@ new macro name and the -fn suffix.
`(apply ,(car funcs) `(apply ,(car funcs)
(imalison:make-list (imalison:compose-with-apply-helper ,(cdr funcs)))))) (imalison:make-list (imalison:compose-with-apply-helper ,(cdr funcs))))))
#+END_SRC #+END_SRC
**** Simpler unary version *** Simpler unary version
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defmacro imalison:compose-unary (&rest funcs) (defmacro imalison:compose-unary (&rest funcs)
"Build a new function with NAME that is the composition of FUNCS." "Build a new function with NAME that is the composition of FUNCS."
@ -497,7 +503,7 @@ new macro name and the -fn suffix.
'arg 'arg
`(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs))))) `(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs)))))
#+END_SRC #+END_SRC
*** Make Interactive ** Make Interactive
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defmacro imalison:make-interactive-fn (function) (defmacro imalison:make-interactive-fn (function)
`(lambda (&rest args) `(lambda (&rest args)
@ -506,7 +512,7 @@ new macro name and the -fn suffix.
(imalison:named-builder imalison:make-interactive) (imalison:named-builder imalison:make-interactive)
#+END_SRC #+END_SRC
*** Advice Add Around Builder ** Advice Add Around Builder
For composing functions with an apply so that they can be used with For composing functions with an apply so that they can be used with
the ~:around~ keyword of advice-add. the ~:around~ keyword of advice-add.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -516,11 +522,11 @@ the ~:around~ keyword of advice-add.
(imalison:named-builder imalison:advice-add-around-builder) (imalison:named-builder imalison:advice-add-around-builder)
#+END_SRC #+END_SRC
**** Kill New *** Kill New
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(imalison:advice-add-around-builder imalison:kill-new-around kill-new) (imalison:advice-add-around-builder imalison:kill-new-around kill-new)
#+END_SRC #+END_SRC
*** Let Around ** Let Around
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defmacro imalison:let-around-fn (orig-func &rest forms) (defmacro imalison:let-around-fn (orig-func &rest forms)
(let* ((orig-interactive-form (interactive-form orig-func)) (let* ((orig-interactive-form (interactive-form orig-func))
@ -535,7 +541,7 @@ the ~:around~ keyword of advice-add.
(imalison:named-builder imalison:let-around) (imalison:named-builder imalison:let-around)
#+END_SRC #+END_SRC
*** Let Around Advice ** Let Around Advice
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defmacro imalison:let-advise-around-fn (&rest forms) (defmacro imalison:let-advise-around-fn (&rest forms)
`(lambda (orig-func &rest args) `(lambda (orig-func &rest args)
@ -544,7 +550,7 @@ the ~:around~ keyword of advice-add.
(imalison:named-builder imalison:let-advise-around) (imalison:named-builder imalison:let-advise-around)
#+END_SRC #+END_SRC
*** Compose Around Builder ** Compose Around Builder
For composing functions with an apply so that they can be used with the ~:around~ keyword of advice-add. For composing functions with an apply so that they can be used with the ~:around~ keyword of advice-add.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; TODO/XXX: Isn't this just apply? why doesn't apply work here ;; TODO/XXX: Isn't this just apply? why doesn't apply work here
@ -556,7 +562,7 @@ the ~:around~ keyword of advice-add.
(imalison:named-builder imalison:compose-around-builder) (imalison:named-builder imalison:compose-around-builder)
#+END_SRC #+END_SRC
*** Measure Time ** Measure Time
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defmacro imalison:measure-time (&rest body) (defmacro imalison:measure-time (&rest body)
"Measure and return the running time of the code block." "Measure and return the running time of the code block."
@ -747,6 +753,7 @@ A macro for composing functions together to build an interactive command to copy
(perform-replace "\\n" "\n" nil nil delimited nil nil beg end nil))))) (perform-replace "\\n" "\n" nil nil delimited nil nil beg end nil)))))
#+END_SRC #+END_SRC
** Download a File Into a Buffer ** Download a File Into a Buffer
<<downloadfile>>
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun imalison:download-to-buffer (uri) (defun imalison:download-to-buffer (uri)
(interactive (list (read-string "Enter uri: "))) (interactive (list (read-string "Enter uri: ")))
@ -770,6 +777,9 @@ A macro for composing functions together to build an interactive command to copy
(intern (mapconcat 'imalison:maybe-symbol-name args ""))) (intern (mapconcat 'imalison:maybe-symbol-name args "")))
#+END_SRC #+END_SRC
** Edit a script on PATH ** Edit a script on PATH
<<editscript>> Note that you'll need to make sure that emacs properly inherits
the path variable for this work. Check out my [[exec-path-from-shell]] config for
details.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun imalison:get-executables-at-path (filepath) (defun imalison:get-executables-at-path (filepath)
(when (and (file-exists-p filepath) (f-directory? filepath)) (when (and (file-exists-p filepath) (f-directory? filepath))