From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: terminal command with output in current buffer Date: Tue, 20 Jul 2021 01:12:14 +0200 Message-ID: <87wnpl290x.fsf@zoho.eu> References: <87czrip6db.fsf@sperrhaken.name> <877dhqoxw6.fsf@sperrhaken.name> <87tukr3y7f.fsf@zoho.eu> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33176"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:fP6xkGCaQMAsq+aggYojxzaZVJw= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 20 01:14:28 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5cSy-0008Oa-4y for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 20 Jul 2021 01:14:28 +0200 Original-Received: from localhost ([::1]:49468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5cSx-0001as-6n for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Jul 2021 19:14:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5cR4-0007y0-3i for help-gnu-emacs@gnu.org; Mon, 19 Jul 2021 19:12:30 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:45052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5cR2-0004xw-FJ for help-gnu-emacs@gnu.org; Mon, 19 Jul 2021 19:12:29 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1m5cQz-00060d-NH for help-gnu-emacs@gnu.org; Tue, 20 Jul 2021 01:12:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 2 X-Spam_score: 0.2 X-Spam_bar: / X-Spam_report: (0.2 / 5.0 requ) HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131860 Archived-At: 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-` 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