emacs - How to call query-replace-regexp inside a function? -


i tend use query-replace-regexp on entire buffer rather @ current position regularly use sequence c-< (beginning-of-buffer), c-r (query-replace-repexp).

i'd make function bound c-s-r (c-r) me. thought if wrapped such as:

(defun query-replace-regexp-whole-buffer ()   "query-replace-regexp beginning of buffer."   (interactive)   (beginning-of-buffer)   (query-replace-regexp)) 

that adequate, unfortunately though i'm getting errors.

query-replace-regexp-whole-buffer: wrong number of arguments: #[(regexp to-string &optional delimited start end) "Å Æ Ç&  " [regexp to-string delimited start end perform-replace t nil] 10 1940879 (let ((common (query-replace-read-args (concat "query replace" (if current-prefix-arg " word" "") " regexp" (if (and transient-mark-mode mark-active) " in region" "")) t))) (list (nth 0 common) (nth 1 common) (nth 2 common) (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end))))], 0 

i can't see i'm doing wrong, can help.

when called lisp, query-replace-regexp expects passed regular expression , intended replacement arguments. if want emulate questions asked when invoked interactively, need use call-interactively:

(defun query-replace-regexp-whole-buffer ()   "query-replace-regexp beginning of buffer."   (interactive)   (goto-char (point-min))   (call-interactively 'query-replace-regexp)) 

also note 1 should never call beginning-of-buffer lisp code; unnecessary work, such pushing mark , printing message.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -