From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Uwe Brauer Newsgroups: gmane.emacs.devel Subject: (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs Date: Fri, 19 Feb 2016 13:21:28 +0000 Message-ID: <8760xkesyv.fsf@mat.ucm.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1455888122 6286 80.91.229.3 (19 Feb 2016 13:22:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Feb 2016 13:22:02 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 19 14:21:53 2016 Return-path: Envelope-to: ged-emacs-devel@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 1aWl0G-00016J-PP for ged-emacs-devel@m.gmane.org; Fri, 19 Feb 2016 14:21:48 +0100 Original-Received: from localhost ([::1]:52225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWl0G-00080h-0g for ged-emacs-devel@m.gmane.org; Fri, 19 Feb 2016 08:21:48 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWl0B-0007x8-1X for emacs-devel@gnu.org; Fri, 19 Feb 2016 08:21:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWl07-0007N3-RQ for emacs-devel@gnu.org; Fri, 19 Feb 2016 08:21:42 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:59313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWl07-0007Mx-Ka for emacs-devel@gnu.org; Fri, 19 Feb 2016 08:21:39 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aWl04-0000wG-PJ for emacs-devel@gnu.org; Fri, 19 Feb 2016 14:21:36 +0100 Original-Received: from gilgamesch.quim.ucm.es ([147.96.12.99]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Feb 2016 14:21:36 +0100 Original-Received: from oub by gilgamesch.quim.ucm.es with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Feb 2016 14:21:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 80 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: gilgamesch.quim.ucm.es Mail-Copies-To: never User-Agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:ZL3mJlXvuiZsKs2dWYA310Ht9i8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200209 Archived-At: Hi The documentation of that string-rectangle says ,---- | | Replace rectangle contents with STRING on each line. | The length of STRING need not be the same as the rectangle width. `---- But: when I mark a region and call string-rectangle I obtain % Again when I mark a region and call string-rectangle But *not* % Therefore I tried out the the following function in matlab mode. (defun my-matlab-insert-simple-raw () "Change and insert the content of the *Matlab Help* buffer. (Sometimes invoked with `matlab-shell-run-command'.) `kill-empty-lines' put all results in one line, and `comment' them out according to the `matlab' syntax." (interactive) (save-excursion (let ((currentname (current-buffer))) (switch-to-buffer "*MATLAB Help*") (toggle-read-only nil) (goto-char (point-min)) (delete-empty-lines-region (point-min) (point-max)) (goto-char (point-max)) (delete-backward-char 1 nil) (goto-char (point-min)) (while (re-search-forward "=" nil t) (kill-line nil)) (goto-char (point-min)) (string-rectangle (point-min) (point-max) "% ") (switch-to-buffer currentname) (insert-buffer "*MATLAB Help*")))) This works fine in Xemacs and inserts a line such as % s=5 In the buffer of question. In GNU emacs however string-rectangle behaves differently: it puts the % at the beginning of the line but deletes the rest! I debugged the function and the result of (string-rectangle (point-min) (point-max) "% ") In my example was: Result: 3 (#o3, #x3, ?\C-c) while in Xemacs it was a simple nil. Meanwhile I found another solution which allows me to do what I want, but I would like to understand why (string-rectangle (point-min) (point-max) "% ") behaves differently in GNU emacs from Xemacs, and how could I nevertheless use this function without deletion. Uwe Brauer