unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs
@ 2016-02-19 13:21 Uwe Brauer
  2016-02-19 13:28 ` [SOLVED] (was: (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs) Uwe Brauer
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Brauer @ 2016-02-19 13:21 UTC (permalink / raw)
  To: emacs-devel



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 






^ permalink raw reply	[flat|nested] 2+ messages in thread

* [SOLVED] (was: (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs)
  2016-02-19 13:21 (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs Uwe Brauer
@ 2016-02-19 13:28 ` Uwe Brauer
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Brauer @ 2016-02-19 13:28 UTC (permalink / raw)
  To: emacs-devel

>>> "Uwe" == Uwe Brauer <oub@mat.ucm.es> writes:

   > Hi


I just found out that rect.el has a (new) function
string-insert-rectangle
which behaves like the old string-rectangle in Xemacs.

Sorry for the noise.

Uwe Brauer 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-19 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 13:21 (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs Uwe Brauer
2016-02-19 13:28 ` [SOLVED] (was: (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs) Uwe Brauer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).