all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* appt.el fix: don't use prin1-to-string
@ 2002-08-12 21:26 Alan Shutko
  2002-08-13 22:46 ` Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Shutko @ 2002-08-12 21:26 UTC (permalink / raw)


I noticed my appointment popups were looking like:

5:25pm Test" 0 11 (fontified nil)

Cause was appt.el using prin1-to-string for the entries, which had
text properties.  I don't think it shouldn't have ever been using
prin1-to-string, since those _are_ strings to begin with (and it had
code to remove the quotes that prin1-to-string added).  So they're gone.

2002-08-12  Alan Shutko  <ats@acm.org>

	* calendar/appt.el (appt-delete, appt-make-list): Remove
	prin1-to-string calls (and substrings around them).

--- appt.el.~1.44.~	2002-08-12 17:08:41.000000000 -0400
+++ appt.el	2002-08-12 17:14:52.000000000 -0400
@@ -454,9 +454,9 @@
   (let* ((tmp-msg-list appt-time-msg-list))
     (while tmp-msg-list
       (let* ((element (car tmp-msg-list))
-             (prompt-string (concat "Delete " 
-                                    (prin1-to-string (car (cdr element))) 
-                                    " from list? "))
+             (prompt-string (concat "Delete \"" 
+                                    (car (cdr element))
+                                    "\" from list? "))
              (test-input (y-or-n-p prompt-string)))
         (setq tmp-msg-list (cdr tmp-msg-list))
         (if test-input
@@ -512,9 +512,7 @@
 	      (while (and entry-list 
 			  (calendar-date-equal 
 			   (calendar-current-date) (car (car entry-list))))
-		(let ((time-string (substring (prin1-to-string 
-					       (cadr (car entry-list))) 1 -1)))
-
+		(let ((time-string (cadr (car entry-list))))
 		  (while (string-match
 			  "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*"
 			  time-string)


-- 
Alan Shutko <ats@acm.org> - In a variety of flavors!
My American Express card left home without me.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: appt.el fix: don't use prin1-to-string
  2002-08-12 21:26 appt.el fix: don't use prin1-to-string Alan Shutko
@ 2002-08-13 22:46 ` Richard Stallman
  2002-08-14  0:26   ` Alan Shutko
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2002-08-13 22:46 UTC (permalink / raw)
  Cc: emacs-devel

I think the reason for using prin1-to-string in the first of these
cases is to quote any doublequotes in the string itself.
In the second case, not calling it seems to be correct.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: appt.el fix: don't use prin1-to-string
  2002-08-13 22:46 ` Richard Stallman
@ 2002-08-14  0:26   ` Alan Shutko
  2002-08-14 14:35     ` Stefan Monnier
  2002-08-14 23:13     ` Richard Stallman
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Shutko @ 2002-08-14  0:26 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> I think the reason for using prin1-to-string in the first of these
> cases is to quote any doublequotes in the string itself.
> In the second case, not calling it seems to be correct.

That makes sense.  Here's a new patch which just removes text
properties before printing it in the prompt, but avoids the
prin1-to-string in appt-make-list.

2002-08-13  Alan Shutko  <ats@acm.org>

	* calendar/appt.el (appt-delete): Remove properties before calling
	prin1-to-string.
	(appt-make-list): Remove prin1-to-string calls (and substrings
	around them) since strings may have properties.


Index: lisp/calendar/appt.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/appt.el,v
retrieving revision 1.44
diff -u -r1.44 appt.el
--- lisp/calendar/appt.el	12 Aug 2002 17:21:06 -0000	1.44
+++ lisp/calendar/appt.el	14 Aug 2002 00:25:09 -0000
@@ -454,8 +454,13 @@
   (let* ((tmp-msg-list appt-time-msg-list))
     (while tmp-msg-list
       (let* ((element (car tmp-msg-list))
-             (prompt-string (concat "Delete " 
-                                    (prin1-to-string (car (cdr element))) 
+	     (entry (car (cdr element)))
+	     (prompt-string (concat "Delete " 
+				    (prin1-to-string 
+				     (progn
+				       (set-text-properties 0 (length entry)
+							    nil entry)
+				       entry))
                                     " from list? "))
              (test-input (y-or-n-p prompt-string)))
         (setq tmp-msg-list (cdr tmp-msg-list))
@@ -512,9 +517,7 @@
 	      (while (and entry-list 
 			  (calendar-date-equal 
 			   (calendar-current-date) (car (car entry-list))))
-		(let ((time-string (substring (prin1-to-string 
-					       (cadr (car entry-list))) 1 -1)))
-
+		(let ((time-string (cadr (car entry-list))))
 		  (while (string-match
 			  "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*"
 			  time-string)


-- 
Alan Shutko <ats@acm.org> - In a variety of flavors!
The darn thing works better if you plug it in

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: appt.el fix: don't use prin1-to-string
  2002-08-14  0:26   ` Alan Shutko
