help-emacs-windows
[Top][All Lists]
Advanced

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

[h-e-w] help-echo: recommended changes to control of help-echo


From: Richard M. Heiberger
Subject: [h-e-w] help-echo: recommended changes to control of help-echo
Date: Fri, 23 Nov 2001 02:55:13 -0500 (EST)

help-echo: recommended changes to control of help-echo

I find the help-echo in dired buffers to be very annoying.
When dired queries me about overwriting a file I do not see the 
query because the help-echo is telling me about clicking on the file name.
Moving the mouse is not a satisfactory solution.  Since the help-echo is
a constant in dired buffers I decided to turn it off.

I added the following to my .emacs
(load-library "dired-help-echo.el")
(setq dired-help-echo nil)
(load-library "buff-menu-help-echo.el")
(setq buff-menu-help-echo nil)
(load-library "show-help-echo.el")     ;; toggle help-echo globally


There are three sets of functions and variables here.
I offer them to be included in emacs.

buffer-menu-help-echo         M-x buffer-menu-help-echo RET
  Command: Toggle `buffer-menu-help-echo'.
dired-help-echo               M-x dired-help-echo RET
  Command: Toggle `dired-help-echo'.
show-help-function            M-x show-help-function RET
  Command: Change the behavior of the help-echo.  Without an ARG, toggle

--------dired-help-echo.el------
;;; based on dired.el

(defvar dired-help-echo t
  "If t, then display `help-echo' in dired buffers.
If nil, then do not display `help-echo' in dired-buffers.")

(defun dired-help-echo (&optional arg)
  "Toggle `dired-help-echo'.
With arg, turn `dired-help-echo' on if arg is non-nil, off
otherwise.  The change takes effect when the dired buffer is refreshed.
See the command `dired-insert-set-properties' for more information."
  (interactive "P")
  (setq dired-help-echo
        (if (null arg) (not dired-help-echo)
          (not (not arg)))))

