all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: michael_heerdegen@web.de, emacs-devel@gnu.org
Subject: Re: face vs. mouse-face text property
Date: Mon, 23 Jan 2012 09:27:36 -0500	[thread overview]
Message-ID: <jwvvco2h51v.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1RpDhu-0003VC-FW@fencepost.gnu.org> (Eli Zaretskii's message of "Mon, 23 Jan 2012 01:48:46 -0500")

> Therefore, I think if we want to be able to display selectable
> newlines, we need to have a special way to display such newlines,
> e.g. "<NL>" or some such.

I'd suggest \n rather than <NL>, since it's already used at many other
places in Emacs (tho it's not often visible to the "end user").

There are other similar issues in the *Completions* lists if you have
completions which start/end with spaces or tabs, are very long, or worse
only contain spaces or tabs: while the mouse-over will be reasonably
clear, the list is far from clear if you don't move your mouse over it
to see the exact boundaries.

Currently, completions are used for entities which typically don't
suffer from such issues.  But if we want to use it for things like
yank-browse (see sample code below), we need to make it handle such
cases a bit better.


        Stefan


(defun yank-browse (string)
  "Browse the `kill-ring' to choose which entry to yank."
  (interactive
   (minibuffer-with-setup-hook #'minibuffer-completion-help
     (let* ((kills (delete-dups (append kill-ring-yank-pointer kill-ring nil)))
            (entries
             (mapcar (lambda (string)
                       (let ((pos 0))
                         ;; FIXME: Maybe we should start by removing
                         ;; all properties.
                         (setq string (copy-sequence string))
                         (while (string-match "\n" string pos)
                           ;; FIXME: Maybe completion--insert-strings should
                           ;; do that for us.
                           (put-text-property
                            (match-beginning 0) (match-end 0)
                            'display (eval-when-compile
                                       (propertize "\\n" 'face 'escape-glyph))
                            string)
                           (setq pos (match-end 0)))
                         ;; FIXME: We may use the window-width of the
                         ;; wrong window.
                         (when (>= (* 3 (string-width string))
                                   (* 2 (window-width)))
                           (let ((half (- (/ (window-width) 3) 1)))
                             ;; FIXME: We're using char-counts rather than
                             ;; width-count.
                             (put-text-property
                              half (- (length string) half)
                              'display (eval-when-compile
                                         (propertize "……" 'face 'escape-glyph))
                              string)))
                         string))
                     kills))
            (table (lambda (string pred action)
                     (cond
                      ((eq action 'metadata)
                       '(metadata (category . kill-ring)))
                      (t
                       (complete-with-action action entries string pred))))))
       ;; FIXME: We should return the entry from the kill-ring rather than
       ;; the entry from the completion-table.
       ;; FIXME: substring completion doesn't work well because it only matches
       ;; subtrings before the first \n.
       ;; FIXME: completion--insert-strings assumes that boundaries of
       ;; candidates are obvious enough, but with kill-ring entries this is not
       ;; true, so we'd probably want to display them with «...» around them.
       (list (completing-read "Yank: " table nil t)))))
  (setq this-command 'yank)
  (insert-for-yank string))



  reply	other threads:[~2012-01-23 14:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-18 21:34 face vs. mouse-face text property Michael Heerdegen
2012-01-19  7:20 ` Chong Yidong
2012-01-19 12:19 ` Eli Zaretskii
2012-01-20 20:18   ` Michael Heerdegen
2012-01-21 10:09     ` Eli Zaretskii
2012-01-22 22:21       ` Michael Heerdegen
2012-01-23  6:48         ` Eli Zaretskii
2012-01-23 14:27           ` Stefan Monnier [this message]
2012-01-23 14:43             ` Lennart Borgman
2012-01-23 15:34               ` Stefan Monnier
2012-01-23 15:40                 ` Lennart Borgman
2012-01-23 18:47                   ` chad
2012-01-23 20:44                     ` Eli Zaretskii
2012-01-23 21:09                       ` chad
2012-01-24  3:48                         ` Eli Zaretskii
2012-01-24  5:55                           ` Eli Zaretskii
2012-01-24  7:04                             ` chad
2012-01-24  9:11                               ` Eli Zaretskii
2012-01-24 11:14                                 ` chad
2012-01-24 15:01                     ` Stefan Monnier
2012-01-24 16:49                     ` Richard Stallman

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=jwvvco2h51v.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.