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

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

dired: toggle the ls -h option, force relisting


From: Emanuel Berg
Subject: dired: toggle the ls -h option, force relisting
Date: Thu, 01 Oct 2015 03:21:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Check out the below code for dired. The idea is to hit
'h' (for human) to toggle the ls -h option.

The code seems to work but if you examine the code you
see that ~3/4 of it is only there to redraw the data
with the point/window all in place at the end of the
tunnel.

So the question is, isn't there something to do this
already?

Neither `revert-buffer', `dired-revert', nor
`dired-do-redisplay' do this what I can see.

Source:

    http://user.it.uu.se/~embe8573/conf/emacs-init/dired-my.el

;; dired ls
(defvar dired-ls-human nil)
(defvar dired-base-ls-options "-AGlX --group-directories-first")
(setq dired-listing-switches dired-base-ls-options)

(defun dired-toggle-human ()
  (interactive)
  (if (setq dired-ls-human (not dired-ls-human))
      (setq dired-listing-switches (format "%s%s" dired-base-ls-options " -h"))
    (setq dired-listing-switches dired-base-ls-options) )
  (let ((current-dir  dired-directory)
        (window-start (window-start))
        (current-line (line-number-at-pos)) )
    (quit-window t) ; KILL
    (dired current-dir)
    (goto-char (point-min))
    (forward-line (1- current-line))
    (dired-move-to-filename)
    (set-window-start nil window-start) )) ; the selected WINDOW

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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