fancy-yank
Sometimes you just have to transform text from the clipboard before pasting it into the buffer. For example, when inserting links to tickets, issues or pull requests you might want to format them, so https://github.com/d12frosted/fancy-yank/issue/1 becomes d12frosted/fancy-yank#1. Are you doing it manually?
Usage
In order to use this package, setup the value of fancy-yank-rules
and use
fancy-yank
to automatically apply transformations defined by these rules.
Example setup
(setq fancy-yank-rules
'(
;; transform GitHub issue link to username/repo#number
("\\(https?://github.com/\\([-[:alnum:]]+\\)/\\([-[:alnum:]]+\\)/[[:alpha:]]+/\\([[:digit:]]+\\)\\).*" .
"[[\\1][\\2/\\3#\\4]]")
;; the same as before, but much more flexible
("\\(https?://github.com/\\([-[:alnum:]]+\\)/\\([-[:alnum:]]+\\)/[[:alpha:]]+/\\([[:digit:]]+\\)\\).*" .
(fancy-yank-extract-regex
(lambda (url owner repo number &rest args)
(list url
(format "%s/%s#%s" owner repo number)))
fancy-yank-format-link))
;; automatically get the title of web page using `org-cliplink' and
;; format it acordingly to the current major mode
("https?://.*" . (fancy-yank-extract-url-title fancy-yank-format-link))
;; append "FIX " to any other string
(#'identity . (lambda (x) (concat "FIX " x)))))
Please refer to fancy-yank-rules
documentation for more information.
In order to configure fancy-yank-format-link
, please take a look at
fancy-yank-format-link-rules
.
Testing
Ideally, you should use Cask for running tests. So first you need to install
cask
. If you are using emacs-plus, then you need to ignore dependencies during
cask
installation.
$ brew install cask --ignore-dependencies
One you have cask
, you need to install all dependencies.
$ cask install
Now you can run tests.
$ cask exec ert-runner
Contributing
Let me know if you have any issues, ideas or proposals. Pull requests are welcome!