all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* detect emacs/xemacs in elisp?
@ 2002-12-09 18:30 Jason Addison
  2002-12-09 18:52 ` Jesper Harder
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jason Addison @ 2002-12-09 18:30 UTC (permalink / raw)


I have some elisp that works/doesn't work in emacs/xemacs in my
".emacs" file. I would like to be able to execute or not execute code
depending on which type of emacs I'm running. Another way around this
would be to know how to determine if a function is defined before
calling it. Any idea on how to do this in elisp? Also, how do you
determine the version of emacs that is running in elisp?

Thanks, Jason

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

* Re: detect emacs/xemacs in elisp?
  2002-12-09 18:30 detect emacs/xemacs in elisp? Jason Addison
@ 2002-12-09 18:52 ` Jesper Harder
  2002-12-09 21:57 ` Tim X
  2002-12-10  0:50 ` Stefan Monnier <foo@acm.com>
  2 siblings, 0 replies; 5+ messages in thread
From: Jesper Harder @ 2002-12-09 18:52 UTC (permalink / raw)


jason_addison@hotmail.com (Jason Addison) writes:

> I have some elisp that works/doesn't work in emacs/xemacs in my
> ".emacs" file. I would like to be able to execute or not execute code
> depending on which type of emacs I'm running. 


(if (featurep 'xemacs)
    (progn
      ;; do Xemacs stuff
      )
  ;; do Emacs stuff
  )

> Another way around this would be to know how to determine if a
> function is defined before calling it. Any idea on how to do this in
> elisp? 

Use `fboundp' to determine if a function is defined.

> Also, how do you determine the version of emacs that is running in
> elisp?

E.g the function `emacs-version'.

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

* Re: detect emacs/xemacs in elisp?
  2002-12-09 18:30 detect emacs/xemacs in elisp? Jason Addison
  2002-12-09 18:52 ` Jesper Harder
@ 2002-12-09 21:57 ` Tim X
  2002-12-09 22:19   ` Benjamin Lewis
  2002-12-10  0:50 ` Stefan Monnier <foo@acm.com>
  2 siblings, 1 reply; 5+ messages in thread
From: Tim X @ 2002-12-09 21:57 UTC (permalink / raw)


jason_addison@hotmail.com (Jason Addison) writes:

> I have some elisp that works/doesn't work in emacs/xemacs in my
> ".emacs" file. I would like to be able to execute or not execute code
> depending on which type of emacs I'm running. Another way around this
> would be to know how to determine if a function is defined before
> calling it. Any idea on how to do this in elisp? Also, how do you
> determine the version of emacs that is running in elisp?
> 

There is a package called initz which allows you to setup different
initializations depending on what emacs/xemacs flavor you are
running. This package will then control what init files are used
depending on the flavor/version you are starting up.

I'm not sure where to get it, I saw it as one of the packages
available for debian. 


-- 
Tim X.
tcross (at) northnet com au

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

* Re: detect emacs/xemacs in elisp?
  2002-12-09 21:57 ` Tim X
@ 2002-12-09 22:19   ` Benjamin Lewis
  0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Lewis @ 2002-12-09 22:19 UTC (permalink / raw)


On 10 Dec 2002, Tim X. wrote:

> jason_addison@hotmail.com (Jason Addison) writes:
> 
>> I have some elisp that works/doesn't work in emacs/xemacs in my
>> ".emacs" file. I would like to be able to execute or not execute code
>> depending on which type of emacs I'm running. Another way around this
>> would be to know how to determine if a function is defined before
>> calling it. Any idea on how to do this in elisp? Also, how do you
>> determine the version of emacs that is running in elisp?
>> 
> 
> There is a package called initz which allows you to setup different
> initializations depending on what emacs/xemacs flavor you are
> running. This package will then control what init files are used
> depending on the flavor/version you are starting up.

Do you really need a ``package'' to do this?  Why not just make a .emacs
with something like

(defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
(defvar running-em21 (>= emacs-major-version 21))

(cond (running-xemacs (load-file my-xemacs-init-file))
      (running-em21 (load-file my-em21-specific-file))
      (load-file my-default-file))

... or whatever.

-- 
Benjamin Lewis

Dinosaurs aren't extinct.  They've just learned to hide in the trees.

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

* Re: detect emacs/xemacs in elisp?
  2002-12-09 18:30 detect emacs/xemacs in elisp? Jason Addison
  2002-12-09 18:52 ` Jesper Harder
  2002-12-09 21:57 ` Tim X
@ 2002-12-10  0:50 ` Stefan Monnier <foo@acm.com>
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2002-12-10  0:50 UTC (permalink / raw)


>>>>> "Jason" == Jason Addison <jason_addison@hotmail.com> writes:
> I have some elisp that works/doesn't work in emacs/xemacs in my
> ".emacs" file.

You can use

        (condition-case nil
            (this-is-the thing that might fail)
          (error nil))

to tell Emacs to ignore any error that might occur while executing
the form (this-is-the thing that might fail).

If you do (require 'cl) you can equivalently use the following shorthand:

        (ignore-errors (this-is-the thing that might fail))

> Another way around this
> would be to know how to determine if a function is defined before
> calling it.

(if (fboundp 'foo)
    (foo some arg))


        Stefan

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

end of thread, other threads:[~2002-12-10  0:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-09 18:30 detect emacs/xemacs in elisp? Jason Addison
2002-12-09 18:52 ` Jesper Harder
2002-12-09 21:57 ` Tim X
2002-12-09 22:19   ` Benjamin Lewis
2002-12-10  0:50 ` Stefan Monnier <foo@acm.com>

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.