2019-10-09 13:13:56 +02:00
|
|
|
;; symbol.el --- Library for working with symbols. -*- lexical-binding: t -*-
|
2020-09-01 00:28:47 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-09-01 00:28:47 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
|
|
|
|
;; Package-Requires: ((emacs "24"))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; Library for working with symbols.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-09-01 00:28:47 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
(require 'string)
|
|
|
|
|
2020-09-01 00:28:47 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Library
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; Symbols
|
2020-09-01 00:28:47 +02:00
|
|
|
(defun symbol-as-string (callback x)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Treat the symbol, X, as a string while applying CALLBACK to it.
|
|
|
|
Coerce back to a symbol on the way out."
|
|
|
|
(->> x
|
|
|
|
#'symbol-name
|
|
|
|
callback
|
|
|
|
#'intern))
|
|
|
|
|
2020-09-01 00:28:47 +02:00
|
|
|
(defun symbol-to-string (x)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Map `X' into a string."
|
2020-09-01 00:28:47 +02:00
|
|
|
(string-<-symbol x))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 00:28:47 +02:00
|
|
|
(defun symbol-hookify (x)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Append \"-hook\" to X when X is a symbol."
|
2020-09-01 00:28:47 +02:00
|
|
|
(symbol-as-string #'string-hookify x))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 00:28:47 +02:00
|
|
|
(defun symbol-ensure-hookified (x)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Ensure that X has \"-hook\" appended to it when X is a symbol."
|
2020-09-01 00:28:47 +02:00
|
|
|
(symbol-as-string #'string-ensure-hookified x))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 00:28:47 +02:00
|
|
|
(defun symbol-instance? (x)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Return t if X is a symbol."
|
|
|
|
(symbolp x))
|
|
|
|
|
|
|
|
(provide 'symbol)
|
|
|
|
;;; symbol.el ends here
|