news@bbn.COM (News system owner ID) (08/24/89)
Okay, i've apropos'ed, checked the manual, browsed my local sources, and looked through the elisp archives, and i still haven't found a solution: any suggestions for how to sort a dired buffer by _date_? Seems a little tough on the surface, since sort-columns appears to use a sort utility which won't do month names properly: i could have sworn i saw some code to do this before, but since i can't find it, if you've got a solution, please post/mail. ........................................ Sean Boisen -- sboisen@bbn.com BBN Systems and Technologies Corporation, Cambridge MA Disclaimer: these opinions void where prohibited by lawyers. Sean
Duchier-Denys@cs.yale.edu (Denys Duchier) (08/25/89)
In article <44719@bbn.COM>, news@bbn (News system owner ID) writes: > Okay, i've apropos'ed, checked the manual, browsed my local sources, > and looked through the elisp archives, and i still haven't found a > solution: > > any suggestions for how to sort a dired buffer by _date_? > > Seems a little tough on the surface, since sort-columns appears to use > a sort utility which won't do month names properly: i could have sworn i saw > some code to do this before, but since i can't find it, if you've got > a solution, please post/mail. (setq dired-listing-switches "-algot") --Denys
daveemme@uts.amdahl.com (Dave Emme) (08/25/89)
In article <44719@bbn.COM> sboisen@bbn.com writes: > [...] >any suggestions for how to sort a dired buffer by _date_? > [...] Well, I use the following, which can be placed in your ".emacs" file. It's sort of a hack, but it works. The "s" key in the dired keymap is defined to call "dired-sort", which toggles the arguments to ls(1) between their normal dired value and a set which sorts by date. Each time you press the "s" key the arguments are toggled, ls(1) is called, and the results displayed. The ls(1) arguments are local to each dired buffer. Enjoy! -------------------- Cut Here -------------------- (load "dired") (make-variable-buffer-local 'dired-listing-switches) (setq-default dired-listing-switches "-als") (define-key dired-mode-map "s" 'dired-sort) (defun dired-sort () "Alternates dired listing order between sorted-by-name and sorted-by-date." (interactive) (setq dired-listing-switches (if (string-equal dired-listing-switches "-als") "-alts" "-als")) (revert-buffer)) -- ------------------------------------------------------------------------------ Dave Emme daveemme@uts.amdahl.com Amdahl Corporation {ames, decwrl, sun, uunet}!amdahl!daveemme 1250 E. Arques Ave. M/S 316 Sunnyvale, CA. 94088-3470 "Whenever you find yourself on the side of the majority, it is time to pause and reflect." -- Mark Twain
gwr@gomez.uucp (Gordon W. Ross) (08/26/89)
In article <572C02cp4emH01@amdahl.uts.amdahl.com> daveemme@amdahl.uts.amdahl.com (Dave Emme) writes: >In article <44719@bbn.COM> sboisen@bbn.com writes: [...] > >any suggestions for how to sort a dired buffer by _date_? [...] and each offer some simple ways to hack the elisp variable "dired-listing-switches" but I like mine better because it makes no permanent changes to that variable. (Small, too!) Here it is: ; Make the "t" key sort the current dired listing by date. ; It takes effect just this once, so "g" will be unchanged. (defun dired-sort-by-time () "Redisplays a dired listing sorted by time." (interactive) (let ((dired-listing-switches (concat dired-listing-switches "t"))) (revert-buffer t t))) (setq dired-mode-hook '(lambda() (define-key dired-mode-map "t" 'dired-sort-by-time) ; Add other dired-mode-map customizations here... )) Gordon W. Ross gwr@gomez.mitre.org (617) 271-3205 (daytime) The MITRE Corp. (M/S E025) Burlington Road, Bedford, MA 01730
ceb@csli.Stanford.EDU (Charles Buckley) (08/28/89)
In the spirit of the recently posted dired-by-date patch, I seem to remember that it used to be that when you did M-x grep, and got your results in the *compilation* buffer, that hitting 'e' or somehing on a partiucular line would cause that file to be edited, and move the cursor to the line in question (One could even do this by character - enough information is present). Does someone still have the code which does this, or could perhaps some FSF member dig it out of the code locker? ceb
rbj@dsys.ncsl.nist.GOV (Root Boy Jim) (08/29/89)
? From: News system owner ID <news@BBN.COM> ? any suggestions for how to sort a dired buffer by _date_? ? Sean Boisen -- sboisen@bbn.com ? BBN Systems and Technologies Corporation, Cambridge MA ? Disclaimer: these opinions void where prohibited by lawyers. ? Sean Put the following in your .emacs: (setq dired-mode-hook 'dired-mode-hook) (defun dired-mode-hook () "Define dired extensions" (setq case-fold-search t) ; Why is this not done? (define-key dired-mode-map "t" 'dired-sort-by-time) (setq dired-mode-hook nil)) (defun dired-sort-by-time (arg) ; t "Reread directory and sort by time. Reverse sort with prefix." (interactive "P") (let ((dired-listing-switches (concat dired-listing-switches "t" (and arg "r")))) (revert-buffer))) Root Boy Jim Have GNU, Will Travel.
kim@kannel.lut.fi (Kimmo Suominen) (08/29/89)
In article <10204@csli.Stanford.EDU> ceb@csli.Stanford.EDU (Charles Buckley) writes:
From: ceb@csli.Stanford.EDU (Charles Buckley)
Newsgroups: comp.emacs
Date: 28 Aug 89 09:38:50 GMT
Organization: Center for the Study of Language and Information, Stanford U.
In the spirit of the recently posted dired-by-date patch, I seem to
remember that it used to be that when you did M-x grep, and got your
results in the *compilation* buffer, that hitting 'e' or somehing on a
partiucular line would cause that file to be edited, and move the
cursor to the line in question (One could even do this by character -
enough information is present).
Does someone still have the code which does this, or could perhaps
some FSF member dig it out of the code locker?
ceb
After grep or compile you can edit the files mentioned in *compilation* by
keying in C-x `. Every time you do this, you get into the next file.
Kim
--
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
( Kimmo Suominen Electronic Mail on Internet: kim@kannel.lut.fi )
( "That's what I think!" on Funet: KUULA::KIM )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rock%warp@Sun.COM (Bill Petro) (08/30/89)
rbj@dsys.ncsl.nist.GOV (Root Boy Jim) writes: >? From: News system owner ID <news@BBN.COM> >? any suggestions for how to sort a dired buffer by _date_? Even better, any suggestions for how to sort a dired buffer by _size_ ? Bill Petro {decwrl,hplabs,ucbvax}!sun!Eng!rock "UNIX for the sake of the kingdom of heaven" Matthew 19:12
Duchier-Denys@cs.yale.edu (Denys Duchier) (08/30/89)
In article <123916@sun.Eng.Sun.COM>, rock%warp (Bill Petro) writes: > Even better, any suggestions for how to sort a dired buffer by _size_ ? The following works on my machine: (defvar dired-filter " | sort -n +2 -3 ") (defun dired-readin (dirname buffer) (save-excursion (message "Reading directory %s..." dirname) (set-buffer buffer) (let ((buffer-read-only nil)) (widen) (erase-buffer) (setq dirname (expand-file-name dirname)) (if (file-directory-p dirname) (call-process shell-file-name nil buffer nil "-c" (concat "ls " dired-listing-switches " " dirname dired-filter)) (let ((default-directory (file-name-directory dirname))) (call-process shell-file-name nil buffer nil "-c" (concat "ls " dired-listing-switches " " (file-name-nondirectory dirname))))) (goto-char (point-min)) (while (not (eobp)) (insert " ") (forward-line 1)) (goto-char (point-min))) (message "Reading directory %s...done" dirname))) --Denys
rbj@dsys.ncsl.nist.GOV (Root Boy Jim) (08/30/89)
? From: Denys Duchier <Duchier-Denys@yale.edu>
? In article <123916@sun.Eng.Sun.COM>, rock%warp (Bill Petro) writes:
? > Even better, any suggestions for how to sort a dired buffer by _size_ ?
? The following works on my machine:
Hmmmm. This seems to sort on the userid. Perhaps you have a weird ls?
And you have to use it all the time. It should be a separate function.
Not to be outdone, here is my version, simpler and more general:
Add the following to your .emacs to sort by both time and date:
(setq dired-mode-hook 'dired-mode-hook)
(defun dired-mode-hook ()
"Define dired extensions"
(setq case-fold-search t) ; Why is this not done?
(define-key dired-mode-map "t" 'dired-sort-by-time)
(define-key dired-mode-map "s" 'dired-sort-by-size)
(setq dired-mode-hook nil))
(defun dired-sort-by-time (arg) ; t
"Reread directory and sort by time. Reverse sort with prefix."
(interactive "P")
(let ((dired-listing-switches
(concat dired-listing-switches "t" (and arg "r"))))
(revert-buffer)))
(defun dired-sort-by-size (arg) ; s
"Reread directory and sort by size. Reverse sort with prefix."
(interactive "P")
(revert-buffer)
(shell-command-on-region
(point-min) (point-max)
(concat "sort +3n" (and arg " -r")) t))
? --Denys
Root Boy Jim and
the GNU Bohemians
rbj@dsys.ncsl.nist.GOV (Root Boy Jim) (08/30/89)
OOPS! Forgot that buffer was read only! A corrected version: Add the following to your .emacs to sort by both time and date: (setq dired-mode-hook 'dired-mode-hook) (defun dired-mode-hook () "Define dired extensions" (setq case-fold-search t) ; Why is this not done? (define-key dired-mode-map "t" 'dired-sort-by-time) (define-key dired-mode-map "s" 'dired-sort-by-size) (setq dired-mode-hook nil)) (defun dired-sort-by-time (arg) ; t "Reread directory and sort by time. Reverse sort with prefix." (interactive "P") (let ((dired-listing-switches (concat dired-listing-switches "t" (and arg "r")))) (revert-buffer))) (defun dired-sort-by-size (arg) ; s "Reread directory and sort by size. Reverse sort with prefix." (interactive "P") (revert-buffer) (let ((buffer-read-only nil)) ; I forgot this line (shell-command-on-region (point-min) (point-max) (concat "sort +3n" (and arg " -r")) t))) ? --Denys Root Boy Jim and the GNU Bohemians
lynn@rave.phx.mcd.mot.com (Lynn D. Newton) (08/31/89)
Here's another way to sort by size which I just implemented today. (Designed by a friend, not me.) (defun dired-sort-by-size (arg) ; s "Reread directory and sort by size. Reverse sort with prefix." (interactive "P") (revert-buffer) (let ((buffer-read-only nil)) (shell-command-on-region (point-min) (point-max) (concat "sort +4n" (and arg " -r")) t))) -- ================================================================= Lynn D. Newton | System Test Motorola MCD, Tempe, AZ | (Department of Heuristic Neology) (602) 437-3739 | "The bug stops here!" lynn@rave.phx.mcd.mot.com |
aglew@urbana.mcd.mot.com (Andy-Krazy-Glew) (08/31/89)
From: ceb@csli.Stanford.EDU (Charles Buckley) Newsgroups: comp.emacs Date: 28 Aug 89 09:38:50 GMT Organization: Center for the Study of Language and Information, Stanford U. In the spirit of the recently posted dired-by-date patch, I seem to remember that it used to be that when you did M-x grep, and got your results in the *compilation* buffer, that hitting 'e' or somehing on a partiucular line would cause that file to be edited, and move the cursor to the line in question (One could even do this by character - enough information is present). Does someone still have the code which does this, or could perhaps some FSF member dig it out of the code locker? This isn't the old code (I wasn't aware of the old code) but it does part of the trick: ;;; Added functions to the compile package (defun ag-reparse-compilation-errors () "Move to a position in the compilation window, skipping stuff you don't want, and recreate list. INTERIM: maybe long delay since whole list is redone. but so far I have found it tolerable" (interactive) (compilation-forget-errors) (save-excursion (set-buffer "*compilation*") (setq compilation-parsing-end (point))) (next-error)) (make-global-binding "\^x\\" 'ag-reparse-compilation-errors) As I mention inline, it can be slow since it reparses the *compilation* buffer -- this was right for me, since I occasionally edit the compilation buffer, but it isn't always the best. Or, you could move down the already parsed list of marks until you found the one corresponding to your position in the *compilation* buffer. PS. is there any way, macro invocation or such, so that the docstring can be split up into several lines and properly indented? Eg. instead of: (defun foo () "Multi line docstring obscures indentation" (bar (baz))) Something like: (defun foo () (CONCAT-MACRO "Multi\n" "line\n" "docstring\n" "reasonably\n" "indented\n") (bar (baz))) ANSI C combines adjacent string literals, separated by whitespace including newlines, into one literal, but this obviously wouldn't work for LISP. I'm told that Common Lisp has a special code that indicates to delete leading whitespace per line in the following literal, but that's pretty ugly. A macro would be what I want, but it seems that special forms get in the way. -- Andy "Krazy" Glew, Motorola MCD, aglew@urbana.mcd.mot.com 1101 E. University, Urbana, IL 61801, USA. {uunet!,}uiucuxc!udc!aglew My opinions are my own; I indicate my company only so that the reader may account for any possible bias I may have towards our products.
rbj@dsys.ncsl.nist.GOV (Root Boy Jim) (09/01/89)
? From: "Lynn D. Newton" <mailrus!ncar!asuvax!mcdphx!rave!lynn@BBN.COM> ? Here's another way to sort by size which I just implemented ? today. (Designed by a friend, not me.) I just posted that yesterday. Well, at least you called me a friend :-) ? (defun dired-sort-by-size (arg) ; s ? "Reread directory and sort by size. Reverse sort with prefix." ? (interactive "P") ? (revert-buffer) ? (let ((buffer-read-only nil)) ? (shell-command-on-region ? (point-min) (point-max) ? (concat "sort +4n" (and arg " -r")) t))) ? ================================================================= ? Lynn D. Newton | System Test ? Motorola MCD, Tempe, AZ | (Department of Heuristic Neology) ? (602) 437-3739 | "The bug stops here!" ? lynn@rave.phx.mcd.mot.com | I tried to call, but they say your number has been disconnected. Root Boy Jim and the GNU Bohemians