Hot answers tagged

5

Use the following key sequence: M-C-% \("finished":[[:space:]]*\)\([0-9]+\) RET \1\,(1+ (string-to-number \2))RET M-C-% is bound to query-replace-regexp. \("finished":[[:space:]]*\)\([0-9]+\) is the regexp to search for, the first group is just for copying into the replacement string, the second group is the number to be transformed. \1\,(1+ (string-to-...


5

In the following I assume that the order of the lines in the result buffer is irrelevant. For medium size buffers you can use cl-intersection: (defun txt-intersection (buffer-a buffer-b) "Only keep the set theoretic intersection of lines in BUFFER-A and BUFFER-B." (interactive "bBuffer A: \nbBuffer B: ") (with-current-buffer (generate-new-buffer (...


4

You can simply run M-x eval-expression and type ?O. You will get the following output in the minibuffer: 79 (#o117, #x4f, ?O)


3

Based on the screenshot, you are only interested in quotes spanning multiple lines. Here's a patten for that: "\\(``\\(?:[^'\n]\\|'[^'\n]\\)*'?\\)\n\\(?:.\\|\n\\)*?''" Or in rx syntax: (rx (seq (group "``" (zero-or-more (or (not (in "\n'")) (seq "'" (not (in "\n'"))))) (zero-or-one "'")) "\n"...


3

If you use regular expressions as suggested by one of the other answers, you have to be careful to avoid checking text outside of quotes for uppercase letters. If you use just a single regular expression, you probably end up with the wrong result for This is a "text" with some UPPERCASE letters outside the "quoted text" You probably need to iterate through ...


2

For example, you can search upper-case letters in quotes. (defun all-text-in-quotes-is-lowercase () "Return t if text in quotes are lowercase text." (save-excursion (goto-char (point-min)) (let ((case-fold-search nil)) (not (search-forward-regexp "\".*[[:upper:]]+.*\"" nil t)))))


2

In Emacs 26 I think you can do this: (defun my-italize-line-dwim () (interactive) (let ((handle (prepare-change-group))) (save-excursion (if (and (progn (evil-last-non-blank) (equal (following-char) ?/)) (progn (back-to-indentation) (equal (following-char) ?/))) (progn (delete-char 1) (evil-last-non-blank) (delete-char ...


2

The way I'd do this is with search and replace. You can call Lisp code from a regexp replacement with \,(my-function …). So call M-x replace-regexp (or C-M-% which is bound to query-replace-regexp by default). Use \[guid_here] as the regexp to search for and [\,(upcase (uuid-string))] as the replacement text.


2

I'm going to use the function found here. (defun increment-number-at-point () (interactive) (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) (replace-match (number-to-string (1+ (string-to-number (match-string 0)))))) For a quick solution, I would use a macro. This is appropriate if you only need to do it a ...


2

Use a regular expression replacement with a bit of Lisp code. In the replacement text, you can use \,(…) to execute some Lisp code, and you can use \# as the number of replacements made so far. So \,(+ 2 \#) will be become successively 2, 3, 4, … in successive replacements. Thus, use C-M-% or M-x replace-regexp to replace \("id": \)[0-9]+ with \1\,(+ 2 \#)


1

What language are you trying to use, and where/how are you trying to use it? If you are trying to evaluate subscr({a,b,c,d,e,f,h},{1,2,3}) as Lisp (which it seems you are) then there are a few things wrong. First, subscr is evaluated as a variable, not a function. If it's not bound as a Lisp variable then you should get an error saying that. Second, the ...


1

(random t) ; seed it randomly (defun my-random-number-insert-at-point () "Insert at point a four-digit random number between 0000 to 1000." (interactive) (insert (number-to-string (random 100))))


1

Maybe no so elegant but should do the trick. Note I have assigned it to "C-." which might be used by other functions in your setup. Reassign as you wish: (defun hexify() (interactive) (setq hx (format "%x" (char-before))) (delete-backward-char 1) (insert hx)) (global-set-key (kbd "C-.") 'hexify) Calling the function, replaces the character before ...


Only top voted, non community-wiki answers of a minimum length are eligible