I need to write a command which will apply to my buffer custom, predefined copy-and-replace sequence.
What I have is:
(defun custom-processor () "Formats logs to human-readable format" ((replace-in-the-buffer "\n" "\n\n\n") (replace-in-the-buffer "\t" "\n"))) (defun replace-in-the-buffer (from to) "Replaces in the current buffer all occurences of from to to (not interactively)" (while (re-search-forward from nil t) (replace-match to nil nil)))
It is basically working for simple characters like letters or numbers, but the case is I need to use it with new lines (
\n) and tabs (
\t) - the error I get is:
Debugger entered--Lisp error: (invalid-function (replace-in-the-buffer "\n" "\n\n\n")) ((replace-in-the-buffer "\n" "\n\n\n") (replace-in-the-buffer "\011" "\n")) custom-processor() eval((custom-processor) nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp)
I use EMACS for 10y+ but now just starting to leverage it with Lisp programming. Please help.