🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #8774

vmsort.el robustness improved (GNU Emacs 19.13 and later)

#8774
From: Paul Eggert
Date: Tue, 13 Jul 1993 19:40
121 lines
5573 bytes
Jamie Zawinski's vmsort.el, as distributed by David MacKenzie in the GNU Emacs
19 version of VM (ftp.eng.umd.edu:pub/gnu/vm-5.33-19.tar.gz), contains a lot
of fragile contortions to find out the local timezone.  These contortions are
no longer necessary in GNU Emacs 19.13 and later, which allows
current-time-zone output to be passed as input to
timezone-make-date-sortable.  Here's a patch.

Tue Jul 13 19:17:46 1993  Paul Eggert  (eggert@twinsun.com)

	* vmsort.el (vm-default-timezone, vm-compute-local-timezone): Remove.
	(vm-sortable-date-string): Use `current-time-zone' instead.

===================================================================
RCS file: vmsort.el,v
retrieving revision 5.33
retrieving revision 5.33.1.1
diff -c -r5.33 -r5.33.1.1
*** vmsort.el	1991/05/11 23:58:01	5.33
--- vmsort.el	1993/07/13 19:17:46	5.33.1.1
***************
*** 52,59 ****
  (defun vm-sort-by-date (reverse)
    "Sort messages of current VM file by date.
  If prefix argument REVERSE is non-nil, sort them in reverse order.
! This actually changes the order of messages in the folder.
! You may need to set the variable `vm-default-timezone' before running this."
    (interactive "P")
    (vm-sort-messages reverse 'vm-sortable-date-string))
  
--- 52,58 ----
  (defun vm-sort-by-date (reverse)
    "Sort messages of current VM file by date.
  If prefix argument REVERSE is non-nil, sort them in reverse order.
! This actually changes the order of messages in the folder."
    (interactive "P")
    (vm-sort-messages reverse 'vm-sortable-date-string))
  
***************
*** 206,248 ****
      ))
  
  
- ;;; Time stuff.  What a pain in the butt.
- 
- (defvar vm-default-timezone nil
-   "*The string-name of the local timezone, \"PDT\" for example.
- If this is nil, we will -try- to compute it when necessary.")
- 
- (defun vm-compute-local-timezone ()
-   "Try to figure out what timezone we're in by executing `date(1)'."
-   (require 'timezone)
-   (save-excursion
-     (set-buffer (get-buffer-create " *zone-hackery*"))
-     (let (h1 d1 h2 d2)
-       (erase-buffer)
-       (shell-command-on-region 1 1 "date '+%H %w'" t)
-       (goto-char 1)
-       (and (looking-at "\\([0-9][0-9]?\\) \\([0-9][0-9]?\\)")
- 	   (setq h1 (string-to-int (buffer-substring
- 				    (match-beginning 1) (match-end 1))))
- 	   (setq d1 (string-to-int (buffer-substring
- 				    (match-beginning 2) (match-end 2)))))
-       (erase-buffer)
-       (shell-command-on-region 1 1 "date -u '+%H %w'" t)
-       (goto-char 1)
-       (and (looking-at "\\([0-9][0-9]?\\) \\([0-9][0-9]?\\)")
- 	   (setq h2 (string-to-int (buffer-substring
- 				    (match-beginning 1) (match-end 1))))
- 	   (setq d2 (string-to-int (buffer-substring
- 				    (match-beginning 2) (match-end 2)))))
-       (kill-buffer " *zone-hackery*")
-       (let ((offset (% (- h2 h1) 24)))
- 	(if (< offset 0)
- 	    (setq offset (+ 24 offset)))
- 	;; daylight savings time might make this be goofy:
- 	;; MST instead of PDT, for example.  This still works.
- 	(car (rassq (* -100 offset) timezone-world-timezones))))))
- 
- 
  (defun vm-sortable-date-string (msg)
    "Make a string sortable by string-lessp of the date of the message."
    (let ((year (vm-year-of msg))
--- 205,210 ----
***************
*** 259,277 ****
  	(setq day (concat " " day))
        (if (and (= 2 (length day)) (= ?0 (aref day 0)))
  	  (setq day (concat " " (substring day 1)))))
!     (or vm-default-timezone
! 	(setq vm-default-timezone (vm-compute-local-timezone)))
!     (if (equal "" zone) (setq zone vm-default-timezone))
      (timezone-make-date-sortable
!      (setq x (concat day " " month " " year " " time " " zone))
!      "GMT" "GMT")))
  
  ;; CORRECT:
! ;; (timezone-make-date-sortable " 3 May 1991 17:34:45 EDT" "GMT" "GMT")  "91050321:34:45"
! ;; (timezone-make-date-sortable " 3 May 1991 14:38:58 PDT" "GMT" "GMT")  "91050321:38:58"
  
  ;; INCORRECT:
! ;; (timezone-make-date-sortable " 3 May 1991 17:34:45 EDT" "GMT" "GMT")  "91050313:34:45"
! ;; (timezone-make-date-sortable " 3 May 1991 14:38:58 PDT" "GMT" "GMT")  "91050307:38:58"
  
  (provide 'vm-sort)
--- 221,236 ----
  	(setq day (concat " " day))
        (if (and (= 2 (length day)) (= ?0 (aref day 0)))
  	  (setq day (concat " " (substring day 1)))))
!     (if (equal "" zone) (setq zone (current-time-zone)))
      (timezone-make-date-sortable
!      (concat day " " month " " year " " time) zone 0)))
  
  ;; CORRECT:
! ;; (timezone-make-date-sortable " 3 May 1991 17:34:45" "EDT" 0)  "1991050321:34:45"
! ;; (timezone-make-date-sortable " 3 May 1991 14:38:58" "PDT" 0)  "1991050321:38:58"
  
  ;; INCORRECT:
! ;; (timezone-make-date-sortable " 3 May 1991 17:34:45" "EDT" 0)  "1991050313:34:45"
! ;; (timezone-make-date-sortable " 3 May 1991 14:38:58" "PDT" 0)  "1991050307:38:58"
  
  (provide 'vm-sort)
Technical Details
Message-ID: <9307131940.AA11606@bi.twinsun.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!noc.near.net!uunet!wendy-fate.uu.net!bug-vm

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6829,f8265c4d41e6264b,start
X-Google-Attributes: gidf6829,public
X-Google-ArrivalTime: 1993-07-13 12:47:31 PST
x-gateway: rodan.UU.NET from bug-vm to gnu.emacs.vm.bug; Tue, 13 Jul 1993 15:42:55 EDT
Date: Tue, 13 Jul 1993 12:40:09 PDT
From: eggert@twinsun.com (Paul Eggert)
Message-ID: <9307131940.AA11606@bi.twinsun.com>
Subject: vmsort.el robustness improved (GNU Emacs 19.13 and later)
Newsgroups: gnu.emacs.vm.bug
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!noc.near.net!uunet!wendy-fate.uu.net!bug-vm
Sender: bug-vm-request@uunet.uu.net
Lines: 121