[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(string-rectangle (point-min) (point-max) "% ") behaves different in GNU
From: |
Uwe Brauer |
Subject: |
(string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs |
Date: |
Fri, 19 Feb 2016 13:21:28 +0000 |
User-agent: |
Gnus/5.13001 (Ma Gnus v0.10) Emacs/25.1.50 (gnu/linux) |
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
- (string-rectangle (point-min) (point-max) "% ") behaves different in GNU and Xemacs,
Uwe Brauer <=