unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to delete/unbind a name defined in Emacs Lisp?
@ 2004-01-06 11:41 WANG Wei
  2004-01-06 12:08 ` David Kastrup
  2004-01-06 14:34 ` Jesper Harder
  0 siblings, 2 replies; 10+ messages in thread
From: WANG Wei @ 2004-01-06 11:41 UTC (permalink / raw)



Hello all!

When we say (defun xxx () ...), we introduce a new name "xxx" in
Emacs. A lot of such names will dirty the global name space. So I
wonder how to delete names that I don't need any more.

Thanks a lot.

Regards, Wangwei

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-06 11:41 How to delete/unbind a name defined in Emacs Lisp? WANG Wei
@ 2004-01-06 12:08 ` David Kastrup
  2004-01-06 13:57   ` WANG Wei
  2004-01-06 14:34 ` Jesper Harder
  1 sibling, 1 reply; 10+ messages in thread
From: David Kastrup @ 2004-01-06 12:08 UTC (permalink / raw)


WANG Wei <wangwei_org@sina.com> writes:

> Hello all!
> 
> When we say (defun xxx () ...), we introduce a new name "xxx" in
> Emacs. A lot of such names will dirty the global name space. So I
> wonder how to delete names that I don't need any more.

Why do you create them in the first place?  If you need a function
just temporarily, you can create it ad-hoc with lambda:

((lambda (x y) (+ x (* 2 y))) 3 4)   =>  11

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-06 12:08 ` David Kastrup
@ 2004-01-06 13:57   ` WANG Wei
  2004-01-06 14:46     ` Martin Rydstr|m
  0 siblings, 1 reply; 10+ messages in thread
From: WANG Wei @ 2004-01-06 13:57 UTC (permalink / raw)



Thank you :-)

Yeah, and by the way, we can even define a function like this:

(let* ((f1 (lambda (x) (1+ x))))
  (funcall f1 2))

but what I want to know is that, if we made some *mistake* and
introduce a function that I didn't need (maybe when debugging?), what
should I do.  then when we press C-h f, we'll find some rubbish there.

Now the only solution is shutting down the Emacs and restart again,
but of course it's not a good idea.

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-06 11:41 How to delete/unbind a name defined in Emacs Lisp? WANG Wei
  2004-01-06 12:08 ` David Kastrup
@ 2004-01-06 14:34 ` Jesper Harder
  1 sibling, 0 replies; 10+ messages in thread
From: Jesper Harder @ 2004-01-06 14:34 UTC (permalink / raw)


WANG Wei <wangwei_org@sina.com> writes:

> When we say (defun xxx () ...), we introduce a new name "xxx" in
> Emacs. A lot of such names will dirty the global name space. So I
> wonder how to delete names that I don't need any more.

Use `fmakunbound' to remove a function and `makunbound' to remove a
variable.

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-06 13:57   ` WANG Wei
@ 2004-01-06 14:46     ` Martin Rydstr|m
  2004-01-07  1:41       ` WANG Wei
  2004-01-07  3:28       ` How to delete/unbind a name defined in Emacs Lisp? WANG Wei
  0 siblings, 2 replies; 10+ messages in thread
From: Martin Rydstr|m @ 2004-01-06 14:46 UTC (permalink / raw)


WANG Wei <wangwei_org@sina.com> writes:
> but what I want to know is that, if we made some *mistake* and
> introduce a function that I didn't need (maybe when debugging?), what
> should I do.  then when we press C-h f, we'll find some rubbish there.

fmakunbound might help. unintern as well.

Regards,

'mr

-- 
[Emacs] is written in Lisp, which is the only computer language that is
beautiful.  -- Neal Stephenson, _In the Beginning was the Command Line_

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-06 14:46     ` Martin Rydstr|m
@ 2004-01-07  1:41       ` WANG Wei
  2004-01-07 10:09         ` Stefan Monnier
  2004-01-07  3:28       ` How to delete/unbind a name defined in Emacs Lisp? WANG Wei
  1 sibling, 1 reply; 10+ messages in thread
From: WANG Wei @ 2004-01-07  1:41 UTC (permalink / raw)
  Cc: rydis+copies

Thanks, unintern is actually what I need!

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-06 14:46     ` Martin Rydstr|m
  2004-01-07  1:41       ` WANG Wei
@ 2004-01-07  3:28       ` WANG Wei
  1 sibling, 0 replies; 10+ messages in thread
From: WANG Wei @ 2004-01-07  3:28 UTC (permalink / raw)
  Cc: rydis+copies


> rydis (Martin Rydstr|m) @CD.Chalmers.SE writes:
> 
> fmakunbound might help. unintern as well.

Thanks a lot.

``unintern'' works well!

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

* Re: How to delete/unbind a name defined in Emacs Lisp?
  2004-01-07  1:41       ` WANG Wei
@ 2004-01-07 10:09         ` Stefan Monnier
  2004-01-16 11:52           ` advice needed for font-lock-syntactic-face-function Gian Uberto Lauri
       [not found]           ` <mailman.780.1074279472.928.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Monnier @ 2004-01-07 10:09 UTC (permalink / raw)


> Thanks, unintern is actually what I need!

I doubt it.  Use `fmakunbound' instead.
The effects of `unintern' are pretty subtle.


        Stefan

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

* advice needed for font-lock-syntactic-face-function
  2004-01-07 10:09         ` Stefan Monnier
