Aquamacs 1.9/Objective-C

View: New views
7 Messages — Rating Filter:   Alert me  

Aquamacs 1.9/Objective-C

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I remember seeing in the release notes for the 1.9 preview that Aquamacs
now does a better job of recognizing Objective-C files. When I try to
open .m files in 1.9, however, Aquamacs still defaults to Matlab, and I
have to manually change the parser/buffer mode. Wouldn't it be more
Mac-like to have Aquamacs default to Objective-C for .m files? Or is
there a way to set preferences on this?

Thanks,
Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel

Re: Aquamacs 1.9/Objective-C

by davidswelt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 8, 2009, at 9:26 AM, Kevin Walzer wrote:
> I remember seeing in the release notes for the 1.9 preview that  
> Aquamacs now does a better job of recognizing Objective-C files.  
> When I try to open .m files in 1.9, however, Aquamacs still defaults  
> to Matlab, and I have to manually change the parser/buffer mode.  
> Wouldn't it be more Mac-like to have Aquamacs default to Objective-C  
> for .m files? Or is there a way to set preferences on this?


Can you send one of the files that it doesn't recognize?
magic-mode-alist is key.

- David






_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel

smime.p7s (2K) Download Attachment

Re: Aquamacs 1.9/Objective-C

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/10/09 9:43 AM, David Reitter wrote:

>
> Can you send one of the files that it doesn't recognize?
> magic-mode-alist is key.
>
> - David

See the attached.

For what it's worth, when select "About Aquamacs" in the menu, I get
this output:

GNU Emacs 23.1.1 (i386-apple-darwin9.7.0, NS apple-appkit-949.46)
  of 2009-08-06 on braeburn.aquamacs.org - Aquamacs Distribution 2.0preview2

Is that right? I thought I had downloaded 1.9, but this says 2.0.

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

/*tkmacicon: implements a simple Cocoa-based mechanism for retrieving file icons in a Tk application on OS X. (c) 2009 WordTech Communications LLC. License: standard Tcl license,  http://www.tcl.tk/software/tcltk/license.html.*/


#import "macicon.h"
#import "tkmacicon.h"


// Tcl command to get a file icon
int GetMacIcon (ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
       
  NSString *iconpath;
  NSString *iconfile;
  double iconwidth;
  double iconheight;
  double tclwidth;
  double tclheight;
 
  //cast double vars to float for Cocoa method args
  float outputheight;
  float outputwidth;
       
  //set up memory pool
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
       
       
  //need proper number of args    
  if(objc != 5) {        
    Tcl_WrongNumArgs(ip, 1, objv, "icon width height outputfile");        
    return TCL_ERROR;    
  }
   
  //initialize the instance of tkmacicon
  MacIcon *tkmacicon = [[MacIcon alloc ] init];

  //convert args to usable Cocoa objects
  iconpath = [NSString stringWithUTF8String:Tcl_GetString(objv[1])];
  iconwidth =  Tcl_GetDoubleFromObj(ip, objv[2], &tclwidth);
  iconheight = Tcl_GetDoubleFromObj(ip, objv[3], &tclheight);
  outputwidth = (float) tclwidth;
  outputheight = (float) tclheight;
  iconfile = [NSString stringWithUTF8String:Tcl_GetString(objv[4])];

       
  //retrieve the icon and write it to file
  [tkmacicon makeIcon:iconpath imagewidth:outputwidth imageheight:outputheight outputfile:iconfile];
   
   
  //release the memory
  [pool release];  
  return TCL_OK;
}




//initalize the package in the tcl interpreter, create tcl commands
int Tkmacicon_Init (Tcl_Interp *ip) {
       
  //set up an autorelease pool
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
       
  if (Tcl_InitStubs(ip, "8.5", 0) == NULL) {
    return TCL_ERROR;
  }

  Tcl_CreateObjCommand(ip, "::tkmacicon::getIcon", GetMacIcon,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
             

  if (Tcl_PkgProvide(ip, "tkmacicon", "1.0") != TCL_OK) {
    return TCL_ERROR;
  }

  //release memory
  [pool release];
       
  return TCL_OK;
       

}

int Tkmacicon_SafeInit(Tcl_Interp *ip) {
  return Tkmacicon_Init(ip);
}



_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel

Re: Aquamacs 1.9/Objective-C

by davidswelt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 10, 2009, at 10:04 AM, Kevin Walzer wrote:

> <tkmacicon.m>

OK, the code below fixes this one.

Also.. does matlab use /* these comments */ ?
Otherwise they'd be a distinguishing feature as well.

- D





(defun objc-mode-buffer-check ()
   (if (string-match "\\.m$" buffer-file-name)
       (save-restriction
        (narrow-to-region (point-min)
                          (min (point-max)
                               (+ (point-min) magic-mode-regexp-match-limit)))
        (looking-at "\\(.\\|\n\\)*#\\(include\\|define\\|import\\)"))))

_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel

smime.p7s (2K) Download Attachment

Re: Aquamacs 1.9/Objective-C

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/10/09 5:33 PM, David Reitter wrote:

> On Oct 10, 2009, at 10:04 AM, Kevin Walzer wrote:
>
>> <tkmacicon.m>
>
> OK, the code below fixes this one.
>
> Also.. does matlab use /* these comments */ ?
> Otherwise they'd be a distinguishing feature as well.
>
> - D
>
>
>
>
>
> (defun objc-mode-buffer-check ()
> (if (string-match "\\.m$" buffer-file-name)
> (save-restriction
> (narrow-to-region (point-min)
> (min (point-max)
> (+ (point-min) magic-mode-regexp-match-limit)))
> (looking-at "\\(.\\|\n\\)*#\\(include\\|define\\|import\\)"))))


David,

Forgive my obtuseness, but where should this patch go? I did not see a
magic-mode-alist file anywhere in site-lisp.

--Kevin
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel

Re: Aquamacs 1.9/Objective-C

by davidswelt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 10, 2009, at 6:58 PM, Kevin Walzer wrote:
> Forgive my obtuseness, but where should this patch go? I did not see  
> a magic-mode-alist file anywhere in site-lisp.

It's a customization variable, so you'd have to customize it. Or you  
use my code in Preferences.el.

Or, why not wait until I've committed the change to the 2.x series and  
download a nightly build?

- D

--
http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and  
support the Aquamacs Project!
_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel

Re: Aquamacs 1.9/Objective-C

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/10/09 7:23 PM, David Reitter wrote:

> On Oct 10, 2009, at 6:58 PM, Kevin Walzer wrote:
>> Forgive my obtuseness, but where should this patch go? I did not see a
>> magic-mode-alist file anywhere in site-lisp.
>
> It's a customization variable, so you'd have to customize it. Or you use
> my code in Preferences.el.
>
> Or, why not wait until I've committed the change to the 2.x series and
> download a nightly build?
>
> - D
>

Added to preferences.el, thanks. Works great.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Aquamacs-devel mailing list
Aquamacs-devel@...
http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-devel