[30147] trunk/dports/aqua/emacs-app

source_changes at macosforge.org source_changes at macosforge.org
Sun Oct 21 10:18:09 PDT 2007


Revision: 30147
          http://trac.macosforge.org/projects/macports/changeset/30147
Author:   css at macports.org
Date:     2007-10-21 10:17:45 -0700 (Sun, 21 Oct 2007)

Log Message:
-----------
Update emacs-app to rc2 along with build fixes for Panther and the latest upstream patches from the author.

Modified Paths:
--------------
    trunk/dports/aqua/emacs-app/Portfile

Added Paths:
-----------
    trunk/dports/aqua/emacs-app/files/
    trunk/dports/aqua/emacs-app/files/20071015_rc2a.patch
    trunk/dports/aqua/emacs-app/files/patch-compile.diff

Modified: trunk/dports/aqua/emacs-app/Portfile
===================================================================
--- trunk/dports/aqua/emacs-app/Portfile	2007-10-21 17:01:33 UTC (rev 30146)
+++ trunk/dports/aqua/emacs-app/Portfile	2007-10-21 17:17:45 UTC (rev 30147)
@@ -2,7 +2,7 @@
 
 PortSystem 1.0
 name		emacs-app
-version		23.0.0_NS-9.0rc1
+version		23.0.0_NS-9.0rc2a
 categories	aqua editors
 maintainers	css at macports.org
 description	The GNU Emacs text editor (Cocoa version)
@@ -23,9 +23,12 @@
 distname	emacs-${version}
 extract.suffix	.tar.bz2
 use_bzip2	yes
-checksums	md5 bbbe6ac08c74d921caf132352dd7fd1b \
-		sha1 0964b2661577fb8a0551a38710b3d5cce168d7b8
+checksums	md5 5799b301ab0158b953d70b6f69ba32ed \
+		sha1 1373a5048cbd1973993f6c46a24c7a256c6c7f46
 
+# http://sourceforge.net/tracker/index.php?func=detail&aid=1810588&group_id=148174&atid=770756
+patchfiles	20071015_rc2a.patch
+
 depends_lib	port:coreutils \
 		port:pkgconfig \
 		port:texinfo
@@ -42,6 +45,12 @@
 # Eventually build the port without the provided script...
 # configure.args	--with-ns --without-x --prefix=${destroot}/Applications/MacPorts/Emacs.app/Contents/Resources
 