@ 2004-01-16 11:52           ` Gian Uberto Lauri
       [not found]           ` <mailman.780.1074279472.928.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Gian Uberto Lauri @ 2004-01-16 11:52 UTC (permalink / raw)


I'm trying  to borrow the  function from tex-mode.el (CVS  version) to
mark.  html tags and JSP/ASP/PHP blocks,  and I took the piece of code
that matches \verb+ + blocks as example.

(defun html-helper-font-lock-last-char-helper ()
  (when (eq (char-syntax (preceding-char)) ?/)
    (put-text-property (1- (point)) (point) 'syntax-table '(1)))
  (unless (eobp)
    (put-text-property (point) (1+ (point)) 'syntax-table '(7))))


(defun html-helper-font-lock-syntactic-face-function (state)
  (let ((char (nth 3 state)))
    (cond
     ;; char ^[,bh^[(B nil
     ((not char) font-lock-comment-face)
     (t
	(cond ((string-match "[a-zA-Z]" (char-to-string char))
	       ;; This is an HTML tag
	       (save-excursion
		 (unless (search-forward-regexp "[^%?]>" nil t)
		   (goto-char (point-max)))
		 (html-helper-font-lock-last-char-helper))
	       html-helper-tag-face)
	      ((string-match "[%?]"  (char-to-string char))
	       ;; This is a server script block
	       (save-excursion
		 (unless (search-forward-regexp "[%?]>" nil t)
		   (goto-char (point-max)))
		 (html-helper-font-lock-last-char-helper))
	       html-helper-server-script-face)
	      ((eq ? char)
	       ;; This is a server script block
	       (unless (search-forwardd "-->" nil t)
		 (save-excursion
		   (goto-char (point-max))))
	       font-lock-comment-face))))))

Executing my function step by  step i verified that I successfully set
up  font-lock-syntactic-keywords,  I successfully  matched  a tag  but
after leaving the  save-excursion block I see that  the program enters
this sexp

(set-syntax-table old-syntax-table)

and after some more steps (about 8) I get stuck in the

(mode-line-mode-name) 

sexp.

I fear that there's something weird in the put-text-property sexps in
html-helper-font-lock-last-char-helper function.

Is there anybody who can (and wants) to give me some advice ?

The tex-mode original works fine, of course :).

TIA

 /\            ___
/___/\__|_|\_|__|___Gian Uberto Lauri_____________________
  //--\ | | \|  |   Integralista GNUslamico e fancazzista 
\/

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

* Re: advice needed for font-lock-syntactic-face-function
       [not found]           ` <mailman.780.1074279472.928.help-gnu-emacs@gnu.org>
@ 2004-01-19 22:54             ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2004-01-19 22:54 UTC (permalink / raw)


> I'm trying  to borrow the  function from tex-mode.el (CVS  version) to
> mark.  html tags and JSP/ASP/PHP blocks,  and I took the piece of code
> that matches \verb+ + blocks as example.

I did not understand what goes wrong with the code you posted: does it get
stuck in an infinite loop?  does it fail to highlight?  does it
highlight wrong?  does it signal an error?

> 	(cond ((string-match "[a-zA-Z]" (char-to-string char))
> 	       ;; This is an HTML tag
> 	       (save-excursion
> 		 (unless (search-forward-regexp "[^%?]>" nil t)
> 		   (goto-char (point-max)))
> 		 (html-helper-font-lock-last-char-helper))

I'd recommend (re-search-forward "[^%?]>" nil 'move).

> 	      ((eq ? char)

Since "? " is the first arg to `eq' above, that means there is no
separation betwen the two args, which is poor style.  I recommend
(eq char ?\ ) instead which makes the meaningful space much more visible.

> 	       ;; This is a server script block
> 	       (unless (search-forwardd "-->" nil t)
> 		 (save-excursion
> 		   (goto-char (point-max))))
> 	       font-lock-comment-face))))))

This save-excursion block is a nop.

> Executing my function step by  step i verified that I successfully set
> up  font-lock-syntactic-keywords,

I.e. you checked with C-x = that the proper chars get assigned the proper
syntax-table property?

> I successfully  matched  a tag  but after leaving the save-excursion
> block I see that the program enters this sexp

Which save-excursion block?

> (set-syntax-table old-syntax-table)

I see no such sexp in your code.  Which code are you tracing?  font-lock's?
If you're tracing font-lock's code, you're better off turning off jit-lock
mode, otherwise it's a complete mess.

> and after some more steps (about 8) I get stuck in the

Are you using edebug?  Or which kind of stepping are you doing?


        Stefan

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

end of thread, other threads:[~2004-01-19 22:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-06 11:41 How to delete/unbind a name defined in Emacs Lisp? WANG Wei
2004-01-06 12:08 ` David Kastrup
2004-01-06 13:57   ` WANG Wei
2004-01-06 14:46     ` Martin Rydstr|m
2004-01-07  1:41       ` WANG Wei
2004-01-07 10:09         ` Stefan Monnier
2004-01-16 11:52           ` advice needed for font-lock-syntactic-face-function Gian Uberto Lauri
     [not found]           ` <mailman.780.1074279472.928.help-gnu-emacs@gnu.org>
2004-01-19 22:54             ` Stefan Monnier
2004-01-07  3:28       ` How to delete/unbind a name defined in Emacs Lisp? WANG Wei
2004-01-06 14:34 ` Jesper Harder

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).