bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point


From: Noam Postavsky
Subject: bug#25777: 25.1; [PATCH] `rectangle--pos-cols' should not move point
Date: Mon, 27 Feb 2017 14:47:57 -0500

On Mon, Feb 27, 2017 at 2:21 PM, Drew Adams <address@hidden> wrote:
> 2. The purpose of `rectangle--pos-cols', just as was the purpose
> of the previous (Emacs 24.5) code, is to return the rectangle
> columns.  Nothing more.  Its purpose is not to move point and
> leave it in some other place that is not a rectangle corner.

The code you extracted in 24.5 is (modulo a few dropped lines)

    (save-excursion
      (goto-char start)
      (setq startcol (current-column))
      (beginning-of-line)
      (setq startpt (point)) ;; [dropped in modeline-posn]
      (goto-char end)
      (setq endcol (current-column))
      (forward-line 1) ;; [dropped in modeline-posn]
      (setq endpt (point-marker)) ;; [dropped in modeline-posn]
      ;; ensure the start column is the left one.
      (if (< endcol startcol)
      (let ((col startcol))
        (setq startcol endcol endcol col)))


The equivalent in 25.1 is

  (save-excursion
    (let* ((cols (rectangle--pos-cols start end))
           (startcol (car cols))
           (endcol (cdr cols))

But for some reason you don't want to extract the save-excursion from 25.1.

>
> 3. `rectangle--pos-cols' is a general function.  It should not
> be considered internal.  It is useful generally - I have
> reused it, as one example.  (I have not used `apply-on-rectangle'.)
>
> Is there a reason to have `rectangle--pos-cols' move point,
> instead of use `save-excursion'?

I don't want to add unneeded clutter.

> What's the argument in
> favor of not having this code be as clean as it was in Emacs
> 24.5?  Why favor this regression?

It's clearly not a regression.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]