emacs-devel
[Top][All Lists]
Advanced

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

Re: [External] : Re: Emacs Survey: Toolbars


From: Stefan Monnier
Subject: Re: [External] : Re: Emacs Survey: Toolbars
Date: Fri, 26 Feb 2021 11:27:20 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> By "inside the window's text" do you mean anywhere
> within it, so for example a user could move it

I don't know what other people mean, but what I'm thinking of is
reflected in the chunk of code below I started writing some years ago.
You can `insert` the result into the buffer to put a toolbar wherever
you want (don't expect miracles: it has loads of shortcomings).


        Stefan


(defun tool-bar-to-string (&optional map)
  (let ((res ""))
    (map-keymap
     (lambda (k v)
       (when (eq (car v) 'menu-item)
         (let* ((name (nth 1 v))            ;Unused, AFAICT.
                (cmd (nth 2 v))
                (plist (nthcdr (if (consp (nth 3 v)) 4 3) v))
                (help-echo (plist-get plist :help))
                (image     (plist-get plist :image))
                (button (propertize " " 'help-echo help-echo
                                    'keymap (let ((map (make-sparse-keymap)))
                                              (define-key map [mouse-1] cmd)
                                              map)
                                    'face 'tool-bar ;; 'custom-button
                                    'mouse-face 'custom-button-mouse
                                    'rear-nonsticky '(display keymap help-echo)
                                    'display image)))
           (setq res (concat res (propertize " " 'display '(space :width 1)
                                             'face 'custom-button
                                             )
                             button)))))
     (or map (key-binding [tool-bar])))
    res))




reply via email to

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