* help on text-properties
@ 2007-06-06 5:15 Yu,Gang
2007-06-06 8:31 ` Kim F. Storm
0 siblings, 1 reply; 4+ messages in thread
From: Yu,Gang @ 2007-06-06 5:15 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1713 bytes --]
Hi all:
I want to set text properties on a string, however, any time I get a nil
result after the (set|add)-text-properties call, the text is not properly
propetied.
what's wrong??
I use emacs 22.1, here is the source code:
(defun show-paren-minibuffer (pair-point pos)
"show the paren pair in the minibuffer, pos is current point , pair-point
is the point of the paren pair"
(if (not (pos-visible-in-window-p pair-point))
(let ((pair-line-number (line-number-at-pos pair-point))
(pos-line-number (line-number-at-pos pos))
show-string
offset)
(if (not (equal pair-line-number pos-line-number))
(save-excursion
(goto-line pair-line-number)
(setq offset (- pair-point (line-beginning-position)))
(setq show-string (buffer-substring (line-beginning-position)
(line-end-position)))
(diag-pr (set-text-properties offset offset '(comment t face
highlight) show-string))
(if (< (length show-string) 20)
(setq show-string
(concat
(buffer-substring
(- (line-beginning-position) 30)
(- (line-beginning-position) 1))
"\n"
show-string
"\n"
(buffer-substring
(+ (line-end-position) 1)
(+ (line-end-position) 30)))))
(message "%s" show-string))))))
and my diag-pr macro:
(defmacro diag-pr (exp)
"print the expression result in the *scratch buffer"
`(let ((tmp-diag-var ,exp))
(print (list ',exp 'result 'is (list tmp-diag-var)) diag-buffer)
tmp-diag-var))
in the diag-buffer, all resutls display "nil"
How can I sovle the problem?
thanks !!
--
YuGang
[-- Attachment #1.2: Type: text/html, Size: 3056 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help on text-properties
[not found] <mailman.1619.1181106948.32220.help-gnu-emacs@gnu.org>
@ 2007-06-06 7:13 ` Thien-Thi Nguyen
2007-06-06 9:00 ` Yu,Gang
0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2007-06-06 7:13 UTC (permalink / raw)
To: help-gnu-emacs
() "Yu,Gang" <wuhanyugang@gmail.com>
() Wed, 6 Jun 2007 13:15:35 +0800
(set-text-properties offset offset ...)
How can I sovle the problem?
what is the distance between offset and offset?
(would be a fine number to count if but "not yet".)
when an expression paints pictures in thin air,
can memory alone suffice to record what's there?
if desire to build is too strong, one reflects,
it's easy to miss what is wrong, through neglect.
thi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help on text-properties
2007-06-06 5:15 help on text-properties Yu,Gang
@ 2007-06-06 8:31 ` Kim F. Storm
0 siblings, 0 replies; 4+ messages in thread
From: Kim F. Storm @ 2007-06-06 8:31 UTC (permalink / raw)
To: Yu,Gang; +Cc: help-gnu-emacs
"Yu,Gang" <wuhanyugang@gmail.com> writes:
> Hi all:
> I want to set text properties on a string, however, any time I get a nil
> result after the (set|add)-text-properties call, the text is not properly
> propetied.
>
> what's wrong??
> (diag-pr (set-text-properties offset offset '(comment t face
> highlight) show-string))
This part?
It sets the properties from "offset" to "offset" -- which is a no-op.
--
Kim F. Storm http://www.cua.dk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help on text-properties
2007-06-06 7:13 ` Thien-Thi Nguyen
@ 2007-06-06 9:00 ` Yu,Gang
0 siblings, 0 replies; 4+ messages in thread
From: Yu,Gang @ 2007-06-06 9:00 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1956 bytes --]
Thanks, I get things run now~
(defun show-paren-minibuffer (pair-point pos)
"show the paren pair in the minibuffer"
(if (not (pos-visible-in-window-p pair-point))
(let ((pair-line-number (line-number-at-pos pair-point))
(pos-line-number (line-number-at-pos pos))
show-string
offset)
(if (not (equal pair-line-number pos-line-number))
(save-excursion
(goto-line pair-line-number)
(setq offset (- pair-point (line-beginning-position)))
(setq show-string (buffer-substring (line-beginning-position)
(line-end-position)))
(if (> pos pair-point)
(add-text-properties offset (+ offset 1) '(fontified t face
highlight) show-string)
(add-text-properties (- offset 1) offset '(fontified t face
highlight) show-string))
(if (< (length show-string) 20)
(setq show-string
(concat
(buffer-substring
(- (line-beginning-position) 30)
(- (line-beginning-position) 1))
"\n"
show-string
"\n"
(buffer-substring
(+ (line-end-position) 1)
(+ (line-end-position) 30)))))
(message "%s" show-string))))))
On 6/6/07, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
>
> () "Yu,Gang" <wuhanyugang@gmail.com>
> () Wed, 6 Jun 2007 13:15:35 +0800
>
> (set-text-properties offset offset ...)
>
> How can I sovle the problem?
>
> what is the distance between offset and offset?
> (would be a fine number to count if but "not yet".)
> when an expression paints pictures in thin air,
> can memory alone suffice to record what's there?
> if desire to build is too strong, one reflects,
> it's easy to miss what is wrong, through neglect.
>
> thi
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
--
YuGang
[-- Attachment #1.2: Type: text/html, Size: 3643 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-06-06 9:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-06 5:15 help on text-properties Yu,Gang
2007-06-06 8:31 ` Kim F. Storm
[not found] <mailman.1619.1181106948.32220.help-gnu-emacs@gnu.org>
2007-06-06 7:13 ` Thien-Thi Nguyen
2007-06-06 9:00 ` Yu,Gang
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).