+# Don't attempt to build universal on darwin 7, so apply a patch
+# to modify the compile script.
+platform darwin 7 {
+	patchfiles-append	patch-compile
+}
+
 platform darwin 8 {
 	if {$xcodeversion == "2.1"} {
 		set xcodebuilddir build/Deployment
@@ -50,14 +59,15 @@
 
 build.dir	${worksrcpath}/nextstep
 build.cmd	./compile
+build.target
 
 # Due to the fact that the script compiles and installs everything
 # into the source directory, the destroot phase must manually copy the
 # resulting application package.
 
-pre-configure {
-	reinplace "s|--with-ns|--with-ns --without-freetype|g" ${worksrcpath}/nextstep/compile
-}
+#pre-configure {
+#	reinplace "s|--with-ns|--with-ns --without-freetype|g" ${worksrcpath}/nextstep/compile
+#}
 
 destroot {
 	xinstall -m 755 -d ${destroot}/Applications/MacPorts

Added: trunk/dports/aqua/emacs-app/files/20071015_rc2a.patch
===================================================================
--- trunk/dports/aqua/emacs-app/files/20071015_rc2a.patch	                        (rev 0)
+++ trunk/dports/aqua/emacs-app/files/20071015_rc2a.patch	2007-10-21 17:17:45 UTC (rev 30147)
@@ -0,0 +1,1412 @@
+--- emacs-23.0.0_NS-9.0rc2a/src/image.c	2007-09-15 21:36:19.000000000 +0300
++++ src/image.c	2007-10-14 06:30:25.000000000 +0300
+@@ -1583,6 +1583,9 @@
+ 
+ 	  img->background_transparent
+ 	    = (four_corners_best (mask, img->corners, img->width, img->height) == PIX_MASK_RETAIN);
++#ifdef HAVE_NS
++          ns_retain_object(img->background_transparent);
++#endif
+ 
+ 	  if (free_mask)
+ 	    Destroy_Image (mask, prev);
+@@ -1625,16 +1628,21 @@
+     {
+       Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap);
+       img->pixmap = NO_PIXMAP;
+-      img->background_valid = 0;
+ #ifdef HAVE_NS
+-      ns_release_object(img->background);
++      if (img->background_valid)
++        ns_release_object(img->background);
+ #endif
++      img->background_valid = 0;
+     }
+ 
+   if (mask_p && img->mask)
+     {
+       Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
+       img->mask = NO_PIXMAP;
++#ifdef HAVE_NS
++      if (img->background_transparent_valid)
++        ns_release_object(img->background_transparent);
++#endif
+       img->background_transparent_valid = 0;
+     }
+ 
+@@ -4688,20 +4696,21 @@
+ 	  Lisp_Object color_val =
+ 	    (*get_color_table) (color_table, str, chars_per_pixel);
+ 
+-	  XPutPixel (ximg, x, y,
+ #ifndef HAVE_NS
++	  XPutPixel (ximg, x, y,
+ 		     (INTEGERP (color_val) ? XINT (color_val)
++		      : FRAME_FOREGROUND_PIXEL (f)));
+ #else
+-                     (STRINGP (color_val) ? *(void **)SDATA(color_val)
++          if (STRINGP (color_val))
++            XPutPixel (ximg, x, y, *(void **)SDATA(color_val));
+ #endif
+-		      : FRAME_FOREGROUND_PIXEL (f)));
+ #ifndef HAVE_NS
+ 	  XPutPixel (mask_img, x, y,
+ 		     (!EQ (color_val, Qt) ? PIX_MASK_DRAW
+ 		      : (have_mask = 1, PIX_MASK_RETAIN)));
+ #else
+           if (EQ(color_val, Qt))
+-              ns_set_alpha(ximg, x, y, 0);
++            ns_set_alpha(ximg, x, y, 0);
+ #endif
+ 	}
+       if (y + 1 < height)
+@@ -5477,7 +5486,7 @@
+       Display *dpy = FRAME_X_DISPLAY (f);
+       GC gc;
+ 
+-#ifndef HAVE_NS  //PENDING: NS XPM support
++#ifndef HAVE_NS  //PENDING
+ 
+ #ifdef MAC_OS
+ #define MaskForeground(f)  PIX_MASK_DRAW
+--- emacs-23.0.0_NS-9.0rc2a/src/frame.c	2007-08-21 01:57:48.000000000 +0300
++++ src/frame.c	2007-09-25 22:46:40.000000000 +0300
+@@ -734,6 +734,11 @@
+     }
+ #endif /* !WINDOWSNT */
+ 
++#ifdef COCOA
++  /* term gets no other notification of this */
++  Fraise_frame(Qnil);
++#endif
++
+   /* We want to make sure that the next event generates a frame-switch
+      event to the appropriate frame.  This seems kludgy to me, but
+      before you take it out, make sure that evaluating something like
+--- emacs-23.0.0_NS-9.0rc2a/src/nsterm.h	2007-09-19 18:13:06.000000000 +0300
++++ src/nsterm.h	2007-10-13 22:47:25.000000000 +0300
+@@ -78,7 +78,7 @@
+ - (void)keyDown:(NSEvent *)theEvent;
+ - (void)mouseDown:(NSEvent *)theEvent;
+ - (void)mouseUp:(NSEvent *)theEvent;
+-- setMiniwindowImage;
++- setMiniwindowImage: (BOOL)setMini;
+ 
+ // Emacs-side interface
+ - initFrameFromEmacs: (struct frame *) f;
+@@ -136,6 +136,7 @@
+      NSMutableDictionary *identifierToItem;
+      NSMutableArray *activeIdentifiers;
+      NSArray *prevIdentifiers;
++     unsigned long enablement, prevEnablement;
+    }
+ - initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
+ - (void) clearActive;
+@@ -369,8 +370,8 @@
+    no_highlight=0,
+    filled_box,
+    hollow_box,
+-   bar,
+-   line
++   underscore,
++   bar
+ };
+ 
+ 
+@@ -535,6 +536,7 @@
+   Lisp_Object icon_top;
+   Lisp_Object icon_left;
+   enum ns_cursor_types current_cursor, desired_cursor;
++  unsigned char last_inactive;
+ 
+   /* The size of the extra width currently allotted for vertical
+      scroll bars, in pixels.  */
+@@ -597,6 +599,7 @@
+ #define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color)
+ #define FRAME_NEW_CURSOR(f)  ((f)->output_data.ns->desired_cursor)
+ #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
++#define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive)
+ 
+ #ifndef COMPILING_MULTI_TERM
+ #define FRAME_FONT(f) ((f)->output_data.ns->font)
+--- emacs-23.0.0_NS-9.0rc2a/src/nsterm.m	2007-09-19 22:22:05.000000000 +0300
++++ src/nsterm.m	2007-10-14 21:27:38.000000000 +0300
+@@ -20,10 +20,9 @@
+ 
+ Originally by Carl Edman
+ Updated by Christian Limpach (chris at nice.ch)
+-OpenStep/Rhapsody  port by Scott Bender (sbender at harmony-ds.com)
++OpenStep/Rhapsody port by Scott Bender (sbender at harmony-ds.com)
+ MacOSX/Aqua port by Christophe de Dinechin (descubes at earthlink.net)
+ GNUstep port and post-20 update by Adrian Robert (arobert at cogsci.ucsd.edu)
+-
+ */
+ 
+ #include <math.h>
+@@ -241,11 +240,10 @@
+ static int select_nfds;
+ static NSAutoreleasePool *outerpool;
+ static BOOL ns_shutdown_properly = NO;
+-
+ static struct input_event *emacs_event = NULL;
+ static struct input_event *q_event_ptr = NULL;
+ static int n_emacs_events_pending = 0;
+-
++static NSMutableArray *ns_pending_files;
+ 
+ /* Convert modifiers in a NeXTSTEP event to emacs style modifiers.  */
+ #define NS_FUNCTION_KEY_MASK 0x800000
+@@ -348,8 +346,8 @@
+   if (!getenv("EMACSLOADPATH"))
+     {
+       NSArray *paths = [resourceDir stringsByAppendingPaths:
+-                                  [NSArray arrayWithObjects: @"lisp", @"leim",
+-                                                             @"site-lisp",nil]];
++                                  [NSArray arrayWithObjects: @"site-lisp", @"lisp",
++                                                             @"leim",nil]];
+       NSEnumerator *pathEnum = [paths objectEnumerator];
+       resourcePaths = @"";
+       while (resourcePath = [pathEnum nextObject])
+@@ -982,7 +980,9 @@
+ //   External: Show the window (X11 semantics)
+ // ----------------------------------------------------------------------------
+ {
+-  ns_raise_frame(f);
++  NSTRACE(x_make_frame_visible);
++  // not needed, as the only place that calls this (frame.c:Fraise_frame()) also calls raise_lower
++  // ns_raise_frame(f);
+ }
+ 
+ 
+@@ -993,6 +993,7 @@
+ // ----------------------------------------------------------------------------
+ {
+   NSView * view = FRAME_NS_VIEW(f);
++  NSTRACE(x_make_frame_invisible);
+   check_ns();
+   [[view window] orderOut:NSApp];
+ }
+@@ -1006,6 +1007,7 @@
+ {
+   NSView * view = FRAME_NS_VIEW(f);
+   struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
++  NSTRACE(x_iconify_frame);
+   check_ns();
+ 
+   if (dpyinfo->ns_highlight_frame == f)
+@@ -1035,7 +1037,9 @@
+ {
+   NSView *view = FRAME_NS_VIEW(f);
+   struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
++  NSTRACE(x_destroy_window);
+   check_ns();
++
+   [(EmacsView *)view setWindowClosing: YES]; // may not have been informed
+ 
+   BLOCK_INPUT;
+@@ -1430,15 +1434,13 @@
+     {
+       [[col colorUsingColorSpaceName:NSCalibratedWhiteColorSpace]
+             getWhite:&gray alpha:&alpha];
+-      sprintf(buf,"GRAY%02.2x%02.2x",
+-              (int)rint(gray*0xff),
+-              (int)rint(alpha*0xff));
++      sprintf(buf,"GRAY%02.2x%02.2x", lrint(gray*0xff), lrint(alpha*0xff));
+       UNBLOCK_INPUT;
+       return build_string(buf);
+     }
+ 
+-  sprintf(buf,"ARGB%02.2x%02.2x%02.2x%02.2x",(int)rint(alpha*0xff),
+-          (int)rint(red*0xff),(int)rint(green*0xff),(int)rint(blue*0xff));
++  sprintf(buf,"ARGB%02.2x%02.2x%02.2x%02.2x",lrint(alpha*0xff),
++          lrint(red*0xff), lrint(green*0xff), lrint(blue*0xff));
+ 
+   UNBLOCK_INPUT;
+   return build_string(buf);
+@@ -1588,20 +1590,28 @@
+   int xchar, ychar;
+   Lisp_Object frame, tail;
+   struct frame *f;
+-  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (*fp);
++  struct ns_display_info *dpyinfo;
+ 
+   NSTRACE(ns_mouse_position);
+ 
++  if (*fp == NULL)
++    {
++      fprintf(stderr, "Warning: ns_mouse_position() called with null *fp.\n");
++      return;
++    }
++
++  dpyinfo = FRAME_NS_DISPLAY_INFO (*fp);
++
+   BLOCK_INPUT;
+ 
+-  if (! NILP (last_mouse_scroll_bar) && insist == 0)
++  if (last_mouse_scroll_bar != nil && insist == 0)
+     {
+       //PENDING: we do not use this path at the moment because drag events will
+       // go directly to the EmacsScroller.  Leaving code in for now.
+       [last_mouse_scroll_bar getMouseMotionPart: part window:bar_window
+                                               x:x y:y];
+       if (time) *time = last_mouse_movement_time;
+-      last_mouse_scroll_bar = Qnil;
++      last_mouse_scroll_bar = nil;
+     }
+   else
+     {
+@@ -1610,7 +1620,7 @@
+         if (FRAME_NS_DISPLAY (XFRAME (frame)) == FRAME_NS_DISPLAY (*fp))
+           XFRAME (frame)->mouse_moved = 0;
+ 
+-      last_mouse_scroll_bar = Qnil;
++      last_mouse_scroll_bar = nil;
+       if (last_mouse_frame && FRAME_LIVE_P(last_mouse_frame))
+         f = last_mouse_frame;
+       else
+@@ -1628,8 +1638,8 @@
+           if (bar_window) *bar_window = Qnil;
+           if (part) *part = 0; //scroll_bar_handle;
+ 
+-          if (x) XSETINT (*x, (int)rint(position.x));
+-          if (y) XSETINT (*y, (int)rint(position.y));
++          if (x) XSETINT (*x, lrint(position.x));
++          if (y) XSETINT (*y, lrint(position.y));
+           if (time) *time = last_mouse_movement_time;
+           *fp = f;
+         }
+@@ -2051,7 +2061,8 @@
+   struct frame *f = XFRAME (WINDOW_FRAME (w));
+   struct face *face = p->face;
+   int rowY;
+-  static EmacsImage **bimgs;
++  static EmacsImage **bimgs = NULL;
++  static int nBimgs = 0;
+   // NS-specific: move internal border inside fringe
+   int x = p->bx < 0 ? p->x : p->bx;
+   int wd = p->bx < 0 ? p->wd : p->nx;
+@@ -2064,10 +2075,21 @@
+   int xAdjust = FRAME_INTERNAL_BORDER_WIDTH(f) *
+     (fringeOnVeryLeft ? -1 : (fringeOnVeryRight ? 1 : 0));
+ 
+-  if (!bimgs)
++  // grow bimgs if needed
++  if (nBimgs < max_used_fringe_bitmap)
+     {
+-      bimgs = xmalloc(max_used_fringe_bitmap * sizeof (EmacsImage *));
+-      bzero(bimgs, max_used_fringe_bitmap * sizeof (EmacsImage *));
++      EmacsImage **newBimgs =
++        xmalloc(max_used_fringe_bitmap * sizeof (EmacsImage *));
++      bzero(newBimgs, max_used_fringe_bitmap * sizeof (EmacsImage *));
++
++      if (nBimgs)
++        {
++          bcopy(bimgs, newBimgs, nBimgs * sizeof (EmacsImage *));
++          xfree(bimgs);
++        }
++
++      bimgs = newBimgs;
++      nBimgs = max_used_fringe_bitmap;
+     }
+ 
+   /* Must clip because of partially visible lines.  */
+@@ -2143,16 +2165,17 @@
+ //   External call (RIF): draw cursor
+ // ----------------------------------------------------------------------------
+ {
+-  NSRect r,s;
++  NSRect r, s;
+   int fx, fy, h;
+   struct frame *f = WINDOW_XFRAME (w);
+   struct glyph *phys_cursor_glyph;
+   int overspill;
++  unsigned char drawGlyph = 0, cursorType, oldCursorType;
+ 
+   NSTRACE(dumpcursor);
+ 
+   if (!on_p)
+-    return;  //PENDING: erase?
++      return;
+ 
+   w->phys_cursor_type = cursor_type;
+   w->phys_cursor_on_p = 1;
+@@ -2189,7 +2212,8 @@
+     r.size.width -= overspill;
+ 
+   //PENDING: 23: use emacs stored f->cursor_type instead of ns-specific
+-  FRAME_CURSOR(f) = FRAME_NEW_CURSOR(f);
++  oldCursorType = FRAME_CURSOR(f);
++  cursorType = FRAME_CURSOR(f) = FRAME_NEW_CURSOR(f);
+   FRAME_CURSOR_COLOR(f) = FRAME_NEW_CURSOR_COLOR(f);
+ 
+   //PENDING: only needed in rare cases with last-resort font in HELLO..
+@@ -2197,41 +2221,64 @@
+   ns_clip_to_row(w, glyph_row, -1, NULL);
+ //  ns_focus(f, &r, 1);
+ 
+-  // draw the cursor
+-  // needed for bar and line cursors
+-  [FRAME_BACKGROUND_COLOR(f) set];
+-  NSRectFill(r);
+-  [FRAME_CURSOR_COLOR(f) set];
++  if (FRAME_LAST_INACTIVE(f))
++    {
++      // previously hollow box; clear entire area
++      [FRAME_BACKGROUND_COLOR(f) set];
++      NSRectFill(r);
++      drawGlyph = 1;
++      FRAME_LAST_INACTIVE(f) = NO;
++    }
++
++  // prepare to draw
++  if (cursorType == no_highlight || cursor_type == NO_CURSOR)
++    {
++      // clearing for blink: erase the cursor itself
++      [FRAME_BACKGROUND_COLOR(f) set];
++      cursorType = oldCursorType; // just clear what we had before
++    }
++  else
++      [FRAME_CURSOR_COLOR(f) set];
++
++  if (!active_p)
++    {
++      // inactive window: ignore what we just set and use a hollow box
++      cursorType = hollow_box;
++      [FRAME_CURSOR_COLOR(f) set];
++    }
+ 
+-  switch (active_p ? FRAME_CURSOR(f) : hollow_box)
++  switch (cursorType)
+     {
+     case no_highlight:
+       break;
+     case filled_box:
+       NSRectFill(r);
++      drawGlyph = 1;
+       break;
+     case hollow_box:
+       NSRectFill(r);
+       [FRAME_BACKGROUND_COLOR(f) set];
+       NSRectFill(NSInsetRect(r, 1, 1));
+       [FRAME_CURSOR_COLOR(f) set];
++      drawGlyph = 1;
+       break;
+-    case bar:
++    case underscore:
+       s = r;
+-      s.origin.y += 0.75 * s.size.height;
+-      s.size.height *= 0.25;
++      s.origin.y += lrint(0.75 * s.size.height);
++      s.size.height = lrint(s.size.height * 0.25);
+       NSRectFill(s);
+       break;
+-    case line:
++    case bar:
+       s = r;
+-      s.size.width = 2;
++      s.size.width = 1;
+       NSRectFill(s);
+       break;
+     }
+   ns_unfocus(f);
+ 
+-  // draw the character under the cursor
+-  draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
++  // if needed, draw the character under the cursor
++  if (drawGlyph)
++    draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+ }
+ 
+ 
+@@ -2570,7 +2617,9 @@
+ 
+   bg_x = x;
+   bg_y =  s->slice.y == 0 ? s->y : s->y + box_line_vwidth;
+-  bg_height = s->height - 2 * box_line_vwidth;
++  bg_height = s->height;
++  // other terms have this, but was causing problems w/tabbar mode
++  // - 2 * box_line_vwidth;
+ 
+   if (s->slice.x == 0) x += s->img->hmargin;
+   if (s->slice.y == 0) y += s->img->vmargin;
+@@ -2600,9 +2649,8 @@
+           br.size.height += br.origin.y;
+           br.origin.y = 0;
+         }
+-      if (br.origin.x <= fibw+1)
++      if (br.origin.x <= fibw+1 + box_line_vwidth)
+         {
+-          br.size.height += 2*box_line_vwidth;
+           br.size.width += br.origin.x;
+           br.origin.x = 0;
+         }
+@@ -2868,19 +2916,28 @@
+   [outerpool release];
+   outerpool = [[NSAutoreleasePool alloc] init];
+ 
+-    /* We must always send one NX_APPDEFINED event to ourself, otherwise
+-       [NXApp run] will never exit.  */
+-  send_appdefined = YES;
+-
+-  if (!expected)
++  /* If we've got pending open-file requests, attend to the next one of those. */
++  if (ns_pending_files && [ns_pending_files count] != 0
++      && [NSApp openFile: [ns_pending_files objectAtIndex: 0]])
+     {
+-      /* Post an application defined event on the event queue.  When this is
+-         received the [NXApp run] will return, thus having processed all
+-         events which are currently queued, if any.  */
+-      ns_send_appdefined (-1);
++      [ns_pending_files removeObjectAtIndex: 0];
+     }
++  else
++    {
++      /* Run and wait for events.  We must always send one NX_APPDEFINED event
++         to ourself, otherwise [NXApp run] will never exit.  */
++      send_appdefined = YES;
+ 
+-  [NSApp run];
++      if (!expected)
++        {
++          /* Post an application defined event on the event queue.  When this is
++             received the [NXApp run] will return, thus having processed all
++             events which are currently queued, if any.  */
++          ns_send_appdefined (-1);
++        }
++
++      [NSApp run];
++    }
+ 
+   nevents = n_emacs_events_pending;
+   n_emacs_events_pending = 0;
+@@ -2948,11 +3005,11 @@
+       if (!NUMBERP(ns_cursor_blink_rate))
+         ns_cursor_blink_rate = make_float(0.5);
+       cursor_blink_entry =
+-        [[NSTimer scheduledTimerWithTimeInterval: XFLOATINT(ns_cursor_blink_rate)
+-                                          target: NSApp
+-                                        selector: @selector(cursor_blink_handler:)
+-                                        userInfo:0
+-                                         repeats:YES]
++       [[NSTimer scheduledTimerWithTimeInterval: XFLOATINT(ns_cursor_blink_rate)
++                                         target: NSApp
++                                       selector: @selector(cursor_blink_handler:)
++                                       userInfo:0
++                                        repeats:YES]
+           retain];
+     }
+   else if (NILP(ns_cursor_blink_mode) && cursor_blink_entry)
+@@ -3464,11 +3521,17 @@
+   // Start app and create the main menu, window, view.
+   // Needs to be here because ns_initialize_display_info() uses AppKit classes.
+   // The view will then ask the NSApp to stop and return to Emacs.
++  ns_pending_files = [[NSMutableArray alloc] init];
+   [EmacsApp sharedApplication];
+   if (NSApp == nil)
+     return NULL;
+   [NSApp setDelegate: NSApp];
+ 
++  // debugging: log all notifications
++//   [[NSNotificationCenter defaultCenter] addObserver: NSApp
++//                                            selector:@selector(logNotification:)
++//                                                name: nil object: nil];
++
+   dpyinfo = (struct ns_display_info *)xmalloc(sizeof(struct ns_display_info));
+   bzero (dpyinfo, sizeof (struct ns_display_info));
+ 
+@@ -3798,6 +3861,15 @@
+ 
+ @implementation EmacsApp
+ 
++- (void)logNotification:(NSNotification *)notification
++{
++  char *name = [[notification name] UTF8String];
++  if (!strstr(name, "Update") && !strstr(name, "NSMenu")
++      && !strstr(name, "WindowNumber"))
++    NSLog(@"notification: '%@'", [notification name]);
++}
++
++
+ - (void)sendEvent:(NSEvent *)theEvent
+ // ----------------------------------------------------------------------------
+ //   Events posted by ns_send_appdefined interrupt the run loop here
+@@ -3873,6 +3945,15 @@
+   NSTRACE(applicationDidFinishLaunching);
+   ns_send_appdefined (-2);
+ }
++/*- (void)applicationWillFinishLaunching:(NSNotification *)notification
++// ----------------------------------------------------------------------------
++//   When application is loaded, terminate event loop in ns_term_init
++// ----------------------------------------------------------------------------
++{
++  NSTRACE(applicationWillFinishLaunching);
++fprintf(stderr, "willfinishlaunching\n");
++  ns_send_appdefined (-2);
++}*/
+ 
+ 
+ - (void) terminate: (id)sender
+@@ -3886,10 +3967,8 @@
+ }
+ 
+ 
+-// Open a file (used by below)
+--(BOOL) openFile: (char *)fileName
+-        fromLine: (int)startLine
+-          toLine: (int)endLine
++// Open a file (used by below, after going into queue read by ns_read_socket)
++-(BOOL) openFile: (NSString *)fileName
+ {
+   struct frame *emacsframe = SELECTED_FRAME();
+   NSEvent *theEvent = [NSApp currentEvent];
+@@ -3899,11 +3978,8 @@
+ 
+   emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
+   emacs_event->code = KEY_NS_OPEN_FILE_LINE;
+-  ns_input_file = append2(ns_input_file, build_string(fileName));
+-  if (startLine == endLine)
+-    ns_input_line = (startLine >= 0) ? make_number(startLine) : Qnil;
+-  else
+-    ns_input_line = Fcons(make_number(startLine), make_number(endLine));
++  ns_input_file = append2(ns_input_file, build_string([fileName UTF8String]));
++  ns_input_line = Qnil; // can be start or cons start,end
+   emacs_event->modifiers=0;
+   EV_TRAILER(theEvent);
+ 
+@@ -3912,35 +3988,37 @@
+ 
+ 
+ //   Notification from the Workspace to open a file
+-- (BOOL)application: sender openFile: (NSString *)fileName
++- (BOOL)application: sender openFile: (NSString *)file
+ {
+-  return [self openFile: (char *) [fileName UTF8String] fromLine:-1 toLine:-1];
++  [ns_pending_files addObject: file];
++  return YES;
+ }
+ 
+ 
+ //   Open a file as a temporary file
+ - (BOOL)application:sender openTempFile:(NSString *)file
+ {
+-  return [self application: sender openFile: file];
++  [ns_pending_files addObject: file];
++  return YES;
+ }
+ 
+ 
+ //   Notification from the Workspace to open a file noninteractively (?)
+-- (BOOL)application: sender openFileWithoutUI: (NSString *)fileName
++- (BOOL)application: sender openFileWithoutUI: (NSString *)file
+ {
+-  return [self openFile: (char *) [fileName UTF8String] fromLine:-1 toLine:-1];
++  [ns_pending_files addObject: file];
++  return YES;
+ }
+ 
+ 
+ //   Notification from the Workspace to open multiple files
+ - (void)application: sender openFiles: (NSArray *)fileList
+ {
+-  NSEnumerator *filenames = [fileList objectEnumerator];
+-  NSString *fileName;
+-  while ((fileName = [filenames nextObject]) != nil)
+-    if ([self openFile: (char *)[fileName UTF8String] fromLine:-1 toLine:-1]
+-        == NO)
+-      return;
++  NSEnumerator *files = [fileList objectEnumerator];
++  NSString *file;
++  while ((file = [files nextObject]) != nil)
++    [ns_pending_files addObject: file];
++  return YES;
+ }
+ 
+ 
+@@ -3980,7 +4058,7 @@
+     }
+   else
+     {
+-      f->output_data.ns->desired_cursor=no_highlight;
++      f->output_data.ns->desired_cursor = no_highlight;
+     }
+   update_window_cursor (XWINDOW(FRAME_SELECTED_WINDOW(f)), 1);
+   //x_update_cursor (f, 1);
+@@ -4058,8 +4136,8 @@
+ 
+       size = [newFont pointSize];
+       //PENDING: stick w/integer sizes for now.
+-//        if (size == rint(size))
+-        ns_input_fontsize = make_number((int)rint(size));
++//        if (size == lrint(size))
++        ns_input_fontsize = make_number(lrint(size));
+ //        else
+ //          ns_input_fontsize = make_float(size);
+       ns_input_font= build_string([[newFont familyName/*fontName*/] UTF8String]);
+@@ -4489,8 +4567,8 @@
+       emacs_event->modifiers = EV_MODIFIERS (theEvent)
+                              | EV_UDMODIFIERS (theEvent);
+     }
+-  XSETINT (emacs_event->x, (int)rint(p.x));
+-  XSETINT (emacs_event->y, (int)rint(p.y));
++  XSETINT (emacs_event->x, lrint(p.x));
++  XSETINT (emacs_event->y, lrint(p.y));
+   EV_TRAILER (theEvent);
+ }
+ 
+@@ -4706,7 +4784,7 @@
+   struct frame *old_focus = dpyinfo->ns_focus_frame;
+ 
+   NSTRACE(windowDidBecomeKey);
+-  
++
+   if (emacsframe != old_focus)
+     dpyinfo->ns_focus_frame = emacsframe;
+   ///last_mouse_frame = emacsframe;?
+@@ -4736,6 +4814,7 @@
+     {
+       FRAME_NEW_CURSOR(emacsframe) = hollow_box;
+       x_update_cursor(emacsframe, 1);
++      FRAME_LAST_INACTIVE(emacsframe) = YES;
+     }
+ 
+   if (dpyinfo->ns_highlight_frame == emacsframe)
+@@ -4761,7 +4840,6 @@
+ - (void)windowWillMiniaturize:sender
+ {
+   NSTRACE(windowWillMiniaturize);
+-  [self setMiniwindowImage];
+ }
+ 
+ 
+@@ -5090,7 +5168,7 @@
+ 
+   NSTRACE(performDragOperation);
+   position = [self convertPoint:[sender draggingLocation] fromView:nil];
+-  x = (int)rint(position.x);  y = (int)rint(position.y);
++  x = lrint(position.x);  y = lrint(position.y);
+ 
+   pb = [sender draggingPasteboard];
+   type = [pb availableTypeFromArray:ns_drag_types];
+@@ -5211,19 +5289,23 @@
+ }
+ 
+ 
+-- setMiniwindowImage
++// setMini=YES means set from internal (gives a finder icon), NO means set nil
++// (gives a miniaturized version of the window); currently we use the latter for
++// frames whose active buffer doesn't correspond to any file (e.g., '*scratch*')
++- setMiniwindowImage: (BOOL) setMini
+ {
+   id image = [[self window] miniwindowImage];
+   NSTRACE(setMiniwindowImage);
+ 
+-  // NOTE: under Cocoa this always returns nil, documentation about
+-  // "AppleDockIconEnabled" notwithstanding, however the set message
++  // NOTE: under Cocoa miniwindowImage always returns nil, documentation
++  // about "AppleDockIconEnabled" notwithstanding, however the set message
+   // below has its effect nonetheless.
+   if (image != emacsframe->output_data.ns->miniimage)
+     {
+       if (image && [image isKindOfClass: [EmacsImage class]])
+         [image release];
+-      [[self window] setMiniwindowImage: emacsframe->output_data.ns->miniimage];
++      [[self window] setMiniwindowImage:
++                       setMini ? emacsframe->output_data.ns->miniimage : nil];
+     }
+ 
+   return self;
+@@ -5739,7 +5821,7 @@
+   [cursorBlinkSlider setFloatValue: prevBlinkRate];
+   [cursorTypeMatrix selectCellWithTag: (cursorType == filled_box ? 1 :
+                                         (cursorType == bar ? 2 :
+-                                         (cursorType == line ? 3 : 4)))];
++                                         (cursorType == underscore ? 3 : 4)))];
+   selectItemWithTag(alternateModMenu, ns_lisp_to_mod(ns_alternate_modifier));
+   selectItemWithTag(commandModMenu, ns_lisp_to_mod(ns_command_modifier));
+ #ifdef COCOA
+@@ -5813,7 +5895,7 @@
+   FRAME_NEW_CURSOR(frame) =
+                          (cursorTag == 1 ? filled_box :
+                           (cursorTag == 2 ? bar :
+-                           (cursorTag == 3 ? line : hollow_box)));
++                           (cursorTag == 3 ? underscore : hollow_box)));
+   store_frame_param(frame, Qcursor_type,
+                     ns_cursor_type_to_lisp(FRAME_NEW_CURSOR(frame)));
+   ns_alternate_modifier = ns_mod_to_lisp(altTag);
+--- emacs-23.0.0_NS-9.0rc2a/src/nsmenu.m	2007-09-17 04:10:30.000000000 +0300
++++ src/nsmenu.m	2007-10-15 20:58:50.000000000 +0300
+@@ -743,12 +743,11 @@
+ static Lisp_Object
+ ns_popup_menu(Lisp_Object position, Lisp_Object menu)
+ {
+-  // NOTE: this also gets called when a choice is made in the app main menu;
+-  //       the second part of ns-menu-path is sent back
+   EmacsMenu *pmenu;
+   struct frame *f;
+   NSPoint p;
+   Lisp_Object window, x, y, tem, keymap, title;
++  struct gcpro gcpro1;
+   int specpdl_count = SPECPDL_INDEX (), specpdl_count2;
+   char *error_name = NULL;
+   int keymaps = 0;
+@@ -758,16 +757,14 @@
+ 
+   if (!NILP(position))
+     {
+-  
+       check_ns();
+   
+       if (EQ (position, Qt)
+           || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
+                                    || EQ (XCAR (position), Qtool_bar))))
+-
+         {
+           /* Use the mouse's current position.  */
+-          struct frame *new_f = 0;
++          struct frame *new_f = SELECTED_FRAME();
+ 
+           if (mouse_position_hook)
+             (*mouse_position_hook) (&new_f, 0, 0, 0, &x, &y, 0);
+@@ -821,18 +818,21 @@
+ 
+       p.x += XINT(x); p.y += XINT(y);
+ 
+-//       p = [FRAME_NS_VIEW(f) convertPoint: p toView: nil];
+-//       p = [[FRAME_NS_VIEW(f) window] convertBaseToScreen: p];
+-
+       XSETFRAME (Vmenu_updating_frame, f);
+     }
+   else
+-    {
+-      // no position given
++    {      // no position given
++      //PENDING: if called during dump, we need to stop precomputation of
++      // key equivalents (see below) because the keydefs in ns-win.el have
++      // not been loaded yet.
++      if (noninteractive)
++        return Qnil;
+       Vmenu_updating_frame = Qnil;
+     }
+ 
+   // now parse the lisp menus
++  title = Qnil;
++  GCPRO1 (title);
+ 
+   /* Decode the menu items from what was specified.  */
+ 
+@@ -899,8 +899,8 @@
+       keymaps = 0;
+     }
+ 
+-  // OK, now if no position given, we're just supposed to discard all that
+-  // work (except for whatever was cached during key equivalent computation)
++  // If no position given, that was a signal to just precompute and cache
++  // key equivalents, which was a side-effect of what we just did.
+   if (NILP (position))
+     {
+       discard_menu_items ();
+@@ -1169,15 +1169,8 @@
+       image = TOOLPROP (TOOL_BAR_ITEM_IMAGES);
+       if (VECTORP (image))
+ 	{
+-	  if (enabled_p)
+-              idx = (selected_p
+-		   ? TOOL_BAR_IMAGE_ENABLED_SELECTED
+-		   : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
+-	  else
+-              idx = (selected_p
+-		   ? TOOL_BAR_IMAGE_DISABLED_SELECTED
+-		   : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
+-
++          // NS toolbar auto-computes disabled and selected images
++          idx = TOOL_BAR_IMAGE_ENABLED_SELECTED;
+ 	  xassert (ASIZE (image) >= idx);
+ 	  image = AREF (image, idx);
+ 	}
+@@ -1257,6 +1250,7 @@
+   [self setDelegate: self];
+   identifierToItem = [[NSMutableDictionary alloc] initWithCapacity: 10];
+   activeIdentifiers = [[NSMutableArray alloc] initWithCapacity: 8];
++  prevEnablement = enablement = 0L;
+   return self;
+ }
+ 
+@@ -1273,11 +1267,14 @@
+   [prevIdentifiers release];
+   prevIdentifiers = [activeIdentifiers copy];
+   [activeIdentifiers removeAllObjects];
++  prevEnablement = enablement;
++  enablement = 0L;
+ }
+ 
+ - (BOOL) changed
+ {
+-  return [activeIdentifiers isEqualToArray: prevIdentifiers] ? NO : YES;
++  return [activeIdentifiers isEqualToArray: prevIdentifiers] &&
++    enablement == prevEnablement ? NO : YES;
+ }
+ 
+ - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx
+@@ -1305,6 +1302,7 @@
+   // 3) update state
+   [identifierToItem setObject: item forKey: identifier];
+   [activeIdentifiers addObject: identifier];
++  enablement = (enablement << 1) | (enabled == YES);
+ }
+ 
+ // This overrides super's implementation, which automatically sets
+--- emacs-23.0.0_NS-9.0rc2a/src/nsfns.m	2007-09-17 16:35:23.000000000 +0300
++++ src/nsfns.m	2007-10-14 21:22:54.000000000 +0300
+@@ -755,6 +755,8 @@
+   id image=nil;
+   Lisp_Object chain, elt;
+   NSAutoreleasePool *pool;
++  BOOL setMini = YES;
++
+   NSTRACE(ns_implicitly_set_icon_type);
+ 
+   BLOCK_INPUT;
+@@ -803,11 +805,14 @@
+     }
+ 
+   if (image == nil)
+-    image = [[[NSWorkspace sharedWorkspace] iconForFileType:@"text"] retain];
++    {
++      image = [[[NSWorkspace sharedWorkspace] iconForFileType:@"text"] retain];
++      setMini = NO;
++    }
+ 
+   [f->output_data.ns->miniimage release];
+-  f->output_data.ns->miniimage=image;
+-  [view setMiniwindowImage];
++  f->output_data.ns->miniimage = image;
++  [view setMiniwindowImage: setMini];
+   [pool release];
+   UNBLOCK_INPUT;
+ }
+@@ -818,6 +823,8 @@
+ {
+   EmacsView *view = FRAME_NS_VIEW(f);
+   id image = nil;
++  BOOL setMini = YES;
++
+   NSTRACE(ns_set_icon_type);
+ 
+   if (!NILP (arg) && SYMBOLP (arg))
+@@ -840,10 +847,14 @@
+     image=[NSImage imageNamed:[NSString stringWithUTF8String:
+                                             XSTRING(arg)->data]];
+ 
+-  if (image==nil) image=[NSImage imageNamed:@"text"];
++  if (image == nil)
++    {
++      image = [NSImage imageNamed:@"text"];
++      setMini = NO;
++    }
+ 
+-  f->output_data.ns->miniimage=image;
+-  [view setMiniwindowImage];
++  f->output_data.ns->miniimage = image;
++  [view setMiniwindowImage: setMini];
+ }
+ 
+ 
+@@ -867,11 +878,11 @@
+   else if (XTYPE(arg) == Lisp_Symbol)
+     str=XSTRING(XSYMBOL(arg)->xname)->data;
+   else return -1;
+-  if (!strcmp(str,"bar"))    return bar;
+-  if (!strcmp(str,"box"))    return filled_box;
+-  if (!strcmp(str,"hollow")) return hollow_box;
+-  if (!strcmp(str,"line"))   return line;
+-  if (!strcmp(str,"no"))     return no_highlight;
++  if (!strcmp(str,"box"))	 return filled_box;
++  if (!strcmp(str,"hollow"))	 return hollow_box;
++  if (!strcmp(str,"underscore")) return underscore;
++  if (!strcmp(str,"bar"))	 return bar;
++  if (!strcmp(str,"no"))	 return no_highlight;
+   return -1;
+ }
+ 
+@@ -881,12 +892,12 @@
+ {
+   switch (arg)
+     {
+-    case bar: return intern("bar");
+     case filled_box: return Qbox;
+     case hollow_box: return intern("hollow");
+-    case line: return intern("line");
++    case underscore: return intern("underscore");
++    case bar:	     return intern("bar");
+     case no_highlight:
+-    default: return intern("no");
++    default:	     return intern("no");
+     }
+ }
+ 
+@@ -904,8 +915,8 @@
+   else
+     {
+       store_frame_param(f,Qcursor_type,oldval);
+-      error ("the `cursor-type' frame parameter should be either `no', `bar', \
+-`box', `hollow' or `line'.");
++      error ("the `cursor-type' frame parameter should be either `no', `box', \
++`hollow', `underscore' or `bar'.");
+     }
+ 
+   update_mode_lines++;
+@@ -2227,10 +2238,10 @@
+ 
+   [[col colorUsingColorSpaceName:NSCalibratedRGBColorSpace]
+         getRed:&red green:&green blue:&blue alpha:&alpha];
+-  rgba[0] = make_number ((int) rint(red*65280));
+-  rgba[1] = make_number ((int) rint(green*65280));
+-  rgba[2] = make_number ((int) rint(blue*65280));
+-  rgba[3] = make_number ((int) rint(alpha*65280));
++  rgba[0] = make_number (lrint(red*65280));
++  rgba[1] = make_number (lrint(green*65280));
++  rgba[2] = make_number (lrint(blue*65280));
++  rgba[3] = make_number (lrint(alpha*65280));
+ 
+   return Flist (4, rgba);
+ }
+--- emacs-23.0.0_NS-9.0rc2a/src/nsimage.m	2007-09-19 18:16:53.000000000 +0300
++++ src/nsimage.m	2007-10-13 23:35:59.000000000 +0300
+@@ -316,6 +316,10 @@
+   }
+ 
+   [self addRepresentation: bmRep];
++
++  bzero(planes[0], w*h);
++  bzero(planes[1], w*h);
++  bzero(planes[2], w*h);
+   [self setXBMColor: [NSColor blackColor]];
+   return self;
+ }
+@@ -342,15 +346,28 @@
+   [rgbColor getRed: &r green: &g blue: &b alpha: &a];
+ 
+   [bmRep getBitmapDataPlanes: planes];
+-  memset(planes[0], r*0xff, len);
+-  memset(planes[1], g*0xff, len);
+-  memset(planes[2], b*0xff, len);
++
++  // we used to just do this, but Cocoa seems to have a bug when rendering
++  // an alpha-masked image onto a dark background where it bloats the mask
++//   memset(planes[0..2], r,g,b*0xff, len);
++  {
++    int i, len = s.width*s.height;
++    int rr = r * 0xff, gg = g * 0xff, bb = b * 0xff;
++    for (i=0; i<len; i++)
++      if (planes[3][i] != 0)
++        {
++          planes[0][i] = rr;
++          planes[1][i] = gg;
++          planes[2][i] = bb;
++        }
++  }
+ }
+ 
+ 
+ - initForXPMWithDepth: (int)depth width: (int)width height: (int)height
+ {
+   NSSize s = {width, height};
++  int i;
+ 
+   [self initWithSize: s];
+ 
+@@ -363,6 +380,8 @@
+                                   bytesPerRow: width bitsPerPixel: 0];
+ 
+   [bmRep getBitmapDataPlanes: pixmapData];
++  for (i=0; i<4; i++)
++    bzero(pixmapData[i], width*height);
+   [self addRepresentation: bmRep];
+   return self;
+ }
+--- emacs-23.0.0_NS-9.0rc2a/lisp/frame.el	2007-08-21 01:56:18.000000000 +0300
++++ lisp/frame.el	2007-09-23 03:38:59.000000000 +0300
+@@ -706,7 +706,7 @@
+ 	(nreverse frame-initial-geometry-arguments))
+   (cdr param-list))
+ 
+-(defcustom focus-follows-mouse (not (eq window-system 'mac))
++(defcustom focus-follows-mouse (not (memq window-system '(mac ns)))
+   "*Non-nil if window system changes focus when you move the mouse.
+ You should set this variable to tell Emacs how your window manager
+ handles focus, since there is no way in general for Emacs to find out
+--- emacs-23.0.0_NS-9.0rc2a/man/ns-emacs.texi	2007-09-11 14:43:46.000000000 +0300
++++ man/ns-emacs.texi	2007-09-25 00:57:31.000000000 +0300
+@@ -405,9 +405,9 @@
+ @item
+ Box - the cursor is displayed as a box
+ @item
+-Bar - the cursor is displayed as a horizontal bar
++Underscore - the cursor is displayed as a horizontal bar
+ @item
+-Line - the cursor is displayed as a vertical bar
++Bar - the cursor is displayed as a vertical bar
+ @item
+ Hollow - the cursor is displayed as a box with an outline but no fill
+ @end itemize
+@@ -540,7 +540,7 @@
+ 
+ @item CursorType
+ Name of the default cursor type for Emacs.  Allowed values are
+- at samp{bar}, @samp{box}, @samp{hollow}, @samp{line} and @samp{no}.
++ at samp{box}, @samp{hollow}, @samp{underscore}, @samp{bar},  @samp{line} and @samp{no}.
+ 
+ @example
+ defaults write Emacs CursorType box
+--- emacs-23.0.0_NS-9.0rc2a/nextstep/Cocoa/Info.plist	2007-09-20 14:20:38.000000000 +0300
++++ nextstep/Cocoa/Info.plist	2007-09-25 23:57:10.000000000 +0300
+@@ -105,6 +105,10 @@
+ 			</array>
+ 			<key>CFBundleTypeName</key>
+ 			<string>Any</string>
++			<key>CFBundleTypeOSTypes</key>
++			<array>
++				<string>****</string>
++			</array>
+ 			<key>CFBundleTypeRole</key>
+ 			<string>Editor</string>
+ 		</dict>
+diff -Naur emacs-23.0.0_NS-9.0rc2a/nextstep/Cocoa/preferences.nib/keyedobjects.nib emacs/nextstep/Cocoa/preferences.nib/keyedobjects.nib
+--- emacs-23.0.0_NS-9.0rc2a/nextstep/Cocoa/preferences.nib/keyedobjects.nib	2007-09-11 06:34:28.000000000 +0300
++++ nextstep/Cocoa/preferences.nib/keyedobjects.nib	2007-09-25 23:08:20.000000000 +0300
+@@ -1,35 +1,42 @@


More information about the macports-changes mailing list