From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: terminal command with output in current buffer
Date: Tue, 20 Jul 2021 01:12:14 +0200 [thread overview]
Message-ID: <87wnpl290x.fsf@zoho.eu> (raw)
In-Reply-To: jwvwnpm9a61.fsf-monnier+emacs@gnu.org
Stefan Monnier via Users list for the GNU Emacs text editor wrote:
>> (let*((read-result (read-from-minibuffer "Prompt: "))
>
> Please don't use `read-from-minibuffer` unless you're
> defining a `read-<foo>` function. Use `read-string` instead.
OK, thanks, 5 places to fix...
I wonder what the last function, "replace-regexp-1" is
supposed to do, what the -1 means, and what sets it apart
from what should be there already, is what I'm thinking ... or
am I wrong?
;; in https://dataswamp.org/~incal/emacs-init/edit.el ...
(defun insert-string-centered (str &optional width)
(interactive
(list (read-string "string: ")
(read-number "width: " (window-text-width) ) ))
(let*((span (if (and width (< 0 width)) width (window-text-width)))
(str-len (length str))
(pad (- (/ (- span str-len) 2)
(if (zerop (mod str-len 2)) 1 0) ))
(pad-str (make-string pad ?\s)) )
(insert pad-str str) ))
(defalias 'isc #'insert-string-centered)
;; https://dataswamp.org/~incal/emacs-init/time-cmp.el
(defun dope (from boxes pills dose)
(interactive
(list
(read-string "from: " (format-time-string "%F"))
(read-number "boxes: ")
(read-number "pills/box: " 50)
(read-number "pills/day: " 6) ))
(let*((days (/ (* boxes pills) dose))
(done (time-add (date-to-time (format "%sT00:00+01:00" from))
(days-to-time (1- days)) ))
(str (format-time-string "%F" done))
(more (format-time-string "%F" (time-add done (days-to-time -10)))) )
(insert (format "%s [%s] %s" from more str) )))
;; https://dataswamp.org/~incal/emacs-init/sort-incal.el
(defun sort-line-words (beg end &optional set-delim)
(interactive "r\nP")
(let*((str (region-to-string))
(delim-str (when set-delim (read-string "delimiter: ")))
(str-list (split-string str delim-str))
(sorted (erc-sort-strings str-list)) )
(kill-region beg end)
(if set-delim
(progn
(dolist (s (nreverse (cdr (nreverse sorted))))
(insert (format "%s%s" s delim-str)))
(insert (format "%s" (car (last sorted)))))
(insert-string-list sorted) )))
;; https://dataswamp.org/~incal/emacs-init/latex.el
(defun replace-regexp-1 (regexp to-string &optional beg end)
(interactive
`(,(read-string "regexp: ")
,(read-string "to string: ")
,@(if (use-region-p)
(list (region-beginning) (region-end))
(list (point-min) (point-max))) ))
(let ((beg-set (or beg (point-min)))
(end-set (or end (point-max))) )
(save-excursion
(goto-char end-set)
(while (re-search-backward regexp beg-set t)
(replace-match to-string) ))))
(defalias 'rr #'replace-regexp-1)
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2021-07-19 23:12 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-16 6:43 Run terminal command with output in current buffer lisa-asket
2021-07-16 6:53 ` Jean-Christophe Helary
2021-07-16 7:07 ` Eli Zaretskii
2021-07-16 9:04 ` lisa-asket
2021-07-16 11:32 ` Eli Zaretskii
2021-07-16 11:48 ` lisa-asket
2021-07-16 11:30 ` lisa-asket
2021-07-16 11:58 ` lisa-asket
2021-07-16 15:14 ` Felix Dietrich
2021-07-16 15:21 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-16 15:44 ` lisa-asket
2021-07-16 16:32 ` Felix Dietrich
2021-07-16 17:00 ` lisa-asket
2021-07-16 19:35 ` Felix Dietrich
2021-07-16 19:48 ` lisa-asket
2021-07-16 21:58 ` Felix Dietrich
2021-07-17 5:58 ` lisa-asket
2021-07-17 9:09 ` terminal command with output in current buff lisa-asket
2021-07-17 9:19 ` lisa-asket
2021-07-17 11:33 ` Felix Dietrich
2021-07-19 1:10 ` terminal command with output in current buffer Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-19 4:54 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-19 23:12 ` Emanuel Berg via Users list for the GNU Emacs text editor [this message]
2021-07-20 12:05 ` ‘read-string’ over ‘read-from-minibuffer’ Felix Dietrich
2021-07-20 15:11 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-20 15:46 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-20 12:55 ` terminal command with output in current buffer Felix Dietrich
2021-07-20 18:15 ` Yuri Khan
2021-07-20 18:23 ` lisa-asket
2021-07-16 16:36 ` Run " Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-16 17:24 ` lisa-asket
2021-07-16 18:01 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-16 18:07 ` lisa-asket
2021-07-16 18:04 ` lisa-asket
2021-07-19 0:42 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-19 4:49 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-07-19 20:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-16 15:22 ` lisa-asket
2021-07-16 13:25 ` Felix Dietrich
2021-07-16 13:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-16 14:28 ` lisa-asket
2021-07-16 15:06 ` lisa-asket
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnpl290x.fsf@zoho.eu \
--to=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.