diff -r d0c4fde41a48 .cvsignore --- a/.cvsignore Tue Jul 22 20:55:26 2008 +0000 +++ b/.cvsignore Wed Jul 23 16:36:24 2008 +0200 @@ -15,3 +15,4 @@ lock site-lisp update.log +Emacs.app diff -r d0c4fde41a48 Makefile.in --- a/Makefile.in Tue Jul 22 20:55:26 2008 +0000 +++ b/Makefile.in Wed Jul 23 16:36:24 2008 +0200 @@ -92,6 +92,9 @@ ### for, like `mips-dec-ultrix' or `sparc-sun-sunos'. configuration=@configuration@ +### the window system to use +window_system=@window_system@ + # ==================== Where To Install Things ==================== # The default location for installation. Everything is placed in @@ -164,13 +167,12 @@ # Where to find the application default. x_default_search_path=@x_default_search_path@ -# Location to install Emacs.app on Mac OS X -carbon_appdir=@carbon_appdir@ +# Location to install Emacs.app on GNUstep & Mac OS X -# Location to install Emacs.app under NeXT/Open/GNUstep / Cocoa -ns_appdir=@ns_appdir@ -ns_appbindir=@ns_appbindir@ -ns_appresdir=@ns_appresdir@ +# Location to install Emacs.app under NeXT/Open/GNUstep / Mac OS X +appdir=@appdir@ +appbindir=@appbindir@ +appresdir=@appresdir@ # Where the etc/emacs.desktop file is to be installed. desktopdir=$(datarootdir)/applications @@ -410,19 +412,21 @@ ${INSTALL_DATA} lib-src/$$f $(DESTDIR)${archlibdir}/$$f; \ else true; fi ; \ done - if test "${carbon_appdir}" != ""; then \ - umask 022; mkdir -p $(DESTDIR)${carbon_appdir}/Emacs.app; \ - (cd mac/Emacs.app; (tar -chf - . | \ - (cd $(DESTDIR)${carbon_appdir}/Emacs.app; umask 022; tar -xvf - \ - && cat > /dev/null))) || exit 1; \ + if test "${appdir}" != "" && test "${window_system}" = "mac"; then \ + umask 022; \ + mkdir -p ${DESTDIR}${appdir} ${DESTDIR}${datadir}/$(EMACSFULL) && \ + cp -RPp mac/Emacs.app ${DESTDIR}${appdir}; \ + if test -d site-lisp; then \ + cp -RPp site-lisp ${DESTDIR}${datadir}/$(EMACSFULL); \ + fi; \ fi - if test "${ns_appdir}" != ""; then \ - ( cd ${ns_appresdir} ; \ + if test "${appdir}" != "" && test "${window_system}" = "nextstep"; then \ + ( cd ${appresdir} ; \ if test -d share/emacs ; then mv -f share/emacs/*/* . ; fi ; \ if test -d info ; then mv -f share/info . ; fi ; \ rm -fr share ) ; \ - ( cd ${ns_appbindir}/libexec ; mv -f emacs/*/*/* . ; rm -fr emacs ) ; \ - ( cd ${ns_appbindir}/bin ; rm -f emacs emacs-23* ; \ + ( cd ${appbindir}/libexec ; mv -f emacs/*/*/* . ; rm -fr emacs ) ; \ + ( cd ${appbindir}/bin ; rm -f emacs emacs-23* ; \ ln -sf ../libexec/* .) ; \ else true ; fi @@ -471,7 +475,7 @@ && (echo "Copying $${dir} to $${dest}..." ; \ (cd $${dir}; tar -chf - . ) \ | (cd $${dest}; umask 022; \ - tar -xvf - && cat > /dev/null) || exit 1; \ + tar -xf - && cat > /dev/null) || exit 1; \ find $${dest} -exec chown $${installuser} {} ';' ;\ for subdir in `find $${dest} -type d ! -name RCS ! -name CVS -print` ; do \ chmod a+rx $${subdir} ; \ @@ -519,7 +523,7 @@ fi; \ echo "Copying etc/$${docfile} to $(DESTDIR)${docdir} ..." ; \ (cd ./etc; tar -chf - $${docfile}) \ - |(cd $(DESTDIR)${docdir}; umask 022; tar -xvf - && cat > /dev/null) || exit 1; \ + |(cd $(DESTDIR)${docdir}; umask 022; tar -xf - && cat > /dev/null) || exit 1; \ (cd $(DESTDIR)$(docdir); \ $(set_installuser); \ chown $${installuser} DOC*; chmod a+r DOC*; \ @@ -533,7 +537,7 @@ then \ echo "Copying lisp/*.el and lisp/*.elc to $(DESTDIR)${lispdir} ..." ; \ (cd lisp; tar -chf - *.el *.elc) \ - |(cd $(DESTDIR)${lispdir}; umask 022; tar -xvf - && cat > /dev/null) || exit 1; \ + |(cd $(DESTDIR)${lispdir}; umask 022; tar -xf - && cat > /dev/null) || exit 1; \ (cd $(DESTDIR)${lispdir}; \ $(set_installuser); \ find . -exec chown $${installuser} {} ';') ; \ diff -r d0c4fde41a48 configure.in --- a/configure.in Tue Jul 22 20:55:26 2008 +0000 +++ b/configure.in Wed Jul 23 16:36:25 2008 +0200 @@ -142,7 +142,7 @@ OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d]) OPTION_DEFAULT_ON([xim],[don't use X11 XIM]) OPTION_DEFAULT_OFF([carbon],[use Carbon GUI on Mac OS X. This is unsupported!]) -OPTION_DEFAULT_OFF([ns],[use nextstep (Cocoa or GNUstep) windowing system]) +OPTION_DEFAULT_ON([ns],[don't use Cocoa or GNUstep GUI, if available]) OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console]) OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support]) @@ -151,7 +151,7 @@ ## a suitable makeinfo, and can live without the manuals. dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals]) - + dnl Can remove these in Emacs 24. AC_ARG_WITH([gtk],, AC_MSG_ERROR([--with-gtk has been removed. Use --with-x-toolkit to @@ -160,6 +160,12 @@ AC_ARG_WITH([gcc],, AC_MSG_ERROR([--with-gcc has been removed. Set the `CC' environment variable to specify a compiler.]),,) + +AC_ARG_ENABLE([ns-app],, + AC_MSG_ERROR([--enable-ns-app has been removed. Use --enable-app instead.]),,) + +AC_ARG_ENABLE([carbon-app],, + AC_MSG_ERROR([--enable-carbon-app has been removed. Use --enable-app instead.]),,) AC_ARG_WITH([pkg-config-prog],dnl [AS_HELP_STRING([--with-pkg-config-prog=PATH], @@ -170,21 +176,25 @@ fi fi -AC_ARG_ENABLE(carbon-app, -[AS_HELP_STRING([--enable-carbon-app@<:@=DIR@:>@], - [specify install directory for Emacs.app on Mac OS X - [DIR=/Application]])], -[ carbon_appdir_x=${enableval}]) - AC_ARG_ENABLE(cocoa-experimental-ctrl-g, [ --enable-cocoa-experimental-ctrl-g enable experimental improved ctrl-g recognition], EN_COCOA_EXPERIMENTAL_CTRL_G=yes, EN_COCOA_EXPERIMENTAL_CTRL_G=no) -AC_ARG_ENABLE(ns-self-contained, -[ --disable-ns-self-contained disable self contained build under NS], - EN_NS_SELF_CONTAINED=no, - EN_NS_SELF_CONTAINED=yes) +AC_ARG_ENABLE(app, +[AS_HELP_STRING([--enable-app@<:@=DIR@:>@], + [enable application bundle for GNUstep/Mac OS X])], + [ if test "x${enableval}" = xyes; then + appdir=/Applications + elif test "x${enableval}" != xno; then + appdir="${enableval}" + fi ]) + +AC_ARG_ENABLE(self-contained-app, +[AS_HELP_STRING([--disable-self-contained-app], + [do not use self contained application bundle])], + EN_SELF_CONTAINED=no, + EN_SELF_CONTAINED=yes) AC_ARG_ENABLE(asserts, [AS_HELP_STRING([--enable-asserts], [compile code with asserts enabled])], @@ -382,14 +392,6 @@ * ) unported=yes ;; esac opsys=darwin - # Define CPP as follows to make autoconf work correctly. - CPP="${CC-cc} -E -no-cpp-precomp" - # Use fink packages if available. - if test -d /sw/include && test -d /sw/lib; then - GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib" - CPP="${CPP} ${GCC_TEST_OPTIONS}" - NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS} - fi ;; ## HP 9000 series 700 and 800, running HP/UX @@ -514,9 +516,7 @@ machine=intel386 case "${canonical}" in *-cygwin ) opsys=cygwin ;; - *-darwin* ) opsys=darwin - CPP="${CC-cc} -E -no-cpp-precomp" - ;; + *-darwin* ) opsys=darwin ;; *-linux-gnu* ) opsys=gnu-linux ;; *-sysv4.2uw* ) opsys=unixware; NON_GNU_CPP=/lib/cpp ;; *-sysv5uw* ) opsys=unixware; NON_GNU_CPP=/lib/cpp ;; @@ -625,6 +625,14 @@ fi fi +# Check for an LLVM-based compiler +AC_MSG_CHECKING(whether we are using an LLVM compiler) +AC_TRY_LINK([], [ + #ifndef __llvm__ + #error no. + #endif +], [ LLVM=yes; AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) + #### Some systems specify a CPP to use unless we are using GCC. #### Now that we know whether we are using GCC, we can decide whether #### to use that one. @@ -655,18 +663,68 @@ dnl checks for Unix variants AC_USE_SYSTEM_EXTENSIONS -### Use -Wno-pointer-sign if the compiler supports it -AC_MSG_CHECKING([whether gcc understands -Wno-pointer-sign]) +### Use -Wno-pointer-sign, etc. if the compiler supports it +for flag in -Wno-pointer-sign -Wimplicit -Wformat -Wuninitialized; do +AC_MSG_CHECKING([whether $flag works]) SAVE_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wno-pointer-sign" +CFLAGS="$CFLAGS $flag" AC_TRY_COMPILE([], [], has_option=yes, has_option=no,) if test $has_option = yes; then - C_WARNINGS_SWITCH="-Wno-pointer-sign $C_WARNINGS_SWITCH" + C_WARNINGS_SWITCH="$flag $C_WARNINGS_SWITCH" fi AC_MSG_RESULT($has_option) CFLAGS="$SAVE_CFLAGS" unset has_option unset SAVE_CFLAGS +done + +AC_MSG_CHECKING([whether to optimizate harder]) +AC_ARG_ENABLE(extra-optimizations, + [AS_HELP_STRING([--enable-extra-optimizations], + [enable risky compiler optimizations])], + extra_opts=$enableval, extra_opts=no) +AC_MSG_RESULT($extra_opts) + +# -O, -O2 or -O4 +AC_MSG_CHECKING([for base optimization flag]) +if test x$LLVM = xyes -a x$extra_opts = xyes; then + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -O4" + AC_LINK_IFELSE([ main () { printf("hello\n"); } ], + [C_OPTIMIZE_SWITCH=-O4], + [C_OPTIMIZE_SWITCH=-O2]) + CFLAGS="$SAVE_CFLAGS" +elif test x$GCC = xyes -o x$NON_GNU_CC != x; then + C_OPTIMIZE_SWITCH=-O2 +else + C_OPTIMIZE_SWITCH=-O +fi +AC_MSG_RESULT($C_OPTIMIZE_SWITCH) + +# Apple disabled these flags; sometimes, they won't work +if test x$extra_opts = xyes && $CC -v 2>&1 | tail -n 1 | grep -q Apple; then + SAVE_CC="$CC" + CC="$CC -x objective-c" + +# TODO: delay this until _after_ we have checked if carbon or ns is enabled + for flag in -ftree-vectorize -fstrict-aliasing -freorder-blocks -fsched-interblock; do + AC_MSG_CHECKING([whether $flag works]) + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $flag" + AC_PREPROC_IFELSE([ +// historically -fstrict-aliasing has been incompatible with Objective-C +// and/or CoreFoundation (before 10.5, that is) +#include +#include + ], + [ AC_MSG_RESULT(yes); C_OPTIMIZE_SWITCH="$C_OPTIMIZE_SWITCH $flag" ], + [ AC_MSG_RESULT(no); ]) + CFLAGS="$SAVE_CFLAGS" + unset SAVE_CFLAGS + done + + CC="$SAVE_CC" +fi #### Some other nice autoconf tests. @@ -816,11 +874,7 @@ #endif #ifndef C_OPTIMIZE_SWITCH -#ifdef __GNUC__ -#define C_OPTIMIZE_SWITCH -O2 -#else -#define C_OPTIMIZE_SWITCH -O -#endif +#define C_OPTIMIZE_SWITCH ${C_OPTIMIZE_SWITCH} #endif #ifndef C_WARNINGS_SWITCH @@ -891,6 +945,16 @@ dnl Do this early because it can frob feature test macros for Unix-98 &c. AC_SYS_LARGEFILE + +### Apple GCC 3.1 used a bad form of precompiled headers, newer are fine +AC_MSG_CHECKING([whether -no-cpp-precomp is needed]) +AC_PREPROC_IFELSE([ +#if defined(__APPLE_CC__) && __APPLE_CC__ < 1500 +#error Apple GCC prior to GCC 3.3! +#endif +], +[ AC_MSG_RESULT(no) ], +[ AC_MSG_RESULT(yes); CPPFLAGS="$CPPFLAGS -no-cpp-precomp" ]) ### The standard library on x86-64 and s390x GNU/Linux distributions can @@ -1214,10 +1278,31 @@ fi fi +# check for unsupported carbon backend HAVE_CARBON=no if test "${with_carbon}" != no; then AC_CHECK_HEADER(Carbon/Carbon.h, HAVE_CARBON=yes) - test "${HAVE_CARBON}" = yes && window_system=mac + if test "${HAVE_CARBON}" = yes; then + window_system=mac + with_ns=no + appdir=${srcdir}/src/Emacs.app + appbindir=${appdir}/Contents/MacOS + appresdir=${appdir}/Contents/Resources + appsrc=${srcdir}/mac/Emacs.app + fi +fi + +# presedence: (--with-x overrides nextstep) +if test "${window_system}" = x11; then + if test "${with_ns+set}" != set -o "${appdir+set}" != set; then + for var in with_x with_x_toolkit; do + if eval test \"x\${$var}\" = xyes; then + with_ns=no + appdir= + break + fi + done + fi fi HAVE_NS=no @@ -1228,19 +1313,26 @@ CPPFLAGS="$CPPFLAGS -x objective-c" CFLAGS="$CFLAGS -x objective-c" if test "${with_ns}" != no; then - if test "${opsys}" = darwin; then - NS_IMPL_COCOA=yes - ns_appdir=`pwd`/nextstep/Emacs.app - ns_appbindir=`pwd`/nextstep/Emacs.app/Contents/MacOS - ns_appresdir=`pwd`/nextstep/Emacs.app/Contents/Resources - ns_appsrc=${srcdir}/nextstep/Cocoa/Emacs.base - elif test -f /etc/GNUstep/GNUstep.conf; then + if test "${opsys}" = darwin + then + AC_CHECK_HEADER(Cocoa/Cocoa.h, NS_IMPL_COCOA=yes) + fi + if test -f /etc/GNUstep/GNUstep.conf; then + # FIXME: do not hardcode GNUstep path, use env. variables instead NS_IMPL_GNUSTEP=yes - ns_appdir=`pwd`/nextstep/Emacs.app - ns_appbindir=`pwd`/nextstep/Emacs.app - ns_appresdir=`pwd`/nextstep/Emacs.app/Resources - ns_appsrc=${srcdir}/nextstep/GNUstep/Emacs.base - GNUSTEP_MAKEFILES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_MAKEFILES)" + fi + + if test x${NS_IMPL_COCOA} = xyes; then + appdir=${srcdir}/Emacs.app + appbindir=${appdir}/Contents/MacOS + appresdir=${appdir}/Contents/Resources + appsrc=${srcdir}/nextstep/Cocoa/Emacs.base + elif test x${NS_IMPL_GNUSTEP} = xyes; then + appdir=${srcdir}/Emacs.app + appbindir=${appdir} + appresdir=${appdir}/Resources + appsrc=${srcdir}/nextstep/GNUstep/Emacs.base + GNUSTEP_MAKEFILES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_MAKEFILES)" GNUSTEP_SYSTEM_HEADERS="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_HEADERS)" GNUSTEP_SYSTEM_LIBRARIES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_LIBRARIES)" CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS}" @@ -1248,22 +1340,40 @@ REAL_CFLAGS="$REAL_CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}" LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES}" fi + AC_CHECK_HEADER(AppKit/AppKit.h, HAVE_NS=yes) fi + if test "${HAVE_NS}" = yes; then test "${window_system}" = mac && HAVE_CARBON=no window_system=nextstep with_xft=no with_freetype=no - # set up packaging dirs - exec_prefix=${ns_appbindir} - libexecdir=${ns_appbindir}/libexec - if test "${EN_NS_SELF_CONTAINED}" = yes; then - prefix=${ns_appresdir} - fi fi CFLAGS="$tmp_CFLAGS" CPPFLAGS="$tmp_CPPFLAGS" + +# check if application bundle should be created +AC_MSG_CHECKING([whether to install an application bundle]) +if test "x${appdir}" != "x"; then + if test "${window_system}" != "nextstep" -a "${window_system}" != "mac"; then + AC_MSG_ERROR([ Application bundles are incompatible with + ${window_system} window system!]) + else + AC_MSG_RESULT([yes, ${appdir}]) + fi +else + AC_MSG_RESULT(no) +fi + +# set up self-contained application bundle +if test "${window_system}" = mac -o "${window_system}" = nextstep; then + if test "${EN_SELF_CONTAINED}" = yes; then + prefix=${appresdir} + exec_prefix=${appbindir} + libexecdir=${appbindir}/libexec + fi +fi case "${window_system}" in x11 ) @@ -2055,17 +2165,10 @@ if test "${HAVE_CARBON}" = "yes"; then AC_DEFINE(HAVE_CARBON, 1, [Define to 1 if you are using the Carbon API on Mac OS X.]) AC_CHECK_HEADERS(AvailabilityMacros.h) - ## Specify the install directory - carbon_appdir= - if test "${carbon_appdir_x}" != ""; then - case ${carbon_appdir_x} in - y | ye | yes) carbon_appdir=/Applications ;; - * ) carbon_appdir=${carbon_appdir_x} ;; - esac - fi # We also have mouse menus. HAVE_MENUS=yes fi + ### Use NeXTstep API to implement GUI. if test "${HAVE_NS}" = "yes"; then AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.]) @@ -2476,11 +2579,11 @@ AC_SUBST(machfile) AC_SUBST(opsysfile) AC_SUBST(GETLOADAVG_LIBS) -AC_SUBST(carbon_appdir) -AC_SUBST(ns_appdir) -AC_SUBST(ns_appbindir) -AC_SUBST(ns_appresdir) -AC_SUBST(ns_appsrc) +AC_SUBST(window_system) +AC_SUBST(appdir) +AC_SUBST(appbindir) +AC_SUBST(appresdir) +AC_SUBST(appsrc) AC_SUBST(GNUSTEP_MAKEFILES) AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION, "${canonical}", @@ -2576,6 +2679,7 @@ #define HAVE_WINDOW_SYSTEM #define MULTI_KBOARD #define HAVE_MOUSE +#define OTHER_FILES app-bundle #endif /* Multi-tty support relies on MULTI_KBOARD. It seems safe to turn it @@ -2647,14 +2751,12 @@ # define C_SWITCH_X_SYSTEM -MMD -MP -D_REENTRANT -fPIC -fno-strict-aliasing # define LD_SWITCH_SITE -lgnustep-gui -lgnustep-base -lobjc $(CONFIG_SYSTEM_LIBS) -lpthread # define GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE -# define OTHER_FILES ns-app # else /* NS_IMPL_COCOA */ # define C_SWITCH_X_SYSTEM # define GNU_OBJC_CFLAGS # endif /* NS_IMPL_COCOA */ +# define OTHER_FILES app-bundle #endif /* HAVE_NS */ - - /* If no remapping takes place, static variables cannot be dumped as pure, so don't worry about the `static' keyword. */ @@ -2860,7 +2962,13 @@ Should Emacs use mmap(2) for buffer allocation? $use_mmap_for_buffers What window system should Emacs use? ${window_system} What toolkit should Emacs use? ${USE_X_TOOLKIT}" - +if test "${window_system}" = mac -o "${window_system}" = nextstep; then + if test "x${appdir}" = x; then +echo " Should we install an Emacs.app bundle? no" + else +echo " Should we install an Emacs.app bundle? yes, ${appdir}" + fi +fi if test -n "${x_includes}"; then echo " Where do we find X Windows header files? ${x_includes}" else @@ -2915,6 +3023,17 @@ The NeXTstep port (--with-ns) is an alternative. Read the emacs-devel archives for more information." echo + echo "You must run \"make install\" in order to test the built application. +The installed application will go to nextstep/Emacs.app and can be +run or moved from there." + if test "$EN_SELF_CONTAINED" = "yes"; then + echo "The application will be fully self-contained." + else + echo "The lisp resources for the application will be installed under ${prefix}. +You may need to run \"make install\" with sudo. The application will fail +to run if these resources are not installed." + fi + echo fi if test "$HAVE_NS" = "yes"; then @@ -2922,7 +3041,7 @@ echo "You must run \"make install\" in order to test the built application. The installed application will go to nextstep/Emacs.app and can be run or moved from there." - if test "$EN_NS_SELF_CONTAINED" = "yes"; then + if test "$EN_SELF_CONTAINED" = "yes"; then echo "The application will be fully self-contained." else echo "The lisp resources for the application will be installed under ${prefix}. diff -r d0c4fde41a48 etc/.cvsignore --- a/etc/.cvsignore Tue Jul 22 20:55:26 2008 +0000 +++ b/etc/.cvsignore Wed Jul 23 16:36:25 2008 +0200 @@ -3,5 +3,6 @@ *.ps *.log *.dvi -DOC DOC-* +DOC +DOC-* *.pyc \ No newline at end of file diff -r d0c4fde41a48 leim/Makefile.in --- a/leim/Makefile.in Tue Jul 22 20:55:26 2008 +0000 +++ b/leim/Makefile.in Wed Jul 23 16:36:25 2008 +0200 @@ -33,7 +33,7 @@ datarootdir=@datarootdir@ datadir=@datadir@ srcdir=@srcdir@ -ns_appresdir=@ns_appresdir@ +appresdir=@appresdir@ # Where to install LEIM files. INSTALLDIR=$(DESTDIR)${datadir}/emacs/${version}/leim @@ -260,8 +260,8 @@ [ -n "$${installuser}" ] && break ; \ done ; \ find ${INSTALLDIR} -exec chown $${installuser} '{}' ';' - if [ "${ns_appresdir}" != "" ]; then \ - ( cd ${ns_appresdir} ; \ + if [ "${appresdir}" != "" ]; then \ + ( cd ${appresdir} ; \ if test -d share/emacs ; then mv -f share/emacs/*/* . ; fi ; \ rm -fr share ) ; \ else true ; fi diff -r d0c4fde41a48 lisp/sha1.el --- a/lisp/sha1.el Tue Jul 22 20:55:26 2008 +0000 +++ b/lisp/sha1.el Wed Jul 23 16:36:25 2008 +0200 @@ -71,7 +71,9 @@ :type 'integer :group 'sha1) -(defcustom sha1-program '("sha1sum") +(defcustom sha1-program + (if (memq system-type '(gnu gnu/linux)) + '("sha1sum") '("openssl" "sha1" "-binary")) "*Name of program to compute SHA1. It must be a string \(program name\) or list of strings \(name and its args\)." :type '(repeat string) @@ -88,8 +90,12 @@ (defun sha1-string-external (string &optional binary) (let (prog args digest) (if (consp sha1-program) - (setq prog (car sha1-program) - args (cdr sha1-program)) + (if (and (string= (file-name-nondirectory (car sha1-program)) "openssl") + (<= 2 (length sha1-program))) + (setq prog (car sha1-program) (cadr sha1-program) + args (caddr sha1-program)) + (setq prog (car sha1-program) + args (cdr sha1-program))) (setq prog sha1-program args nil)) (with-temp-buffer @@ -98,11 +104,14 @@ (apply (function call-process-region) (point-min) (point-max) prog t t nil args) - ;; SHA1 is 40 bytes long in hexadecimal form. - (setq digest (buffer-substring (point-min)(+ (point-min) 40)))) - (if binary - (decode-hex-string digest) - digest))) + ;; SHA1 is 40 bytes long in hexadecimal form, 20 in binary. + (if (memq "-binary" prog) + (setq digest (buffer-substring (point-min)(+ (point-min) 20))) + (setq digest (buffer-substring (point-min)(+ (point-min) 40))))) + (cond + ((eq (not binary) (not (memq "-binary" prog))) digest) + (binary (encode-hex-string digest)) + (t (decode-hex-string digest))))) (defun sha1-region-external (beg end &optional binary) (sha1-string-external (buffer-substring-no-properties beg end) binary)) diff -r d0c4fde41a48 src/Makefile.in --- a/src/Makefile.in Tue Jul 22 20:55:26 2008 +0000 +++ b/src/Makefile.in Wed Jul 23 16:36:25 2008 +0200 @@ -525,21 +525,21 @@ #endif #ifdef HAVE_CARBON -mac = ../mac/ MAC_OBJ = mac.o macterm.o macfns.o macmenu.o macselect.o fontset.o fringe.o image.o mactoolbox.o -emacsapp = $(PWD)/$(mac)Emacs.app/ -emacsappsrc = ${srcdir}/../mac/Emacs.app/ #endif #ifdef HAVE_NS -ns_appdir=@ns_appdir@/ -ns_appbindir=@ns_appbindir@/ -ns_appresdir=@ns_appresdir@/ -ns_appsrc=@ns_appsrc@ /* Object files for NeXTstep */ NS_OBJ= nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ fontset.o fringe.o image.o #endif /* HAVE_NS */ + +#if defined(HAVE_CARBON) || defined(HAVE_NS) +appdir=@appdir@/ +appbindir=@appbindir@/ +appresdir=@appresdir@/ +appsrc=@appsrc@ +#endif #ifdef HAVE_WINDOW_SYSTEM #ifdef HAVE_X_WINDOWS @@ -1287,31 +1287,38 @@ mactoolbox.o: blockinput.h atimer.h systime.h macterm.h macgui.h frame.h \ charset.h coding.h ccl.h dispextern.h fontset.h termhooks.h buffer.h \ window.h keyboard.h $(config_h) +#endif -${emacsapp}Contents/Resources/English.lproj: +#if defined(HAVE_NS) || defined(HAVE_CARBON) +ifneq ($(emacsapp),$(emacsappsrc)) +.PHONY: $(emacsapp) app-bundle app + +$(emacsapp): $(emacsappsrc) + rm -rf $@ mkdir -p $@ + ( cd $< ; tar cfh - . ) | ( cd $@ ; tar xf - ) -ifneq (${emacsapp},${emacsappsrc}) -${emacsapp}Contents/Info.plist: ${emacsappsrc}Contents/Info.plist - cp $< $@ -${emacsapp}Contents/PkgInfo: ${emacsappsrc}Contents/PkgInfo - cp $< $@ -${emacsapp}Contents/Resources/Emacs.icns: ${emacsappsrc}Contents/Resources/Emacs.icns - mkdir -p ${emacsapp}Contents/Resources - cp $< $@ -${emacsapp}Contents/Resources/English.lproj/InfoPlist.strings: ${emacsappsrc}Contents/Resources/English.lproj/InfoPlist.strings - cp $< $@ +dnl ${emacsapp}Contents/Resources/English.lproj: + +$(emacsbindir)/Emacs: emacs${EXEEXT} + mkdir -p $(emacsbindir) + cp -Lf $< $@ + +$(emacsapp)/Contents/%: $(emacsappsrc)/Contents/% + mkdir -p $(emacsres) + cp -Lp $< $@ + +$(emacsres)/%: $(emacsappsrc)/Contents/Resources/% + mkdir -p $(emacsres) + cp -LRp $< $@ + +app-bundle: $(emacsapp) $(emacsbindir)/Emacs \ + $(emacsapp)/Contents/Info.plist $(emacsapp)/Contents/PkgInfo \ + $(emacsres)/Emacs.icns + +app: app-bundle endif - -macosx-bundle: ${emacsapp}Contents/Resources/English.lproj \ - ${emacsapp}Contents/Info.plist ${emacsapp}Contents/PkgInfo \ - ${emacsapp}Contents/Resources/Emacs.icns \ - ${emacsapp}Contents/Resources/English.lproj/InfoPlist.strings -macosx-app: macosx-bundle ${emacsapp}Contents/MacOS/Emacs -${emacsapp}Contents/MacOS/Emacs: emacs${EXEEXT} - mkdir -p ${emacsapp}Contents/MacOS/; - cd ${emacsapp}Contents/MacOS/; cp ../../../../src/emacs${EXEEXT} Emacs${EXEEXT} -#endif /* HAVE_CARBON */ +#endif /* HAVE_CARBON || HAVE_NS */ #ifdef HAVE_NS buffer.o callint.o cmds.o dispnew.o editfns.o fileio.o frame.o \ @@ -1330,23 +1337,22 @@ nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h $(config_h) nsimage.o: nsimage.m nsterm.h nsfont.o: nsterm.h dispextern.h frame.h lisp.h $(config_h) +#endif /* HAVE_NS */ -${ns_appdir}: ${ns_appsrc} - rm -fr ${ns_appdir} - mkdir -p ${ns_appdir} - ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; tar xf - ) - ( cd ${ns_appdir} ; for subdir in `find . -type d ! -name CVS -print` ; do \ +${appdir}: ${appsrc} + rm -fr ${appdir} + mkdir -p ${appdir} + ( cd ${appsrc} ; tar cfh - . ) | ( cd ${appdir} ; tar xf - ) + ( cd ${appdir} ; for subdir in `find . -type d ! -name CVS -print` ; do \ chmod a+rx $${subdir} ; \ rm -rf $${subdir}/CVS ; \ rm -f $${subdir}/.cvsignore ; done ; ) -${ns_appbindir}Emacs: emacs${EXEEXT} - mkdir -p ${ns_appbindir} - cp -f emacs${EXEEXT} ${ns_appbindir}Emacs +${appbindir}Emacs: emacs${EXEEXT} + mkdir -p ${appbindir} + cp -f emacs${EXEEXT} ${appbindir}Emacs -ns-app: ${ns_appdir} ${ns_appbindir}Emacs - -#endif /* HAVE_NS */ +app-bundle: ${appdir} ${appbindir}Emacs mostlyclean: rm -f temacs${EXEEXT} prefix-args${EXEEXT} core *.core \#* *.o libXMenu11.a liblw.a @@ -1355,8 +1361,8 @@ rm -f buildobj.lst clean: mostlyclean rm -f emacs-*.*.*${EXEEXT} emacs${EXEEXT} -#ifdef HAVE_NS - rm -fr ${ns_appdir} +#if defined(HAVE_NS) || defined(HAVE_CARBON) + rm -fr ${appdir} #ifdef NS_IMPL_GNUSTEP rm -f *.d #endif diff -r d0c4fde41a48 src/cm.c --- a/src/cm.c Tue Jul 22 20:55:26 2008 +0000 +++ b/src/cm.c Wed Jul 23 16:36:25 2008 +0200 @@ -61,7 +61,7 @@ int cmputc (c) - char c; + int c; { if (current_tty->termscript) putc (c & 0177, current_tty->termscript); diff -r d0c4fde41a48 src/config.in --- a/src/config.in Tue Jul 22 20:55:26 2008 +0000 +++ b/src/config.in Wed Jul 23 16:36:26 2008 +0200 @@ -896,20 +896,8 @@ XPointer or XPointer*. */ #undef XRegisterIMInstantiateCallback_arg6 -/* Define to 1 if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif - /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ #undef _LARGEFILE_SOURCE @@ -927,16 +915,27 @@ /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE -/* Enable extensions on Solaris. */ +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif + /* Define to rpl_ if the getopt replacement functions and variables should be used. */ @@ -984,6 +983,7 @@ #define HAVE_WINDOW_SYSTEM #define MULTI_KBOARD #define HAVE_MOUSE +#define OTHER_FILES app-bundle #endif /* Multi-tty support relies on MULTI_KBOARD. It seems safe to turn it @@ -997,7 +997,7 @@ #define CANNOT_DUMP #endif -/* TODO: These are used for the Carbon port only. */ +/* PENDING: These are used for the Carbon port only. */ #undef MAC_OS #undef MAC_OSX @@ -1055,14 +1055,12 @@ # define C_SWITCH_X_SYSTEM -MMD -MP -D_REENTRANT -fPIC -fno-strict-aliasing # define LD_SWITCH_SITE -lgnustep-gui -lgnustep-base -lobjc $(CONFIG_SYSTEM_LIBS) -lpthread # define GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE -# define OTHER_FILES ns-app # else /* NS_IMPL_COCOA */ # define C_SWITCH_X_SYSTEM # define GNU_OBJC_CFLAGS # endif /* NS_IMPL_COCOA */ +# define OTHER_FILES app-bundle #endif /* HAVE_NS */ - - /* If no remapping takes place, static variables cannot be dumped as pure, so don't worry about the `static' keyword. */ diff -r d0c4fde41a48 src/emacs.c --- a/src/emacs.c Tue Jul 22 20:55:26 2008 +0000 +++ b/src/emacs.c Wed Jul 23 16:36:26 2008 +0200 @@ -49,6 +49,12 @@ #ifdef NS_IMPL_GNUSTEP /* At least under Debian, GSConfig is in a subdirectory. --Stef */ #include +#endif + +#if defined(NS_IMPL_COCOA) || defined(MAC_OSX) +#define Cursor Mac_Cursor_not_to_be_used +#include +#undef Cursor #endif #include "lisp.h" @@ -1434,6 +1440,16 @@ display_arg = 4; } #endif /* HAVE_NS */ + +#if defined (MAC_OSX) || defined (NS_IMPL_COCOA) + // ensure foreground process type, and bring to front + if (!noninteractive && !inhibit_window_system) + { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType( &psn, kProcessTransformToForegroundApplication ); + SetFrontProcess( &psn ); + } +#endif #ifdef HAVE_X_WINDOWS /* Stupid kludge to catch command-line display spec. We can't diff -r d0c4fde41a48 src/keyboard.c --- a/src/keyboard.c Tue Jul 22 20:55:26 2008 +0000 +++ b/src/keyboard.c Wed Jul 23 16:36:27 2008 +0200 @@ -1317,9 +1317,9 @@ Vsignaling_function = Qnil; } -Lisp_Object command_loop_1 (); -Lisp_Object command_loop_2 (); -Lisp_Object top_level_1 (); +Lisp_Object command_loop_1 (Lisp_Object); +Lisp_Object command_loop_2 (Lisp_Object); +Lisp_Object top_level_1 (Lisp_Object); /* Entry to editor-command-loop. This level has the catches for exiting/returning to editor command loop. @@ -1361,8 +1361,9 @@ returned due to end of file (or end of kbd macro). */ Lisp_Object -command_loop_2 () -{ +command_loop_2 (Lisp_Object ignored) +{ + (void)ignored; register Lisp_Object val; do @@ -1379,8 +1380,10 @@ } Lisp_Object -top_level_1 () -{ +top_level_1 (Lisp_Object ignored) +{ + (void)ignored; + /* On entry to the outer level, run the startup file */ if (!NILP (Vtop_level)) internal_condition_case (top_level_2, Qerror, cmd_error); @@ -1529,8 +1532,9 @@ #endif Lisp_Object -command_loop_1 () -{ +command_loop_1 (Lisp_Object ignored) +{ + (void)ignored; Lisp_Object cmd; int lose; int nonundocount; diff -r d0c4fde41a48 src/lisp.h --- a/src/lisp.h Tue Jul 22 20:55:26 2008 +0000 +++ b/src/lisp.h Wed Jul 23 16:36:27 2008 +0200 @@ -3036,7 +3036,7 @@ extern int detect_input_pending_run_timers P_ ((int)); extern void safe_run_hooks P_ ((Lisp_Object)); extern void cmd_error_internal P_ ((Lisp_Object, char *)); -extern Lisp_Object command_loop_1 P_ ((void)); +extern Lisp_Object command_loop_1 P_ ((Lisp_Object)); extern Lisp_Object recursive_edit_1 P_ ((void)); extern void record_auto_save P_ ((void)); extern void init_keyboard P_ ((void)); diff -r d0c4fde41a48 src/macros.c --- a/src/macros.c Tue Jul 22 20:55:26 2008 +0000 +++ b/src/macros.c Wed Jul 23 16:36:27 2008 +0200 @@ -348,7 +348,7 @@ break; } - command_loop_1 (); + command_loop_1 (NULL); executing_kbd_macro_iterations = ++success_count; diff -r d0c4fde41a48 src/nsfns.m --- a/src/nsfns.m Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsfns.m Wed Jul 23 16:36:27 2008 +0200 @@ -281,7 +281,7 @@ -------------------------------------------------------------------------- */ { int i, count; - id item; + NSMenuItem *item; const char *name; Lisp_Object nameStr; unsigned short key; @@ -1773,7 +1773,7 @@ Lisp_Object display; { check_ns (); -#ifdef NS_IMPL_COCOA +#if defined(NS_IMPL_COCOA) && !defined(_DARWIN_FEATURE_UNIX_CONFORMANCE) PSFlush (); #endif /*ns_delete_terminal (dpyinfo->terminal); */ @@ -2160,15 +2160,6 @@ { return FRAME_NS_DISPLAY_INFO (f)->n_planes; } - - -void -x_sync (Lisp_Object frame) -{ - /* XXX Not implemented XXX */ - return; -} - /* ========================================================================== @@ -2294,12 +2285,12 @@ if (ns_lisp_to_color (color, &col)) return Qnil; - [[col colorUsingColorSpaceName: NSCalibratedRGBColorSpace] - getRed: &red green: &green blue: &blue alpha: &alpha]; - 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)); + col = [col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; + + rgba[0] = make_number (lrint ([col redComponent]*65280)); + rgba[1] = make_number (lrint ([col greenComponent]*65280)); + rgba[2] = make_number (lrint ([col blueComponent]*65280)); + rgba[3] = make_number (lrint ([col alphaComponent]*65280)); return Flist (4, rgba); } diff -r d0c4fde41a48 src/nsfont.m --- a/src/nsfont.m Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsfont.m Wed Jul 23 16:36:28 2008 +0200 @@ -63,13 +63,22 @@ /* Replace spaces w/another character so emacs core font parsing routines aren't thrown off. */ -static void -nsfont_escape_name (char *name) +static Lisp_Object +ns_make_string (const NSString *name, const BOOL escaped) { - int i =0, len =strlen (name); - for ( ; i= 1.5) return w; } + else + { + NSDictionary *attrs = + [NSDictionary dictionaryWithObject:sfont forKey:NSFontAttributeName]; + w = [cstr sizeWithAttributes:attrs].width; + } +#else + w = [sfont widthOfString: cstr]; #endif - w = [sfont widthOfString: cstr]; return max (w, 2.0); } @@ -540,7 +561,7 @@ family = nsfont_get_family (font_entity); if (NSFONT_TRACE) { - fprintf (stderr, "family: '%s'\ttraits = %ld\tbold = %d\n", + fprintf (stderr, "family: '%s'\ttraits = %d\tbold = %d\n", [family UTF8String], traits, traits & NSBoldFontMask); } @@ -597,9 +618,9 @@ } #endif - font_info->glyphs = (unsigned short *) + font_info->glyphs = (unsigned short **) xmalloc (0x100 * sizeof (unsigned short *)); - font_info->metrics = (struct font_metrics *) + font_info->metrics = (struct font_metrics **) xmalloc (0x100 * sizeof (struct font_metrics *)); if (!font_info->glyphs || !font_info->metrics) return Qnil; @@ -723,7 +744,7 @@ /* set up metrics portion of font struct */ font->ascent = [sfont ascender]; font->descent = -[sfont descender]; - font->min_width = [sfont widthOfString: @"|"]; /* FIXME */ + font->min_width = lrint (nsfont_char_width (sfont, '|')); font->space_width = lrint (nsfont_char_width (sfont, ' ')); font->average_width = lrint (font_info->width); font->max_width = lrint (font_info->max_bounds.width); @@ -984,7 +1005,7 @@ /* set up for character rendering */ r.origin.y += font->voffset + (s->height - font->height)/2; - col = (NS_FACE_FOREGROUND (face) != nil + col = (NS_FACE_FOREGROUND (face) != 0 ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f) : FRAME_FOREGROUND_COLOR (s->f)); /* FIXME: find another way to pass this */ @@ -1077,7 +1098,7 @@ if (face->underline_p) { - if (face->underline_color != nil) + if (face->underline_color != 0) [ns_lookup_indexed_color (face->underline_color, s->f) set]; else [col set]; @@ -1087,7 +1108,7 @@ CGContextAddLineToPoint (gcontext, r.origin.x + r.size.width, r.origin.y + font->underpos); CGContextStrokePath (gcontext); - if (face->underline_color != nil) + if (face->underline_color != 0) [col set]; } else @@ -1227,19 +1248,15 @@ if (cfont != nil) { - char *family = strdup([[cfont familyName] UTF8String]); - Lisp_Object famAndReg; - - nsfont_escape_name (family); - famAndReg = Fcons (build_string (family), regString); + Lisp_Object family = ns_make_string ( [cfont familyName], YES ); + Lisp_Object famAndReg = Fcons (family, regString); if (NSFONT_TRACE) fprintf (stderr, "%s fontset: use '%s' for script '%s'\n", - font_info->name, family, + font_info->name, SDATA (family), SDATA (SYMBOL_NAME (scripts[i]))); Fset_fontset_font (name, scripts[i], famAndReg, Qnil, Qnil); - free (family); } else { diff -r d0c4fde41a48 src/nsgui.h --- a/src/nsgui.h Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsgui.h Wed Jul 23 16:36:28 2008 +0200 @@ -138,7 +138,7 @@ typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect; #endif -#define NativeRectangle struct _NSRect +#define NativeRectangle NSRect #define CONVERT_TO_XRECT(xr, nr) \ ((xr).x = (nr).origin.x, \ diff -r d0c4fde41a48 src/nsmenu.m --- a/src/nsmenu.m Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsmenu.m Wed Jul 23 16:36:28 2008 +0200 @@ -1409,7 +1409,8 @@ { NSString *str = [NSString stringWithUTF8String: text]; NSRect r = [textField frame]; - r.size.width = [[[textField font] screenFont] widthOfString: str] + 8; + r.size.width = 8 + + nsfont_string_width([[textField font] screenFont], str); [textField setFrame: r]; [textField setStringValue: str]; } diff -r d0c4fde41a48 src/nsselect.m --- a/src/nsselect.m Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsselect.m Wed Jul 23 16:36:28 2008 +0200 @@ -344,8 +344,10 @@ options: NSLiteralSearch range: NSMakeRange (0, [mstr length])]; utfStr = [mstr UTF8String]; +#ifndef NS_IMPL_COCOA if (!utfStr) utfStr = [mstr cString]; +#endif } NS_HANDLER { diff -r d0c4fde41a48 src/nsterm.h --- a/src/nsterm.h Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsterm.h Wed Jul 23 16:36:28 2008 +0200 @@ -38,8 +38,25 @@ } - (void)sendEvent: (NSEvent *)theEvent; - (void)showPreferencesWindow: (id)sender; + +- (void)logNotification: (NSNotification *)notification; +- (BOOL)openFile: (NSString *)fileName; + + +- (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg; +- (void)requestService: (NSPasteboard *)pboard + userData: (NSString *)userData + error: (NSString **)error; @end +@interface NSApplication (EmacsApp) +/* Apple removed the declaration, but kept the implementation */ +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 +- (void)setAppleMenu: (NSMenu *)menu; +#endif + ++ (EmacsApp *)sharedApplication; +@end /* ========================================================================== @@ -77,6 +94,9 @@ - (void) setWindowClosing: (BOOL)closing; - (EmacsToolbar *) toolbar; - (void) deleteWorkingText; + +/* utility */ +- (long)conversationIdentifier; @end @@ -350,13 +370,6 @@ extern NSArray *ns_send_types, *ns_return_types; extern EmacsMenu *mainMenu, *svcsMenu; - -/* Apple removed the declaration, but kept the implementation */ -#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 -@interface NSApplication (EmacsApp) -- (void)setAppleMenu: (NSMenu *)menu; -@end -#endif #endif /* __OBJC__ */ @@ -528,6 +541,9 @@ struct frame *x_highlight_frame; struct frame *x_focus_frame; }; + +// no-op +#define x_sync(x) ((void)NULL) /* This is a chain of structures for all the NS displays currently in use. */ extern struct ns_display_info *x_display_list; @@ -717,6 +733,12 @@ extern void nsfont_make_fontset_for_font (Lisp_Object name, Lisp_Object font_object); +/* In nsfont, called from nsterm.m */ +#ifdef __OBJC__ +extern float nsfont_char_width(NSFont *sfont, int c); +extern float nsfont_string_width(NSFont *sfont, NSString *str); +#endif + /* In nsfont, for debugging */ struct glyph_string; void dump_glyphstring (struct glyph_string *s); @@ -751,6 +773,7 @@ #ifdef __OBJC__ extern Lisp_Object ns_color_to_lisp (NSColor *col); extern int ns_lisp_to_color (Lisp_Object color, NSColor **col); +extern Lisp_Object ns_color_to_lisp (NSColor *col); extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f); extern unsigned long ns_index_color (NSColor *color, struct frame *f); extern void ns_free_indexed_color (unsigned long idx, struct frame *f); @@ -765,6 +788,7 @@ /* in nsmenu */ extern void update_frame_tool_bar (FRAME_PTR f); extern void free_frame_tool_bar (FRAME_PTR f); +extern void free_frame_menubar P_ ((struct frame *)); extern void find_and_call_menu_selection (FRAME_PTR f, EMACS_INT menu_bar_items_used, Lisp_Object vector, void *client_data); extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f, @@ -823,5 +847,11 @@ #endif /* HAVE_NS */ +/* + Local Variables: + mode: objc + End: +*/ + /* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5 (do not change this comment) */ diff -r d0c4fde41a48 src/nsterm.m --- a/src/nsterm.m Tue Jul 22 20:55:26 2008 +0000 +++ b/src/nsterm.m Wed Jul 23 16:36:28 2008 +0200 @@ -58,7 +58,6 @@ #else #define NSTRACE(x) #endif - /* ========================================================================== @@ -1548,13 +1547,13 @@ { [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace] getWhite: &gray alpha: &alpha]; - snprintf (buf, sizeof (buf), "GRAY%02.2lx%02.2lx", + snprintf (buf, sizeof (buf), "GRAY%2.2lx%2.2lx", lrint (gray * 0xff), lrint (alpha * 0xff)); UNBLOCK_INPUT; return build_string (buf); } - snprintf (buf, sizeof (buf), "ARGB%02.2lx%02.2lx%02.2lx%02.2lx", + snprintf (buf, sizeof (buf), "ARGB%2.2lx%2.2lx%2.2lx%2.2lx", lrint (alpha*0xff), lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff)); @@ -2217,7 +2216,7 @@ row->visible_height = oldVH; } else - ns_clip_to_row (w, row, -1, YES); + ns_clip_to_row (w, row, -1, (void *)YES); if (p->bx >= 0 && !p->overlay_p) { @@ -2941,8 +2940,8 @@ (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND : NS_DUMPGLYPH_NORMAL)); ns_tmp_font = (struct nsfont_info *)s->face->font; - if (ns_tmp_font == ~0 || ns_tmp_font == NULL) - ns_tmp_font = FRAME_FONT (s->f); + if (ns_tmp_font == (void *)~0 || ns_tmp_font == NULL) + ns_tmp_font = (struct nsfont_info *)FRAME_FONT (s->f); ns_tmp_font->font.driver->draw (s, 0, s->nchars, s->x, s->y, @@ -3038,6 +3037,7 @@ 23: Now we have to manage the event buffer ourselves. -------------------------------------------------------------------------- */ { + EmacsApp *app = (id)NSApp; struct input_event ev; int nevents; static NSDate *lastCheck = nil; @@ -3070,14 +3070,14 @@ /* If have 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]]) + && [app openFile: [ns_pending_files objectAtIndex: 0]]) { [ns_pending_files removeObjectAtIndex: 0]; } /* Deal with pending service requests. */ else if (ns_pending_service_names && [ns_pending_service_names count] != 0 - && [NSApp fulfillService: [ns_pending_service_names objectAtIndex: 0] - withArg: [ns_pending_service_args objectAtIndex: 0]]) + && [app fulfillService: [ns_pending_service_names objectAtIndex: 0] + withArg: [ns_pending_service_args objectAtIndex: 0]]) { [ns_pending_service_names removeObjectAtIndex: 0]; [ns_pending_service_args removeObjectAtIndex: 0]; @@ -3874,7 +3874,7 @@ #ifdef NS_IMPL_COCOA { NSMenu *appMenu; - id item; + NSMenuItem *item; /* set up the application menu */ svcsMenu = [[EmacsMenu alloc] initWithTitle: @"Services"]; [svcsMenu setAutoenablesItems: NO]; @@ -4129,7 +4129,7 @@ NSString *file; while ((file = [files nextObject]) != nil) [ns_pending_files addObject: file]; - return YES; + return; } /* TODO: these may help w/IO switching btwn terminal and NSApp */ @@ -4158,8 +4158,6 @@ /*NSTRACE (timeout_handler); */ ns_send_appdefined (-2); } - -extern void update_window_cursor (struct window *w, int on); - (void)cursor_blink_handler: (NSTimer *)cursorEntry /* -------------------------------------------------------------------------- @@ -4181,8 +4179,8 @@ { f->output_data.ns->desired_cursor = no_highlight; } - update_window_cursor (XWINDOW (FRAME_SELECTED_WINDOW (f)), 1); - /*x_update_cursor (f, 1); */ + + x_update_cursor (f, 1); } @@ -4246,7 +4244,6 @@ return YES; } - @end /* EmacsApp */ @@ -4358,7 +4355,7 @@ NSView most recently updated (I guess), which is not the correct one. UPDATE: After multi-TTY merge this happens even w/o NO_SOCK_SIGIO */ if ([[theEvent window] isKindOfClass: [EmacsWindow class]]) - [[(EmacsView *)[theEvent window] delegate] keyDown: theEvent]; + [(EmacsView *)[[theEvent window] delegate] keyDown: theEvent]; return; } /*#endif */ @@ -6353,7 +6350,7 @@ char *slantStr = [mgr fontNamed: sname hasTraits: NSItalicFontMask] ? "i" : "r"; int size = [nsfont pointSize]; - int aWidth = lrint (10.0 * [nsfont widthOfString: @"a"]); + int aWidth = lrint (10.0 * nsfont_char_width(nsfont, 'a')); const char *xlfd; int i, len; diff -r d0c4fde41a48 src/s/darwin.h --- a/src/s/darwin.h Tue Jul 22 20:55:26 2008 +0000 +++ b/src/s/darwin.h Wed Jul 23 16:36:28 2008 +0200 @@ -174,8 +174,6 @@ /* Link in the Carbon or AppKit lib. */ #ifdef HAVE_NS -/* PENDING: can this target be specified in a clearer way? */ -#define OTHER_FILES ns-app /* XXX: lresolv is here because configure when testing #undefs res_init, a macro in /usr/include/resolv.h for res_9_init, not in stdc lib. */ #define LIBS_MACGUI -framework AppKit -lresolv @@ -184,11 +182,8 @@ #else /* !HAVE_NS */ #define HEADERPAD_EXTRA 690 -/* This is for the Carbon port. Under the NeXTstep port, this is still picked - up during preprocessing, but is undone in config.in. */ +#ifdef HAVE_CARBON #define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX - -#ifdef HAVE_CARBON /* We need a little extra space, see ../../lisp/loadup.el. */ #define SYSTEM_PURESIZE_EXTRA 30000 @@ -199,9 +194,6 @@ #ifdef HAVE_AVAILABILITYMACROS_H #include #endif -/* Tell src/Makefile.in to create files in the Mac OS X application - bundle mac/Emacs.app. */ -#define OTHER_FILES macosx-app /* Whether to use the Image I/O framework for reading images. */ #ifndef USE_MAC_IMAGE_IO