all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 21468@debbugs.gnu.org
Subject: bug#21468: 24.5; When next-line (visual) crosses overlay with before-string="\n" point goes to column 0
Date: Thu, 1 Oct 2015 16:43:11 -0400	[thread overview]
Message-ID: <CAM-tV-_g2G4JEiKP_3awvyPU1f+Zsu_g06nVDw2AdhNyA2Uj1A@mail.gmail.com> (raw)
In-Reply-To: <83r3m0896l.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]

On Tue, Sep 15, 2015 at 2:53 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> I think you should be able to extend the face by using a display
> property with :align-to value.  The value should be computed to go all
> the way to the edge of the window.

We tried something like this:

(let ((align `(space :align-to (+ (,(window-body-width nil t))
                                  ,(window-hscroll)))))
  (ov rbeg eol 'face (list :overline color)
      'after-string (propertize "\s" 'face face 'display align)))

But when moving point to end of line this causes the cursor to appear
at the edge of the window instead of at the "real" end of line. I
guess it's because the aligned space pushes the newline character to
the edge of the window.

For a self-contained example do "emacs -Q overlay.el -f eval-buffer -f
set-mark-command -f move-end-of-line" with attached overlay.el.


> I cannot do anything about these issues besides explaining how they
> harm Emacs maintenance, and asking people to look for alternative
> solutions.

Well you *could* refuse to fix bugs like this, i.e. declare that
creating overlays with newlines invokes undefined behaviour. As it
stands, the best way to get the effect we want is to use an overlayed
newline, especially now that you've fixed this bug.

[-- Attachment #2: overlay.el --]
[-- Type: application/octet-stream, Size: 1763 bytes --]

(require 'cl-lib)

(defvar-local magit-region-overlays nil)

(defun 21468-update-hunk-region (start end window rol)
  (mapc #'delete-overlay magit-region-overlays)
  (cl-flet ((ov (start end &rest args)
                (let ((ov (make-overlay start end nil t)))
                  (while args (overlay-put ov (pop args) (pop args)))
                  (push ov magit-region-overlays)
                  ov)))
    (let* ((align (list 'space :align-to `(+ (,(window-body-width nil t))
                                             ,(window-hscroll))))
           (rbeg-line (save-excursion (goto-char start)
                                      (cons (line-beginning-position)
                                            (line-end-position))))
           (rend-line (save-excursion (goto-char end)
                                      (cons (line-beginning-position)
                                            (line-end-position))))
           (color (face-background 'highlight nil t))
           (face  (list :overline color :underline color)))
      (if (equal rbeg-line rend-line)
          (ov (car rbeg-line) (cdr rbeg-line) 'face face
              'after-string (propertize "\s" 'face face 'display align))
        (ov (car rbeg-line) (cdr rbeg-line) 'face (setq face (list :overline color))
            'after-string (propertize "\s" 'face face 'display align))
        (ov (car rend-line) (cdr rend-line) 'face (setq face (list :underline color))
            'after-string (propertize "\s" 'face face 'display align))))))

(setq-local redisplay-highlight-region-function '21468-update-hunk-region)

(setq-local redisplay-unhighlight-region-function
            (lambda (rol) (mapc #'delete-overlay magit-region-overlays)))

  reply	other threads:[~2015-10-01 20:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-13  5:17 bug#21468: 24.5; When next-line (visual) crosses overlay with before-string="\n" point goes to column 0 Noam Postavsky
2015-09-13 10:30 ` Eli Zaretskii
2015-09-13 17:20   ` Noam Postavsky
2015-09-13 19:50     ` Eli Zaretskii
2015-09-13 20:22       ` Noam Postavsky
2015-09-14  6:17         ` Eli Zaretskii
2015-09-14 12:46           ` Noam Postavsky
2015-09-14 13:22             ` Stefan Monnier
2015-09-14 13:33             ` Eli Zaretskii
2015-09-14 13:55               ` Noam Postavsky
2015-09-14 15:14                 ` Eli Zaretskii
2015-09-14 20:50                   ` Noam Postavsky
2015-09-15  6:53                     ` Eli Zaretskii
2015-10-01 20:43                       ` Noam Postavsky [this message]
2015-10-02 10:01                         ` Eli Zaretskii
2015-10-02 19:58                           ` Noam Postavsky
2015-10-02 21:00                             ` Eli Zaretskii
2015-10-09 23:34                               ` Noam Postavsky
2015-10-10  7:14                                 ` Eli Zaretskii
2015-10-10 13:37                                   ` Noam Postavsky
2015-10-10 14:20                                     ` Eli Zaretskii
2015-10-10 16:51                                       ` Noam Postavsky
2015-10-10 17:09                                         ` Eli Zaretskii
2015-10-10 21:06                                           ` Noam Postavsky
2015-10-11  2:38                                             ` Eli Zaretskii
2015-10-10 17:03                                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM-tV-_g2G4JEiKP_3awvyPU1f+Zsu_g06nVDw2AdhNyA2Uj1A@mail.gmail.com \
    --to=npostavs@users.sourceforge.net \
    --cc=21468@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.