all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Lisp-readable integer syntax for `C-x ='
@ 2005-11-17  7:52 Juri Linkov
  2005-11-18 16:57 ` Richard M. Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Juri Linkov @ 2005-11-17  7:52 UTC (permalink / raw)


`C-x C-e' and `M-:' print the value in Lisp-readable syntax like:

  99 (#o143, #x63, ?c)

The patch below does the same for `C-x =' and `C-u C-x =':

  Char: c (99, #o143, #x63) point=1 of 2 (0%) column 0

  character: c (99, #o143, #x63, U+0063)

The order of decimal, octal and hex is the same in all formats.
There is currently no syntax for Unicode.  This could be implemented
in the next Emacs version (i.e. "Unicode 23.0").

The same patch also fixes some excessive space.  I can also update the
Emacs manual with real examples.

Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.763
diff -c -r1.763 simple.el
*** lisp/simple.el	16 Nov 2005 22:43:16 -0000	1.763
--- lisp/simple.el	17 Nov 2005 07:48:48 -0000
***************
*** 891,899 ****
  	 (col (current-column)))
      (if (= pos end)
  	(if (or (/= beg 1) (/= end (1+ total)))
! 	    (message "point=%d of %d (%d%%) <%d - %d> column %d %s"
  		     pos total percent beg end col hscroll)
! 	  (message "point=%d of %d (EOB) column %d %s"
  		   pos total col hscroll))
        (let ((coding buffer-file-coding-system)
  	    encoded encoding-msg display-prop under-display)
--- 892,900 ----
  	 (col (current-column)))
      (if (= pos end)
  	(if (or (/= beg 1) (/= end (1+ total)))
! 	    (message "point=%d of %d (%d%%) <%d-%d> column %d%s"
  		     pos total percent beg end col hscroll)
! 	  (message "point=%d of %d (EOB) column %d%s"
  		   pos total col hscroll))
        (let ((coding buffer-file-coding-system)
  	    encoded encoding-msg display-prop under-display)
***************
*** 902,908 ****
  	    (setq coding default-buffer-file-coding-system))
  	(if (not (char-valid-p char))
  	    (setq encoding-msg
! 		  (format "(0%o, %d, 0x%x, invalid)" char char char))
  	  ;; Check if the character is displayed with some `display'
  	  ;; text property.  In that case, set under-display to the
  	  ;; buffer substring covered by that property.
--- 903,909 ----
  	    (setq coding default-buffer-file-coding-system))
  	(if (not (char-valid-p char))
  	    (setq encoding-msg
! 		  (format "(%d, #o%o, #x%x, invalid)" char char char))
  	  ;; Check if the character is displayed with some `display'
  	  ;; text property.  In that case, set under-display to the
  	  ;; buffer substring covered by that property.
***************
*** 921,947 ****
  	  (setq encoding-msg
  		(if display-prop
  		    (if (not (stringp display-prop))
! 			(format "(0%o, %d, 0x%x, part of display \"%s\")"
  				char char char under-display)
! 		      (format "(0%o, %d, 0x%x, part of display \"%s\"->\"%s\")"
  			      char char char under-display display-prop))
  		  (if encoded
! 		      (format "(0%o, %d, 0x%x, file %s)"
  			      char char char
  			      (if (> (length encoded) 1)
  				  "..."
  				(encoded-string-description encoded coding)))
! 		    (format "(0%o, %d, 0x%x)" char char char)))))
  	(if detail
  	    ;; We show the detailed information about CHAR.
  	    (describe-char (point)))
  	(if (or (/= beg 1) (/= end (1+ total)))
! 	    (message "Char: %s %s point=%d of %d (%d%%) <%d - %d> column %d %s"
  		     (if (< char 256)
  			 (single-key-description char)
  		       (buffer-substring-no-properties (point) (1+ (point))))
  		     encoding-msg pos total percent beg end col hscroll)
! 	  (message "Char: %s %s point=%d of %d (%d%%) column %d %s"
  		   (if enable-multibyte-characters
  		       (if (< char 128)
  			   (single-key-description char)
--- 922,948 ----
  	  (setq encoding-msg
  		(if display-prop
  		    (if (not (stringp display-prop))
! 			(format "(%d, #o%o, #x%x, part of display \"%s\")"
  				char char char under-display)
! 		      (format "(%d, #o%o, #x%x, part of display \"%s\"->\"%s\")"
  			      char char char under-display display-prop))
  		  (if encoded
! 		      (format "(%d, #o%o, #x%x, file %s)"
  			      char char char
  			      (if (> (length encoded) 1)
  				  "..."
  				(encoded-string-description encoded coding)))
! 		    (format "(%d, #o%o, #x%x)" char char char)))))
  	(if detail
  	    ;; We show the detailed information about CHAR.
  	    (describe-char (point)))
  	(if (or (/= beg 1) (/= end (1+ total)))
! 	    (message "Char: %s %s point=%d of %d (%d%%) <%d-%d> column %d%s"
  		     (if (< char 256)
  			 (single-key-description char)
  		       (buffer-substring-no-properties (point) (1+ (point))))
  		     encoding-msg pos total percent beg end col hscroll)
! 	  (message "Char: %s %s point=%d of %d (%d%%) column %d%s"
  		   (if enable-multibyte-characters
  		       (if (< char 128)
  			   (single-key-description char)

Index: lisp/descr-text.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/descr-text.el,v
retrieving revision 1.40
diff -c -r1.40 descr-text.el
*** lisp/descr-text.el	9 Sep 2005 01:10:41 -0000	1.40
--- lisp/descr-text.el	17 Nov 2005 07:48:48 -0000
***************
*** 467,473 ****
  			  (encode-char char 'ucs))))
      (setq item-list
  	  `(("character"
! 	    ,(format "%s (0%o, %d, 0x%x%s)"
  		     (apply 'propertize (if (not multibyte-p)
  					    (single-key-description char)
  					  (if (< char 128)
--- 467,473 ----
  			  (encode-char char 'ucs))))
      (setq item-list
  	  `(("character"
! 	    ,(format "%s (%d, #o%o, #x%x%s)"
  		     (apply 'propertize (if (not multibyte-p)
  					    (single-key-description char)
  					  (if (< char 128)
***************
*** 510,516 ****
  	     ,@(let ((category-set (char-category-set char)))
  		 (if (not category-set)
  		     '("-- none --")
! 		   (mapcar #'(lambda (x) (format "%c:%s  "
  						 x (category-docstring x)))
  			   (category-set-mnemonics category-set)))))
  	    ,@(let ((props (aref char-code-property-table char))
--- 510,516 ----
  	     ,@(let ((category-set (char-category-set char)))
  		 (if (not category-set)
  		     '("-- none --")
! 		   (mapcar #'(lambda (x) (format "%c:%s"
  						 x (category-docstring x)))
  			   (category-set-mnemonics category-set)))))
  	    ,@(let ((props (aref char-code-property-table char))
***************
*** 583,589 ****
  		      (if display
  			  (concat
  			   "by this font (glyph code)\n"
! 			   (format "     %s (0x%02X)"
  				   (car display) (cdr display)))
  			"no font available")
  		    (if display
--- 583,589 ----
  		      (if display
  			  (concat
  			   "by this font (glyph code)\n"
! 			   (format "     %s (#x%02X)"
  				   (car display) (cdr display)))
  			"no font available")
  		    (if display
***************
*** 657,663 ****
  		  (insert (logand (car (aref disp-vector i)) #x7ffff) ?:
  			  (propertize " " 'display '(space :align-to 5))
  			  (if (cdr (aref disp-vector i))
! 			      (format "%s (0x%02X)" (cadr (aref disp-vector i))
  				      (cddr (aref disp-vector i)))
  			    "-- no font --")
  			  "\n")
--- 657,663 ----
  		  (insert (logand (car (aref disp-vector i)) #x7ffff) ?:
  			  (propertize " " 'display '(space :align-to 5))
  			  (if (cdr (aref disp-vector i))
! 			      (format "%s (#x%02X)" (cadr (aref disp-vector i))
  				      (cddr (aref disp-vector i)))
  			    "-- no font --")
  			  "\n")
***************
*** 708,714 ****
  		  (insert "\n " (car elt) ?:
  			  (propertize " " 'display '(space :align-to 5))
  			  (if (cdr elt)
! 			      (format "%s (0x%02X)" (cadr elt) (cddr elt))
  			    "-- no font --"))))
  	    (insert "these terminal codes:")
  	    (dolist (elt component-chars)
--- 708,714 ----
  		  (insert "\n " (car elt) ?:
  			  (propertize " " 'display '(space :align-to 5))
  			  (if (cdr elt)
! 			      (format "%s (#x%02X)" (cadr elt) (cddr elt))
  			    "-- no font --"))))
  	    (insert "these terminal codes:")
  	    (dolist (elt component-chars)

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: Lisp-readable integer syntax for `C-x ='
  2005-11-17  7:52 Lisp-readable integer syntax for `C-x =' Juri Linkov
@ 2005-11-18 16:57 ` Richard M. Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard M. Stallman @ 2005-11-18 16:57 UTC (permalink / raw)
  Cc: emacs-devel

    `C-x C-e' and `M-:' print the value in Lisp-readable syntax like:

      99 (#o143, #x63, ?c)

    The patch below does the same for `C-x =' and `C-u C-x =':

Seems good to me.

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

end of thread, other threads:[~2005-11-18 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-17  7:52 Lisp-readable integer syntax for `C-x =' Juri Linkov
2005-11-18 16:57 ` Richard M. 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.