[Top][All Lists]

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

bug#15861: 24.3.50; lots of byte-compiler code written to *Messages* at

From: Drew Adams
Subject: bug#15861: 24.3.50; lots of byte-compiler code written to *Messages* at runtime
Date: Mon, 11 Nov 2013 11:30:02 -0800 (PST)

The subject line might not be the best description.  And you might not
see that this is a bug.  In that case, please let me know how to work
around the behavior I see, as it is quite annoying.

In a Lisp file that I byte-compile and load, I have a redefinition of
`ls-lisp--insert-directory'.  (I do not see another, better way to
accomplish the behavior change I need.)  I added this when vanilla Emacs
was changed recently to use this function.  The bug does not appear for
older Emacs code (e.g. older Emacs 24 Dev snapshots, which do not have

It is true that I byte-compile this library using Emacs 20, because the
library is used with multiple Emacs versions.  I don't know whether
byte-compiling it in Emacs 24 would make a difference wrt this annoying

If doing that is the answer then I guess I'll have to split the file
(the redefinition of this function is only done for Emacs 24.4+, i.e.,
when that function is `fboundp').

The symptom is that each time this function is called (at runtime, i.e.,
using Dired), a boatload of binary byte-compile stuff is printed in
*Messages*, and the entire doc string is printed there as well.

What's more: when I start Emacs with a directory as the target, so it
opens in Dired, the entire doc string is shown in the echo area (for
which my standalone minibuffer frame is expanded automatically).  So a
user has to see that whole, irrelevant doc string for a few seconds.

Please advise, whether or not you feel this is a bug.  What can I do to
prevent this noise.  To me it seems like a bug: byte-compiled code has
no business being logged to *Messages* or shown in the echo area during
runtime.  But you might not see it that way.

Here is the redefinition, in case its relevant to the bug or otherwise
helpful (doubtful):

;; REPLACE ORIGINAL in `ls-lisp.el'
;; 1. If wildcard, set FILE to `default-directory' if FILE has no dir component.
;; 2. In second header line: include the number of files and subdirs in the 
(when (fboundp 'ls-lisp--insert-directory) ; Emacs 24.4+
  (defun ls-lisp--insert-directory (orig-fun file switches &optional wildcard 
    "Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
SWITCHES may be a string of options, or a list of strings.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.

This version of the function comes from `ls-lisp.el'.
If the value of `ls-lisp-use-insert-directory-program' is non-nil then
this advice just delegates the work to ORIG-FUN (the normal `insert-directory'
function from `files.el').
But if the value of `ls-lisp-use-insert-directory-program' is nil
then it runs a Lisp emulation.

The Lisp emulation does not run any external programs or shells.  It
supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards'
is non-nil; otherwise, it interprets wildcards as regular expressions
to match file names.  It does not support all `ls' switches -- those
that work are: A a B C c F G g h i n R r S s t U u X.  The l switch
is assumed to be always present and cannot be turned off."
    (if ls-lisp-use-insert-directory-program
        (funcall orig-fun
                 file switches wildcard full-directory-p)
      ;; We need the directory in order to find the right handler.
      (let ((handler (find-file-name-handler (expand-file-name file)
            (orig-file file)
        (if handler
            (funcall handler 'insert-directory file switches
                     wildcard full-directory-p)
          ;; Remove --dired switch
          (if (string-match "--dired " switches)
              (setq switches (replace-match "" nil nil switches)))
          ;; Convert SWITCHES to a list of characters.
          (setq switches (delete ?\  (delete ?- (append switches nil))))
          ;; Sometimes we get ".../foo*/" as FILE.  While the shell and
          ;; `ls' don't mind, we certainly do, because it makes us think
          ;; there is no wildcard, only a directory name.
          (if (and ls-lisp-support-shell-wildcards
                   (string-match "[[?*]" file)
                   ;; Prefer an existing file to wildcards, like
                   ;; dired-noselect does.
                   (not (file-exists-p file)))
                (or (not (eq (aref file (1- (length file))) ?/))
                    (setq file (substring file 0 (1- (length file)))))
                (setq wildcard t)))
          (if wildcard

              (setq wildcard-regexp
                    (if ls-lisp-support-shell-wildcards
                        (wildcard-to-regexp (file-name-nondirectory file))
                      (file-name-nondirectory file))
                    file             (or (file-name-directory file)  
            (if (memq ?B switches) (setq wildcard-regexp "[^~]\\'")))
          (condition-case err
               file switches (ls-lisp-time-index switches)
               wildcard-regexp full-directory-p)
             ;; Maybe they wanted a literal file that just happens to
             ;; use characters special to shell wildcards.
             (if (equal (cadr err) "Unmatched [ or [^")
                   (setq wildcard-regexp (if (memq ?B switches) "[^~]\\'")
                         file (file-relative-name orig-file))
                    file switches (ls-lisp-time-index switches)
                    nil full-directory-p))
               (signal (car err) (cdr err)))))
          ;; Try to insert the amount of free space.
            (goto-char (point-min))
            (while (re-search-forward "^total" nil t)
              (let ((counted  (save-match-data (count-dired-files))))
                (if (zerop counted)
                    (insert "files 0/0 ")
                  (insert "files " (number-to-string counted)
                          "/" (number-to-string
                               (- (length (directory-files default-directory
                                                           nil nil t)) 2))
                          " ")))
              (goto-char (point-min))
              (re-search-forward "^files [0-9]+/[0-9]+ \\(total\\)" nil t)
              (replace-match "space used" nil nil nil 1)
              (let ((available (and (fboundp 'get-free-disk-space)
                                    (get-free-disk-space ".")))
                    (map (make-sparse-keymap))
                    (inhibit-field-text-motion t)) ; Just to be sure, for eol.
                (define-key map [mouse-2]
                (define-key map "\r" 'dired-describe-listed-directory)
                (when available (end-of-line) (insert " available " available))
                 (save-excursion (beginning-of-line) (line-beginning-position))
                 (1- (match-beginning 1))
                 `(mouse-face highlight keymap ,map
                   help-echo "Files shown / total files in directory \
\[RET, mouse-2: more info]"))
                (add-text-properties (match-beginning 1) (line-end-position)
                                     `(mouse-face highlight keymap ,map
                                       help-echo "Kbytes used in directory, 
Kbytes \
available on disk [RET, mouse-2: more info]"))))))))))

In GNU Emacs (i686-pc-mingw32)
 of 2013-10-19 on LEG570
Bzr revision: 114715 address@hidden
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'

reply via email to

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