code-iai / ros_emacs_utils

Emacs tools for ROS
17 stars 19 forks source link

Update rosemacs.el #9

Closed k-okada closed 9 years ago

k-okada commented 9 years ago

on indigo(14.04) it fails on loading as follows:

/opt/ros/indigo/share/emacs/site-lisp/rosemacs.el
`flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'. [2 times]
fairlight1337 commented 9 years ago

Kei,

thanks a lot for the pull request. Does this work for you in elisp? However, in the default SBCL implementation, I couldn't find the cl-flet call:

CL-USER> (cl-flet ((fnc ())))
; in: CL-FLET ((FNC NIL))
;     ((FNC NIL))
; 
; caught ERROR:
;   illegal function call

; in: CL-FLET ((FNC NIL))
;     (CL-FLET ((FNC NIL)))
; 
; caught STYLE-WARNING:
;   undefined function: CL-FLET
; 
; compilation unit finished
;   Undefined function:
;     CL-FLET
;   caught 1 ERROR condition
;   caught 1 STYLE-WARNING condition
; Evaluation aborted on #<SB-INT:COMPILED-PROGRAM-ERROR {1010E6B583}>.

flet seems indeed to be deprecated though: http://stackoverflow.com/questions/18895605/should-flet-be-replaced-with-cl-flet-or-cl-letf

@gaya-, do you have an idea whether this exists in SBCL as well? Its this function: http://www.gnu.org/software/emacs/manual/html_node/cl/Function-Bindings.html

garaemon commented 9 years ago

Please be careful about using cl-flet, because cl-flet does not exist on emacs 23 (precise default).

fairlight1337 commented 9 years ago

Thanks, true. I'm on GNU Emacs 24.3.1 (Ubuntu 14.04, using ROS Indigo) and it seems to not be present here either. Which Emacs are you using exactly? Is it the default one for Ubuntu (e.g. 24.3)?

garaemon commented 9 years ago

I'm using emacs 24.3.1 and I can use cl-flet after (require 'cl-lib).

According to you code above, you are using sbcl and you don't test it on emacs lisp.

(require 'cl-lib)
(cl-flet ((foo ()))
  (print 'foo))
k-okada commented 9 years ago

Humm, on emacs24 (trusty default), flet does not exist, we have to use cl-flet.

◉ Kei Okada

On Fri, Jan 2, 2015 at 5:50 PM, Ryohei Ueda notifications@github.com wrote:

Please be careful about using cl-flet, because cl-flet does not exist on emacs 23 (precise default).

— Reply to this email directly or view it on GitHub https://github.com/code-iai/ros_emacs_utils/pull/9#issuecomment-68514167 .

garaemon commented 9 years ago

emacs provides a good variable emacs-major-version.

gaya- commented 9 years ago

Yes, I've used that variable in this stack before and am planning to use it for this pull request. I'll merge it in and add necessary tweaks once I'm back home from vacation tomorrow if that's fine. @fairlight1337 You're testing it in common lisp, it's written in emacs lisp though.

fairlight1337 commented 9 years ago

You're right, @garaemon. I was testing it in SBCL and not Elisp, which didn't make any sense. So

(progn
  (require 'cl-lib)
  (cl-flet ((fnc ()
              (print "Test")))
    (fnc)))

works fine for me. Does this work on older Emacs versions as well? We still have some people around that use emacs23 (and hopefully nothing older).

Otherwise, I'll just pull it in. @airballking, @gaya-, any objections?

fairlight1337 commented 9 years ago

@gaya-, just saw it, thanks ;). Okay, I'll leave that to you.

garaemon commented 9 years ago

unfortunately emacs23 does not support cl-flet.

Does this work on older Emacs versions as well? We still have some people around that use emacs23 (and hopefully nothing older).

gaya- commented 9 years ago

Sorry it took forever to process this pull request.

A couple of notes:

Thanks a lot to everyone for your contribution!

Solved in https://github.com/code-iai/ros_emacs_utils/commit/abb4c49687a7d3c56cc945ecab679efc8ca46594#diff-a09e14295c5979c53a50dbbc3adf9f7dR449