From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: replace-regexp, the byte-compiler, docstrings, and suggestions Date: Sun, 12 Oct 2014 20:28:51 +0200 Organization: Aioe.org NNTP Server Message-ID: <874mv9uopo.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1413138625 27613 80.91.229.3 (12 Oct 2014 18:30:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Oct 2014 18:30:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 12 20:30:18 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XdNuK-0003FE-CR for geh-help-gnu-emacs@m.gmane.org; Sun, 12 Oct 2014 20:30:16 +0200 Original-Received: from localhost ([::1]:58148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdNuJ-0007A7-WC for geh-help-gnu-emacs@m.gmane.org; Sun, 12 Oct 2014 14:30:16 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 76 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:EWqVljK9fcOm779H12ujW0Niirk= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:208175 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100451 Archived-At: First I wrote this: (defun block-cite () "Add four spaces to each line in the region." (interactive) (if mark-active (replace-regexp "^" " " nil (region-beginning) (region-end)) )) Then the byte-compiler told me: In block-cite: gnus/message-my.el:39:7:Warning: `replace-regexp' used from Lisp code That command is designed for interactive use only So I checked out the help for `replace-regexp': This function is usually the wrong thing to use in a Lisp program. What you probably want is a loop like this: (while (re-search-forward REGEXP nil t) (replace-match TO-STRING nil nil)) which will run faster and will not set the mark or print anything. And I wrote: (defun replace-regexp-quiet (regexp to-string start end) (save-excursion (goto-char start) (while (re-search-forward regexp end t) ; NOERROR (replace-match to-string) ))) And the byte-compiler is happy! Question: Is there already a block-cite function? I want it to make nice looking citations and blocks of data in Usenet posts and mails. (Actually I would call them quotes outright only that is spoken for already in that context.) As for source code, I'm not entirely sure what is best practice. The block makes it easier to read but after a copy/paste (kill/yank), it wouldn't look the same instantly compared to the source itself (most often). So I think I'll use it for short code-blocks but for longer I'll refer to the complete source file. I'm opposed to the copy/paste culture but I'm also altruistic/practical (not to mention modest) so this is a intricate trade-off... Suggestions: 1. If there isn't a block-cite (or whatever), there should be one. 2. Instead of the note in the docstring for `replace-regexp', why don't you do an interface (like I did) and refer to that? (Both in the docstring and when byte-compiling.) The explanation why can still be there, of course. 3. In the docstring for `re-search-forward', the arguments aren't mentioned explicitly which makes them hard to find (actually they are not that difficult to find - it is rather that if they are not mentioned explicitely, they don't get `help-argument-face', so then you *think* they are not mentioned and you don't bother looking). I will send all this as a bug report but I thought I'd tell you first and if there are discussion I will include any new "leads" which will perhaps make the bug report even more to the point. -- underground experts united