@ 2002-08-14 14:35     ` Stefan Monnier
  2002-08-14 18:44       ` Alan Shutko
  2002-08-14 23:13     ` Richard Stallman
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2002-08-14 14:35 UTC (permalink / raw)
  Cc: rms, emacs-devel

> -             (prompt-string (concat "Delete " 
> -                                    (prin1-to-string (car (cdr element))) 
> +	     (entry (car (cdr element)))
> +	     (prompt-string (concat "Delete " 
> +				    (prin1-to-string 
> +				     (progn
> +				       (set-text-properties 0 (length entry)
> +							    nil entry)
> +				       entry))

Please add a short comment to explain why prin1-to-string is used.


	Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: appt.el fix: don't use prin1-to-string
  2002-08-14 14:35     ` Stefan Monnier
@ 2002-08-14 18:44       ` Alan Shutko
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Shutko @ 2002-08-14 18:44 UTC (permalink / raw)
  Cc: rms, emacs-devel

Stefan Monnier <monnier+gnu/emacs@rum.cs.yale.edu> writes:

> Please add a short comment to explain why prin1-to-string is used.

2002-08-13  Alan Shutko  <ats@acm.org>

	* calendar/appt.el (appt-delete): Remove properties before calling
	prin1-to-string.
	(appt-make-list): Remove prin1-to-string calls (and substrings
	around them) since strings may have properties.


Index: lisp/calendar/appt.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/appt.el,v
retrieving revision 1.44
diff -u -r1.44 appt.el
--- lisp/calendar/appt.el	12 Aug 2002 17:21:06 -0000	1.44
+++ lisp/calendar/appt.el	14 Aug 2002 18:44:36 -0000
@@ -454,8 +454,17 @@
   (let* ((tmp-msg-list appt-time-msg-list))
     (while tmp-msg-list
       (let* ((element (car tmp-msg-list))
-             (prompt-string (concat "Delete " 
-                                    (prin1-to-string (car (cdr element))) 
+	     (entry (car (cdr element)))
+	     (prompt-string (concat "Delete " 
+				    ;; Use prin1-to-string here to
+				    ;; put quotes around the entry,
+				    ;; and escape any quotes within
+				    ;; the entry.
+				    (prin1-to-string 
+				     (progn
+				       (set-text-properties 0 (length entry)
+							    nil entry)
+				       entry))
                                     " from list? "))
              (test-input (y-or-n-p prompt-string)))
         (setq tmp-msg-list (cdr tmp-msg-list))
@@ -512,9 +521,7 @@
 	      (while (and entry-list 
 			  (calendar-date-equal 
 			   (calendar-current-date) (car (car entry-list))))
-		(let ((time-string (substring (prin1-to-string 
-					       (cadr (car entry-list))) 1 -1)))
-
+		(let ((time-string (cadr (car entry-list))))
 		  (while (string-match
 			  "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*"
 			  time-string)


-- 
Alan Shutko <ats@acm.org> - In a variety of flavors!
Corn Frakes: The choice of the next generation.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: appt.el fix: don't use prin1-to-string
  2002-08-14  0:26   ` Alan Shutko
  2002-08-14 14:35     ` Stefan Monnier
@ 2002-08-14 23:13     ` Richard Stallman
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2002-08-14 23:13 UTC (permalink / raw)
  Cc: emacs-devel

Thanks.  I'd already written a similar change:

*** appt.el.~1.44.~	Mon Aug 12 13:24:33 2002
--- appt.el	Tue Aug 13 12:21:14 2002
***************
*** 455,461 ****
      (while tmp-msg-list
        (let* ((element (car tmp-msg-list))
               (prompt-string (concat "Delete " 
!                                     (prin1-to-string (car (cdr element))) 
                                      " from list? "))
               (test-input (y-or-n-p prompt-string)))
          (setq tmp-msg-list (cdr tmp-msg-list))
--- 455,463 ----
      (while tmp-msg-list
        (let* ((element (car tmp-msg-list))
               (prompt-string (concat "Delete " 
!                                     (prin1-to-string
! 				     (substring-no-properties
! 				      (car (cdr element)) 0)) 
                                      " from list? "))
               (test-input (y-or-n-p prompt-string)))
          (setq tmp-msg-list (cdr tmp-msg-list))
***************
*** 512,520 ****
  	      (while (and entry-list 
  			  (calendar-date-equal 
  			   (calendar-current-date) (car (car entry-list))))
! 		(let ((time-string (substring (prin1-to-string 
! 					       (cadr (car entry-list))) 1 -1)))
! 
  		  (while (string-match
  			  "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*"
  			  time-string)
--- 514,520 ----
  	      (while (and entry-list 
  			  (calendar-date-equal 
  			   (calendar-current-date) (car (car entry-list))))
! 		(let ((time-string (cadr (car entry-list))))
  		  (while (string-match
  			  "\\([0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?\\).*"
  			  time-string)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-08-14 23:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-12 21:26 appt.el fix: don't use prin1-to-string Alan Shutko
2002-08-13 22:46 ` Richard Stallman
2002-08-14  0:26   ` Alan Shutko
2002-08-14 14:35     ` Stefan Monnier
2002-08-14 18:44       ` Alan Shutko
2002-08-14 23:13     ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.