How can I “URL decode” a string in Emacs Lisp?
url-unhex-string
url-unhex-string
Based on your feedback to my first answer, how about this: (defun my-isearch-word-at-point () (interactive) (call-interactively ‘isearch-forward-regexp)) (defun my-isearch-yank-word-hook () (when (equal this-command ‘my-isearch-word-at-point) (let ((string (concat “\\<” (buffer-substring-no-properties (progn (skip-syntax-backward “w_”) (point)) (progn (skip-syntax-forward “w_”) (point))) “\\>”))) (if (and isearch-case-fold-search (eq ‘not-yanks search-upper-case)) (setq string (downcase string))) (setq isearch-string string isearch-message (concat isearch-message (mapconcat … Read more
The general way to unbind a key (for any keymap) is to define a binding of nil: (define-key KEYMAP KEY nil) For convenience, there are also two standard functions for unbinding from the global keymap and from the local keymap (which is usually the major mode’s keymap). (global-unset-key KEY) (local-unset-key KEY) Those ones are interactive … Read more
With alists, you usually add a new cons in front of the old one to “shadow” the old value, like so: (add-to-list ‘a1 ‘(:k1 10)) After you do this (assoc :k1 a1) will return 10. If you want to “undo” your change so assoc again returns your old value, use this code: (setq a1 (delq … Read more
The primary difference is that quote prevents evaluation of the elements, whereas list does not: user=> ‘(1 2 (+ 1 2)) (1 2 (+ 1 2)) user=> (list 1 2 (+ 1 2)) (1 2 3) For this reason (among others), it is idiomatic clojure to use a vector when describing a literal collection: user=> … Read more
This is not easily possible. Regular expressions are designed to match things, and this is all they can do. First off: [^] does not designate an “excludes group”, it designates a negated character class. Character classes do not support grouping in any form or shape. They support single characters (and, for convenience, character ranges). Your … Read more
If you have Emacs 24.4 or newer, the cleanest way to do it would be the new delete-duplicate-lines function. Note that this works on a region, not a buffer, so select the desired text first it maintains the relative order of the originals, killing the duplicates For example, if your input is test dup dup … Read more
Use the string-inflection package, available on MELPA, or at https://github.com/akicho8/string-inflection. Useful keyboard shortcuts, copied from https://www.emacswiki.org/emacs/CamelCase : ;; Cycle between snake case, camel case, etc. (require ‘string-inflection) (global-set-key (kbd “C-c i”) ‘string-inflection-cycle) (global-set-key (kbd “C-c C”) ‘string-inflection-camelcase) ;; Force to CamelCase (global-set-key (kbd “C-c L”) ‘string-inflection-lower-camelcase) ;; Force to lowerCamelCase (global-set-key (kbd “C-c J”) ‘string-inflection-java-style-cycle) … Read more
Emacs doesn’t have any support for namespaces, packages, libraries or modules. Emacs sources therefore use foo- as a prefix for a foo library, and in some cases foo– is used for bindings that are supposed to be internal.
Don’t use M-x, use M-:, which runs the command eval-expression.