I want to use C-u M-:, then (format-time-string "%m/%d/%Y")
to insert a customized date string. But it is inserted into the current buffer with double quotes.
Any trick to remove these quotes?
I want to use C-u M-:, then (format-time-string "%m/%d/%Y")
to insert a customized date string. But it is inserted into the current buffer with double quotes.
Any trick to remove these quotes?
Rather than ask M-: to insert the output of the Elisp code, just write the Elisp code that inserts the text you want:
Try M-: (insert (format-time-string "%m/%d/%Y")) RET
I think you should not change M-: for this. I have setup C-c + to call the vicarie/eval-replace-last-sexp
defined below. So, I just type (format-time-string "%Y/%m/%d")
and do C-c +
.
(defun vicarie/eval-last-sexp-and-do (f)
"Eval the last sexp and call F on its value."
(let ((standard-output (current-buffer))
(value (eval-last-sexp nil)))
(funcall f value)))
(defun vicarie/eval-print-last-sexp ()
"Evaluate and print the last sexp on the same line."
(interactive)
(vicarie/eval-last-sexp-and-do (lambda (value)
(insert (format " (= %s ) " value)))))
(defun vicarie/eval-replace-last-sexp ()
"Evaluate and replace last sexp with its value."
(interactive)
(vicarie/eval-last-sexp-and-do (lambda (value)
(backward-kill-sexp)
(insert (format "%s" value)))))