(defun dired-insert-set-properties (beg end)
  "Make the file names highlight when the mouse is on them.
If dired-help-echo, then also place message in echo area."
  (save-excursion
    (goto-char beg)
    (while (< (point) end)
      (condition-case nil
          (if (dired-move-to-filename)
              (add-text-properties
               (point)
               (save-excursion
                 (dired-move-to-end-of-filename)
                 (point))
               (if dired-help-echo
                   '(mouse-face highlight
                     help-echo "mouse-2: visit this file in other window")
                 '(mouse-face highlight))))
        (error nil))
      (forward-line 1))))
--------------------------------
--------buff-menu-help-echo.el------
;;; recommended changes to buff-menu.el to put the help-echo under control

(defvar buffer-menu-help-echo t
  "If t, then display `help-echo' in buffer-menu buffers.
If nil, then do not display `help-echo' in buffer-menu buffers.")

(defun buffer-menu-help-echo (&optional arg)
  "Toggle `buffer-menu-help-echo'.
With arg, turn `buffer-menu-help-echo' on if arg is non-nil, off
otherwise.  The change takes effect when the buffer-menu buffer is refreshed.
See the command `list-buffer-no-select' for more information."
  (interactive "P")
  (setq buffer-menu-help-echo
        (if (null arg) (not buffer-menu-help-echo)
          (not (not arg)))))

(defun list-buffers-noselect (&optional files-only)
  "Create and return a buffer with a list of names of existing buffers.
The buffer is named `*Buffer List*'.
Note that buffers with names starting with spaces are omitted.
Non-null optional arg FILES-ONLY means mention only file buffers.

The M column contains a * for buffers that are modified.
The R column contains a % for buffers that are read-only."
  (let ((old-buffer (current-buffer))
        (standard-output standard-output)
        desired-point)
    (save-excursion
      (set-buffer (get-buffer-create "*Buffer List*"))
      (setq buffer-read-only nil)
      (erase-buffer)
      (setq standard-output (current-buffer))
      (princ "\
 MR Buffer           Size  Mode         File
 -- ------           ----  ----         ----
")
      ;; Record the column where buffer names start.
      (setq Buffer-menu-buffer-column 4)
      (dolist (buffer (buffer-list))
        (let ((name (buffer-name buffer))
              (file (buffer-file-name buffer))
              this-buffer-line-start
              this-buffer-read-only
              (this-buffer-size (buffer-size buffer))
              this-buffer-mode-name
              this-buffer-directory)
          (with-current-buffer buffer
            (setq this-buffer-read-only buffer-read-only
                  this-buffer-mode-name mode-name)
            (unless file
              ;; No visited file.  Check local value of
              ;; list-buffers-directory.
              (when (and (boundp 'list-buffers-directory)
                         list-buffers-directory)
                (setq this-buffer-directory list-buffers-directory))))
          (cond
            ;; Don't mention internal buffers.
            ((string= (substring name 0 1) " "))
            ;; Maybe don't mention buffers without files.
            ((and files-only (not file)))
            ((string= name "*Buffer List*"))
            ;; Otherwise output info.
            (t
             (setq this-buffer-line-start (point))
             ;; Identify current buffer.
             (if (eq buffer old-buffer)
                 (progn
                   (setq desired-point (point))
                   (princ "."))
               (princ " "))
             ;; Identify modified buffers.
             (princ (if (buffer-modified-p buffer) "*" " "))
             ;; Handle readonly status.  The output buffer is special
             ;; cased to appear readonly; it is actually made so at a
             ;; later date.
             (princ (if (or (eq buffer standard-output)
                            this-buffer-read-only)
                        "% "
                      "  "))
             (princ name)
             ;; Put the buffer name into a text property
             ;; so we don't have to extract it from the text.
             ;; This way we avoid problems with unusual buffer names.
             (setq this-buffer-line-start
                   (+ this-buffer-line-start Buffer-menu-buffer-column))
             (let ((name-end (point)))
               (indent-to 17 2)
               (put-text-property this-buffer-line-start name-end
                                  'buffer-name name)
               (put-text-property this-buffer-line-start (point)
                                  'buffer buffer)
               (put-text-property this-buffer-line-start name-end
                                  'mouse-face 'highlight)
               (if buffer-menu-help-echo
                   (put-text-property
                    this-buffer-line-start name-end
                    'help-echo "mouse-2: select this buffer")))
             (let ((size (format "%8d" this-buffer-size))
                   (mode this-buffer-mode-name)
                   (excess (- (current-column) 17)))
               (while (and (> excess 0) (= (aref size 0) ?\ ))
                 (setq size (substring size 1)
                       excess (1- excess)))
               (princ size)
               (indent-to 27 1)
               (princ mode))
             (indent-to 40 1)
             (or file (setq file this-buffer-directory))
             (when file
               (princ (abbreviate-file-name file)))
             (princ "\n")))))
      (Buffer-menu-mode)
      ;; DESIRED-POINT doesn't have to be set; it is not when the
      ;; current buffer is not displayed for some reason.
      (and desired-point
           (goto-char desired-point))
      (current-buffer))))
------------------------------------
--------show-help-echo.el------
;;; show-help-function.el

;; (setq show-help-function 'null)             ; help-echo is suppressed
;; (setq show-help-function 'intercepted-help) ; user-written help-echo
;; (setq show-help-function nil)               ; default: help-echo is on

(defun show-help-function (&optional arg)
  "Change the behavior of the help-echo.  Without an ARG, toggle
`show-help-function' variable between nil and `null'.  When
`show-help-function' is non-nil, then set it to nil.  With an ARG, set
`show-help-function' to ARG, which must be a symbol for an interactive
function.  Interactively, use a prefix argument to make
`show-help-function' prompt for an ARG."
  (interactive "P")
  (if arg (setq arg (read-command "help function: ")))
  (setq show-help-function
        (if (not (null arg))
            arg
          (if show-help-function
              nil
            'null))))


;; (defun intercepted-help (x)
;;   "Sample function to use in `show-help-function'." 
;;   (interactive)
;;   (message (concat "intercepted: " x)))
------------------------------------

Rich



reply via email to

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