unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* `format-spec' fails to pass on text properties
@ 2005-05-13 15:29 Daniel Brockman
  2005-05-13 16:05 ` Daniel Brockman
  2005-05-13 16:26 ` Daniel Brockman
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Brockman @ 2005-05-13 15:29 UTC (permalink / raw)


This works as expected:

ELISP> (format #("<%s>" 0 4 (face (:weight bold))) "foo")
#("<foo>" 0 5
  (face
   (:weight bold)))

This, however, does not:

ELISP> (format-spec #("<%x>" 0 4 (face (:weight bold))) '((?x . "foo")))
#("<foo>" 0 1
  (face
   (:weight bold))
  1 4 nil 4 5
  (face
   (:weight bold)))

Is this a bug that should be fixed?

-- 
Daniel Brockman <daniel@brockman.se>

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

* Re: `format-spec' fails to pass on text properties
  2005-05-13 15:29 `format-spec' fails to pass on text properties Daniel Brockman
@ 2005-05-13 16:05 ` Daniel Brockman
  2005-05-14 15:12   ` Richard Stallman
  2005-05-13 16:26 ` Daniel Brockman
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Brockman @ 2005-05-13 16:05 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 120 bytes --]

Here's a fix that seems to work, but I'm not very experienced in
hacking Elisp so I'm probably doing something stupid.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1302 bytes --]

*** emacs/lisp/gnus/format-spec.el~	2003-09-01 17:45:23.000000000 +0200
--- emacs/lisp/gnus/format-spec.el	2005-05-13 17:48:07.438183352 +0200
***************
*** 45,54 ****
  	(let* ((num (match-string 1))
  	       (spec (string-to-char (match-string 2)))
  	       (val (cdr (assq spec specification))))
- 	  (delete-region (1- (match-beginning 0)) (match-end 0))
  	  (unless val
  	    (error "Invalid format character: %s" spec))
! 	  (insert (format (concat "%" num "s") val))))
         ;; Signal an error on bogus format strings.
         (t
  	(error "Invalid format string"))))
--- 45,59 ----
  	(let* ((num (match-string 1))
  	       (spec (string-to-char (match-string 2)))
  	       (val (cdr (assq spec specification))))
  	  (unless val
  	    (error "Invalid format character: %s" spec))
!           (let ((text (format (concat "%" num "s") val)))
!             (insert-and-inherit text)
!             ;; Delete the specifier body.
!             (delete-region (+ (match-beginning 0) (length text))
!                            (+ (match-end 0) (length text)))
!             ;; Delete the percent sign.
!             (delete-region (1- (match-beginning 0)) (match-beginning 0)))))
         ;; Signal an error on bogus format strings.
         (t
  	(error "Invalid format string"))))

[-- Attachment #3: Type: text/plain, Size: 42 bytes --]


-- 
Daniel Brockman <daniel@brockman.se>

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: `format-spec' fails to pass on text properties
  2005-05-13 15:29 `format-spec' fails to pass on text properties Daniel Brockman
  2005-05-13 16:05 ` Daniel Brockman
@ 2005-05-13 16:26 ` Daniel Brockman
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Brockman @ 2005-05-13 16:26 UTC (permalink / raw)


I'm sorry, ignore this message.  I just want to see if it gets
through Gmane.

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

* Re: `format-spec' fails to pass on text properties
  2005-05-13 16:05 ` Daniel Brockman
@ 2005-05-14 15:12   ` Richard Stallman
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2005-05-14 15:12 UTC (permalink / raw)
  Cc: emacs-devel

Your patch looks good to me.  Thanks.

It is small enough to be a "tiny change".
Would someone please install it?

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

end of thread, other threads:[~2005-05-14 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-13 15:29 `format-spec' fails to pass on text properties Daniel Brockman
2005-05-13 16:05 ` Daniel Brockman
2005-05-14 15:12   ` Richard Stallman
2005-05-13 16:26 ` Daniel Brockman

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).