commit e85053f8fecd2124450a4e27d629cf87cf508319 (HEAD, refs/remotes/origin/master) Author: Leo Liu Date: Sat May 16 09:03:29 2015 +0800 Revert "Fix cps--gensym" * lisp/emacs-lisp/generator.el (cps--gensym): Revert commit fbda511ab8069d0115eafca411a43353b85431b1 on 2015-05-14. diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 65def39..8251682 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -90,7 +90,7 @@ ;; Change this function to use `cl-gensym' if you want the generated ;; code to be easier to read and debug. ;; (cl-gensym (apply #'format fmt args)) - `(make-symbol (format ,fmt . ,args))) + `(make-symbol ,fmt)) (defvar cps--dynamic-wrappers '(identity) "List of transformer functions to apply to atomic forms we commit 741b224a843d78bb12f67ce1a2a3a15355790b90 Author: Glenn Morris Date: Fri May 15 21:04:28 2015 -0400 ; * lib-src/etags.c: Comment. Ref: http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00342.html diff --git a/lib-src/etags.c b/lib-src/etags.c index f243821..7bacbd3 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -68,8 +68,8 @@ University of California, as described above. */ * 1994 Line-by-line regexp tags by Tom Tromey. * 2001 Nested classes by Francesco Potortì (concept by Mykola Dzyuba). * 2002 #line directives by Francesco Potortì. - * - * Francesco Potortì has maintained and improved it since 1993. + * Francesco Potortì maintained and improved it for many years + starting in 1993. */ /* commit 48e384d7104dce8219b169c55a29c9f85024c83f Author: Glenn Morris Date: Fri May 15 20:51:45 2015 -0400 Replace AC_SUBST_FILE in configure with include in Makefiles. * configure.ac (DEPDIR, MKDEPDIR, deps_frag, lwlib_deps_frag) (oldxmenu_deps_frag, lisp_frag): Remove output variables/files. (AUTO_DEPEND): New output variable. * lwlib/Makefile.in (AUTO_DEPEND): New, set by configure. (DEPFLAGS, MKDEPDIR): Set directly via conditional. (lwlib_deps_frag): Replace by conditional include. * lwlib/autodeps.mk: Remove file. * oldXMenu/Makefile.in (AUTO_DEPEND): New, set by configure. (DEPFLAGS, MKDEPDIR): Set directly via conditional. (oldxmenu_deps_frag): Replace by conditional include. * oldXMenu/autodeps.mk: Remove file. * src/Makefile.in (AUTO_DEPEND): New, set by configure. (DEPFLAGS, MKDEPDIR): Set directly via conditional. (lisp_frag): Replace by an include. (deps_frag): Replace by conditional include. * src/autodeps.mk: Remove file. diff --git a/configure.ac b/configure.ac index 90a4055..1cddeb1 100644 --- a/configure.ac +++ b/configure.ac @@ -1661,9 +1661,7 @@ dnl AC_C_BIGENDIAN is done by gnulib. dnl check for Make feature -DEPFLAGS= -MKDEPDIR=":" -deps_frag=deps.mk +AUTO_DEPEND=no dnl check if we have GCC and autodepend is on. if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then AC_MSG_CHECKING([whether gcc understands -MMD -MF]) @@ -1675,24 +1673,10 @@ if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then rm -rf deps.d AC_MSG_RESULT([$ac_enable_autodepend]) if test $ac_enable_autodepend = yes; then - DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d -MP' - ## MKDIR_P is documented (see AC_PROG_MKDIR_P) to be parallel-safe. - MKDEPDIR='${MKDIR_P} ${DEPDIR}' - deps_frag=autodeps.mk + AUTO_DEPEND=yes fi fi -lwlib_deps_frag=$srcdir/lwlib/$deps_frag -oldxmenu_deps_frag=$srcdir/oldXMenu/$deps_frag -deps_frag=$srcdir/src/$deps_frag -AC_SUBST(MKDEPDIR) -AC_SUBST(DEPFLAGS) -AC_SUBST_FILE(deps_frag) -AC_SUBST_FILE(lwlib_deps_frag) -AC_SUBST_FILE(oldxmenu_deps_frag) - -lisp_frag=$srcdir/src/lisp.mk -AC_SUBST_FILE(lisp_frag) - +AC_SUBST(AUTO_DEPEND) dnl checks for operating system services AC_SYS_LONG_FILE_NAMES diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in index 1f332e9..2fd5959 100644 --- a/lwlib/Makefile.in +++ b/lwlib/Makefile.in @@ -70,10 +70,15 @@ am__v_at_0 = @ am__v_at_1 = DEPDIR = deps -## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty. -DEPFLAGS = @DEPFLAGS@ -## ${MKDIR_P} ${DEPDIR} (if AUTO_DEPEND); else ':'. -MKDEPDIR = @MKDEPDIR@ +AUTO_DEPEND = @AUTO_DEPEND@ + +ifeq ($(AUTO_DEPEND),yes) +DEPFLAGS = -MMD -MF ${DEPDIR}/$*.d -MP +MKDEPDIR = ${MKDIR_P} ${DEPDIR} +else +DEPFLAGS = +MKDEPDIR = : +endif ## ../src is where the generated file (config.h, globals.h) are. ## $(srcdir)/../src is where the non-generated files (lisp.h) are. @@ -102,8 +107,11 @@ globals_h = ../src/globals.h $(globals_h): $(MAKE) -C ../src globals.h -## Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk. -@lwlib_deps_frag@ +ifeq ($(AUTO_DEPEND),yes) +-include $(ALLOBJS:%.o=${DEPDIR}/%.d) +else +include $(srcdir)/deps.mk +endif .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean diff --git a/lwlib/autodeps.mk b/lwlib/autodeps.mk deleted file mode 100644 index f710929..0000000 --- a/lwlib/autodeps.mk +++ /dev/null @@ -1,5 +0,0 @@ -### autodeps.mk --- lwlib/Makefile fragment for GNU Emacs - -## This is inserted in lwlib/Makefile if AUTO_DEPEND=yes. - --include $(ALLOBJS:%.o=${DEPDIR}/%.d) diff --git a/lwlib/deps.mk b/lwlib/deps.mk index 11cc056..a19e51f 100644 --- a/lwlib/deps.mk +++ b/lwlib/deps.mk @@ -20,7 +20,7 @@ ### Commentary: -## This file is inserted in lwlib/Makefile if AUTO_DEPEND=no. +## This file is included in lwlib/Makefile if AUTO_DEPEND=no. ## It defines static dependencies between the various source files. ### Code: diff --git a/oldXMenu/Makefile.in b/oldXMenu/Makefile.in index ef2a360..de5b8e1 100644 --- a/oldXMenu/Makefile.in +++ b/oldXMenu/Makefile.in @@ -112,10 +112,15 @@ am__v_at_0 = @ am__v_at_1 = DEPDIR = deps -## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty. -DEPFLAGS = @DEPFLAGS@ -## ${MKDIR_P} ${DEPDIR} (if AUTO_DEPEND); else ':'. -MKDEPDIR = @MKDEPDIR@ +AUTO_DEPEND = @AUTO_DEPEND@ + +ifeq ($(AUTO_DEPEND),yes) +DEPFLAGS = -MMD -MF ${DEPDIR}/$*.d -MP +MKDEPDIR = ${MKDIR_P} ${DEPDIR} +else +DEPFLAGS = +MKDEPDIR = : +endif ALL_CFLAGS=$(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \ $(C_SWITCH_X_SITE) $(DEPFLAGS) \ @@ -132,8 +137,11 @@ libXMenu11.a: $(OBJS) $(EXTRA) $(AM_V_at)$(AR) $(ARFLAGS) $@ $(OBJS) $(EXTRA) $(AM_V_at)$(RANLIB) $@ -## Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk. -@oldxmenu_deps_frag@ +ifeq ($(AUTO_DEPEND),yes) +-include $(ALLOBJS:%.o=${DEPDIR}/%.d) +else +include $(srcdir)/deps.mk +endif .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean diff --git a/oldXMenu/autodeps.mk b/oldXMenu/autodeps.mk deleted file mode 100644 index f710929..0000000 --- a/oldXMenu/autodeps.mk +++ /dev/null @@ -1,5 +0,0 @@ -### autodeps.mk --- lwlib/Makefile fragment for GNU Emacs - -## This is inserted in lwlib/Makefile if AUTO_DEPEND=yes. - --include $(ALLOBJS:%.o=${DEPDIR}/%.d) diff --git a/oldXMenu/deps.mk b/oldXMenu/deps.mk index cdb89f9..54ce358 100644 --- a/oldXMenu/deps.mk +++ b/oldXMenu/deps.mk @@ -32,7 +32,7 @@ ### Commentary: -## This file is inserted in oldXMenu/Makefile if AUTO_DEPEND=no. +## This file is included in oldXMenu/Makefile if AUTO_DEPEND=no. ## It defines static dependencies between the various source files. ### Code: diff --git a/src/Makefile.in b/src/Makefile.in index 1c03b27..51a5b98 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -323,10 +323,15 @@ am__v_at_0 = @ am__v_at_1 = DEPDIR=deps -## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty. -DEPFLAGS=@DEPFLAGS@ -## ${MKDIR_P} ${DEPDIR} (if AUTO_DEPEND); else ':'. -MKDEPDIR=@MKDEPDIR@ +AUTO_DEPEND = @AUTO_DEPEND@ + +ifeq ($(AUTO_DEPEND),yes) +DEPFLAGS = -MMD -MF ${DEPDIR}/$*.d -MP +MKDEPDIR = ${MKDIR_P} ${DEPDIR} +else +DEPFLAGS = +MKDEPDIR = : +endif ## DO NOT use -R. There is a special hack described in lastfile.c ## which is used instead. Some initialized data areas are modified @@ -413,9 +418,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ FIRSTFILE_OBJ=@FIRSTFILE_OBJ@ ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj) -## Configure inserts the file lisp.mk at this point, defining $lisp. -@lisp_frag@ - +include $(srcdir)/lisp.mk ## Construct full set of libraries to be linked. LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ @@ -667,8 +670,10 @@ endif @: Compile some files earlier to speed up further compilation. $(MAKE) -C ../lisp compile-first EMACS="$(bootstrap_exe)" -## Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk. -@deps_frag@ - +ifeq ($(AUTO_DEPEND),yes) +-include $(ALLOBJS:%.o=${DEPDIR}/%.d) +else +include $(srcdir)/deps.mk +endif ### Makefile.in ends here diff --git a/src/autodeps.mk b/src/autodeps.mk deleted file mode 100644 index 8b014a7..0000000 --- a/src/autodeps.mk +++ /dev/null @@ -1,5 +0,0 @@ -### autodeps.mk --- src/Makefile fragment for GNU Emacs - -## This is inserted in src/Makefile if AUTO_DEPEND=yes. - --include $(ALLOBJS:%.o=${DEPDIR}/%.d) diff --git a/src/deps.mk b/src/deps.mk index 71a5f42..2378938 100644 --- a/src/deps.mk +++ b/src/deps.mk @@ -20,7 +20,7 @@ ## Commentary: ## -## This file is inserted in src/Makefile if AUTO_DEPEND=no. +## This file is included in src/Makefile if AUTO_DEPEND=no. ## It defines static dependencies between the various source files. ## FIXME some of these dependencies are platform-specific. commit c7e93c41078193d4df8ca165d3aea50a51c40519 Author: Glenn Morris Date: Fri May 15 18:33:09 2015 -0400 Tweak japanese.el's loading of dependencies. * lisp/loadup.el: Explicitly load cp51932 and eucjp-ms. * lisp/language/japanese.el: Use require rather than load. * lisp/international/cp51932.el, lisp/international/eucjp-ms.el: Provide a feature. * admin/charsets/eucjp-ms.awk, admin/charsets/cp51932.awk: Provide a feature in the generated file. diff --git a/admin/charsets/cp51932.awk b/admin/charsets/cp51932.awk index c8879b3..f59e91c 100644 --- a/admin/charsets/cp51932.awk +++ b/admin/charsets/cp51932.awk @@ -52,4 +52,6 @@ END { print " (setcar x (cdr x)) (setcdr x tmp)))"; print " map)"; print " (define-translation-table 'cp51932-encode map))"; + print ""; + print "(provide 'cp51932)"; } diff --git a/admin/charsets/eucjp-ms.awk b/admin/charsets/eucjp-ms.awk index 18c19f5..f17222d 100644 --- a/admin/charsets/eucjp-ms.awk +++ b/admin/charsets/eucjp-ms.awk @@ -106,5 +106,7 @@ END { print " (setcar x (cdr x)) (setcdr x tmp)))"; print " map)"; print " (define-translation-table 'eucjp-ms-encode map))"; + print ""; + print "(provide 'eucjp-ms)"; } diff --git a/lisp/international/cp51932.el b/lisp/international/cp51932.el index a648926..cb72356 100644 --- a/lisp/international/cp51932.el +++ b/lisp/international/cp51932.el @@ -468,3 +468,5 @@ (setcar x (cdr x)) (setcdr x tmp))) map) (define-translation-table 'cp51932-encode map)) + +(provide 'cp51932) diff --git a/lisp/international/eucjp-ms.el b/lisp/international/eucjp-ms.el index 6e4e1e7..efb0a2b 100644 --- a/lisp/international/eucjp-ms.el +++ b/lisp/international/eucjp-ms.el @@ -2085,3 +2085,5 @@ (setcar x (cdr x)) (setcdr x tmp))) map) (define-translation-table 'eucjp-ms-encode map)) + +(provide 'eucjp-ms) diff --git a/lisp/language/japanese.el b/lisp/language/japanese.el index ce48025..38159d7 100644 --- a/lisp/language/japanese.el +++ b/lisp/language/japanese.el @@ -34,8 +34,8 @@ ;;; Code: ;;; Load translation tables for CP932. -(load "international/cp51932") -(load "international/eucjp-ms") +(require 'cp51932) +(require 'eucjp-ms) (define-coding-system 'iso-2022-jp "ISO 2022 based 7bit encoding for Japanese (MIME:ISO-2022-JP)." diff --git a/lisp/loadup.el b/lisp/loadup.el index 828b19e..525cbad 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -178,6 +178,8 @@ (load "language/romanian") (load "language/greek") (load "language/hebrew") +(load "international/cp51932") +(load "international/eucjp-ms") (load "language/japanese") (load "language/korean") (load "language/lao") diff --git a/src/lisp.mk b/src/lisp.mk index 8eb86b7..0a431a5 100644 --- a/src/lisp.mk +++ b/src/lisp.mk @@ -34,10 +34,6 @@ ## that does not have an explicit .el extension, but beware of any ## no-byte-compile ones. -## Confusingly, international/cp51932 and international/eucjp-ms are -## unconditionally loaded from language/japanese, instead of being -## loaded directly from loadup.el; FIXME. - ## Note that this list should not include lisp files which might not ## be present, like site-load.el and site-init.el; this makefile ## expects them all to be either present or buildable. @@ -96,9 +92,9 @@ lisp = \ $(lispsource)/language/romanian.elc \ $(lispsource)/language/greek.elc \ $(lispsource)/language/hebrew.elc \ - $(lispsource)/language/japanese.elc \ $(lispsource)/international/cp51932.el \ $(lispsource)/international/eucjp-ms.el \ + $(lispsource)/language/japanese.elc \ $(lispsource)/language/korean.elc \ $(lispsource)/language/lao.elc \ $(lispsource)/language/tai-viet.elc \ commit b00168e833ccca1b5c0eebe56688ec44e0efabe7 Author: Jan D Date: Fri May 15 17:06:03 2015 +0200 Fix NS warnings. * nsmenu.m (ns_popup_dialog) * nsimage.m (initFromXBM:width:height:fg:bg:) * nsfns.m (Fx_create_frame): Remove unused variables. (Fns_read_file_name): Initialize fname, remove ret. * nsterm.m (ns_draw_window_cursor): Handle DEFAULT_CURSOR in switch. (ns_get_color, ns_set_horizontal_scroll_bar, keyDown): Remove unused variable. (init): Add parantesis in if. (ns_create_terminal): Assign set_horizontal_scroll_bar_hook. diff --git a/src/nsfns.m b/src/nsfns.m index 5f584e1..8a3c6cc 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1075,7 +1075,6 @@ This function is an internal primitive--use `make-frame' instead. */) Lisp_Object name; int minibuffer_only = 0; long window_prompting = 0; - int width, height; ptrdiff_t count = specpdl_ptr - specpdl; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; Lisp_Object display; @@ -1475,10 +1474,9 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) Lisp_Object init, Lisp_Object dir_only_p) { static id fileDelegate = nil; - BOOL ret; BOOL isSave = NILP (mustmatch) && NILP (dir_only_p); id panel; - Lisp_Object fname; + Lisp_Object fname = Qnil; NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil : [NSString stringWithUTF8String: SSDATA (prompt)]; @@ -1558,20 +1556,17 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) while (ns_fd_data.panel != nil) [NSApp run]; - ret = (ns_fd_data.ret == MODAL_OK_RESPONSE); - - if (ret) + if (ns_fd_data.ret == MODAL_OK_RESPONSE) { NSString *str = ns_filename_from_panel (panel); if (! str) str = ns_directory_from_panel (panel); - if (! str) ret = NO; - else fname = build_string ([str UTF8String]); + if (str) fname = build_string ([str UTF8String]); } [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; unblock_input (); - return ret ? fname : Qnil; + return fname; } const char * diff --git a/src/nsimage.m b/src/nsimage.m index 4d01419..9302cd2 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -211,7 +211,6 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) - initFromXBM: (unsigned char *)bits width: (int)w height: (int)h fg: (unsigned long)fg bg: (unsigned long)bg { - int bpr = (w + 7) / 8; unsigned char *planes[5]; [self initWithSize: NSMakeSize (w, h)]; diff --git a/src/nsmenu.m b/src/nsmenu.m index a4c26fe..b5cb64d 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1418,7 +1418,7 @@ Lisp_Object ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) { id dialog; - Lisp_Object window, tem, title; + Lisp_Object tem, title; NSPoint p; BOOL isQ; NSAutoreleasePool *pool; diff --git a/src/nsterm.m b/src/nsterm.m index 11656a7..67a0389 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1538,7 +1538,7 @@ ns_get_color (const char *name, NSColor **col) { NSColor *new = nil; static char hex[20]; - int scaling; + int scaling = 0; float r = -1.0, g, b; NSString *nsname = [NSString stringWithUTF8String: name]; @@ -2465,6 +2465,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, switch (cursor_type) { + case DEFAULT_CURSOR: case NO_CURSOR: break; case FILLED_BOX_CURSOR: @@ -3963,7 +3964,6 @@ ns_set_horizontal_scroll_bar (struct window *window, EmacsScroller *bar; int top, height, left, width; int window_x, window_width; - int pixel_width = WINDOW_PIXEL_WIDTH (window); BOOL update_p = YES; /* optimization; display engine sends WAY too many of these.. */ @@ -4321,6 +4321,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo) terminal->menu_show_hook = ns_menu_show; terminal->popup_dialog_hook = ns_popup_dialog; terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar; + terminal->set_horizontal_scroll_bar_hook = ns_set_horizontal_scroll_bar; terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars; terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar; terminal->judge_scroll_bars_hook = ns_judge_scroll_bars; @@ -4605,7 +4606,7 @@ ns_term_shutdown (int sig) - (id)init { - if (self = [super init]) + if ((self = [super init])) { #ifdef NS_IMPL_COCOA self->isFirst = YES; @@ -5272,9 +5273,6 @@ not_in_argv (NSString *arg) int code; unsigned fnKeysym = 0; static NSMutableArray *nsEvArray; -#ifdef NS_IMPL_GNUSTEP - static BOOL firstTime = YES; -#endif int left_is_none; unsigned int flags = [theEvent modifierFlags]; @@ -5503,18 +5501,6 @@ not_in_argv (NSString *arg) } -#ifdef NS_IMPL_GNUSTEP - /* if we get here we should send the key for input manager processing */ - /* Disable warning, there is nothing a user can do about it anyway, and - it does not seem to matter. */ -#if 0 - if (firstTime && [[NSInputManager currentInputManager] - wantsToDelayTextChangeNotifications] == NO) - fprintf (stderr, - "Emacs: WARNING: TextInput mgr wants marked text to be permanent!\n"); -#endif - firstTime = NO; -#endif if (NS_KEYLOG && !processingCompose) fprintf (stderr, "keyDown: Begin compose sequence.\n"); @@ -7202,7 +7188,6 @@ if (cols > 0 && rows > 0) one screen, we want to constrain. Other times not. */ NSArray *screens = [NSScreen screens]; NSUInteger nr_screens = [screens count], nr_eff_screens = 0, i; - struct frame *f = ((EmacsView *)[self delegate])->emacsframe; NSTRACE (constrainFrameRect); NSTRACE_RECT ("input", frameRect); commit d02ce2c4321d7b99abc2de21e01f9504008ec735 Author: Jan Djärv Date: Fri May 15 16:50:01 2015 +0200 Fix a enum conversion warning in macfont.m * src/macfont.h (CharacterCollection): Typedef to NSCharacterCollection. (MAC_CHARACTER_COLLECTION_*): Use the NS variants. diff --git a/src/macfont.h b/src/macfont.h index f311577..403be94 100644 --- a/src/macfont.h +++ b/src/macfont.h @@ -48,7 +48,7 @@ struct mac_glyph_layout typedef CTFontDescriptorRef FontDescriptorRef; typedef CTFontRef FontRef; typedef CTFontSymbolicTraits FontSymbolicTraits; -typedef CTCharacterCollection CharacterCollection; +typedef NSCharacterCollection CharacterCollection; #define MAC_FONT_NAME_ATTRIBUTE kCTFontNameAttribute #define MAC_FONT_FAMILY_NAME_ATTRIBUTE kCTFontFamilyNameAttribute @@ -79,8 +79,8 @@ enum { }; enum { - MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING = kCTIdentityMappingCharacterCollection, - MAC_CHARACTER_COLLECTION_ADOBE_JAPAN1 = kCTAdobeJapan1CharacterCollection + MAC_CHARACTER_COLLECTION_IDENTITY_MAPPING = NSIdentityMappingCharacterCollection, + MAC_CHARACTER_COLLECTION_ADOBE_JAPAN1 = NSAdobeJapan1CharacterCollection }; #define mac_font_descriptor_create_with_attributes \ commit b7b0d6e25376b98404197bf0539b795d541d29f9 Author: Jan Djärv Date: Fri May 15 16:23:29 2015 +0200 cus-start.el: Add ns-confirm-quit. * cus-start.el: Add ns-confirm-quit. diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 071aaa6..b4d2139 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -438,6 +438,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (const super)) "23.1") (ns-antialias-text ns boolean "23.1") (ns-auto-hide-menu-bar ns boolean "24.1") + (ns-confirm-quit ns boolean "25.1") (ns-use-native-fullscreen ns boolean "24.4") (ns-use-fullscreen-animation ns boolean "25.1") (ns-use-srgb-colorspace ns boolean "24.4") commit e0e0753505cc2efefcee16bbed99ec6b9e5bcb39 Author: Jan Djärv Date: Fri May 15 16:21:59 2015 +0200 Fix warnings on OSX 10.10. * nsfns.m (MODAL_OK_RESPONSE): New define for different OSX versions. (Fns_read_file_name): Check against MODAL_OK_RESPONSE. (compute_tip_xy): Use convertRectToScreen for OSX >= 10.7 * nsmenu.m (initWithContentRect:styleMask:backing:defer:) * nsimage.m (allocInitFromFile, setPixmapData): Only call setScalesWhenResized for OSX < 10.6. * nsterm.h (EmacsScroller): Declare scrollerWidth. * nsterm.m (ns_copy_bits): New function that does not use deprecated NSCopyBits. (ns_scroll_run, ns_shift_glyphs_for_insert): Call ns_copy_bits. (runAlertPanel): New function. (applicationShouldTerminate:): Call runAlertPanel. (initFrameFromEmacs, toggleFullScreen:): Only call useOptimizedDrawing for OSX < 10.10. (initFrameFromEmacs:): Only call allocateGState for OSX < 10.10. (windowWillUseStandardFrame:defaultFrame:): Cast arg to abs to int. (draggingEntered:): Returns NSDragOperation. (scrollerWidth): Use scrollerWidthForControlSize for OSX >= 10.7. diff --git a/src/nsfns.m b/src/nsfns.m index f8863e6..5f584e1 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1455,6 +1455,15 @@ ns_run_file_dialog (void) ns_fd_data.panel = nil; } +#ifdef NS_IMPL_COCOA +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9 +#define MODAL_OK_RESPONSE NSModalResponseOK +#endif +#endif +#ifndef MODAL_OK_RESPONSE +#define MODAL_OK_RESPONSE NSOKButton +#endif + DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0, doc: /* Use a graphical panel to read a file name, using prompt PROMPT. Optional arg DIR, if non-nil, supplies a default directory. @@ -1549,7 +1558,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) while (ns_fd_data.panel != nil) [NSApp run]; - ret = (ns_fd_data.ret == NSOKButton); + ret = (ns_fd_data.ret == MODAL_OK_RESPONSE); if (ret) { @@ -2677,7 +2686,16 @@ compute_tip_xy (struct frame *f, pt.y = dpyinfo->last_mouse_motion_y; /* Convert to screen coordinates */ pt = [view convertPoint: pt toView: nil]; +#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 pt = [[view window] convertBaseToScreen: pt]; +#else + { + NSRect r = NSMakeRect (pt.x, pt.y, 0, 0); + r = [[view window] convertRectToScreen: r]; + pt.x = r.origin.x; + pt.y = r.origin.y; + } +#endif } else { diff --git a/src/nsimage.m b/src/nsimage.m index 3e90226..4d01419 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -187,7 +187,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) /* The next two lines cause the DPI of the image to be ignored. This seems to be the behavior users expect. */ +#ifdef NS_IMPL_COCOA +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 [image setScalesWhenResized: YES]; +#endif +#endif [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; [image setName: [NSString stringWithUTF8String: SSDATA (file)]]; @@ -353,7 +357,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) /* The next two lines cause the DPI of the image to be ignored. This seems to be the behavior users expect. */ +#ifdef NS_IMPL_COCOA +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 [self setScalesWhenResized: YES]; +#endif +#endif [self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])]; break; diff --git a/src/nsmenu.m b/src/nsmenu.m index 26fe26e..a4c26fe 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1506,7 +1506,11 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) area.size.width = ICONSIZE; area.size.height= ICONSIZE; img = [[NSImage imageNamed: @"NSApplicationIcon"] copy]; +#ifdef NS_IMPL_COCOA +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 [img setScalesWhenResized: YES]; +#endif +#endif [img setSize: NSMakeSize (ICONSIZE, ICONSIZE)]; imgView = [[NSImageView alloc] initWithFrame: area]; [imgView setImage: img]; diff --git a/src/nsterm.h b/src/nsterm.h index d8ffd93..c06b7c4 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -396,6 +396,7 @@ typedef float EmacsCGFloat; - condemn; - reprieve; - (bool)judge; ++ (CGFloat)scrollerWidth; @end diff --git a/src/nsterm.m b/src/nsterm.m index 6a4d0a6..11656a7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2093,6 +2093,18 @@ ns_clear_frame_area (struct frame *f, int x, int y, int width, int height) return; } +static void +ns_copy_bits (struct frame *f, NSRect src, NSRect dest) +{ + if (FRAME_NS_VIEW (f)) + { + ns_focus (f, &dest, 1); + [FRAME_NS_VIEW (f) scrollRect: src + by: NSMakeSize (dest.origin.x - src.origin.x, + dest.origin.y - src.origin.y)]; + ns_unfocus (f); + } +} static void ns_scroll_run (struct window *w, struct run *run) @@ -2145,11 +2157,8 @@ ns_scroll_run (struct window *w, struct run *run) { NSRect srcRect = NSMakeRect (x, from_y, width, height); NSRect dstRect = NSMakeRect (x, to_y, width, height); - NSPoint dstOrigin = NSMakePoint (x, to_y); - ns_focus (f, &dstRect, 1); - NSCopyBits (0, srcRect , dstOrigin); - ns_unfocus (f); + ns_copy_bits (f, srcRect , dstRect); } unblock_input (); @@ -2205,13 +2214,10 @@ ns_shift_glyphs_for_insert (struct frame *f, { NSRect srcRect = NSMakeRect (x, y, width, height); NSRect dstRect = NSMakeRect (x+shift_by, y, width, height); - NSPoint dstOrigin = dstRect.origin; NSTRACE (ns_shift_glyphs_for_insert); - ns_focus (f, &dstRect, 1); - NSCopyBits (0, srcRect, dstOrigin); - ns_unfocus (f); + ns_copy_bits (f, srcRect, dstRect); } @@ -4886,21 +4892,43 @@ ns_term_shutdown (int sig) EV_TRAILER ((id)nil); } +static bool +runAlertPanel(NSString *title, + NSString *msgFormat, + NSString *defaultButton, + NSString *alternateButton) +{ +#if !defined (NS_IMPL_COCOA) || \ + MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 + return NSRunAlertPanel(title, msgFormat, defaultButton, alternateButton, nil) + == NSAlertDefaultReturn; +#else + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle: NSCriticalAlertStyle]; + [alert setMessageText: msgFormat]; + [alert addButtonWithTitle: defaultButton]; + [alert addButtonWithTitle: alternateButton]; + NSInteger ret = [alert runModal]; + [alert release]; + return ret == NSAlertFirstButtonReturn; +#endif +} + - (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender { - int ret; + bool ret; if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO return NSTerminateNow; - ret = NSRunAlertPanel(ns_app_name, - @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?", - @"Save Buffers and Exit", @"Cancel", nil); + ret = runAlertPanel(ns_app_name, + @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?", + @"Save Buffers and Exit", @"Cancel"); - if (ret == NSAlertDefaultReturn) + if (ret) return NSTerminateNow; - else if (ret == NSAlertAlternateReturn) + else return NSTerminateCancel; return NSTerminateNow; /* just in case */ } @@ -6251,8 +6279,10 @@ if (cols > 0 && rows > 0) [win setAcceptsMouseMovedEvents: YES]; [win setDelegate: self]; +#if !defined (NS_IMPL_COCOA) || \ + MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 [win useOptimizedDrawing: YES]; - +#endif sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); [win setResizeIncrements: sz]; @@ -6313,8 +6343,10 @@ if (cols > 0 && rows > 0) if ([col alphaComponent] != (EmacsCGFloat) 1.0) [win setOpaque: NO]; +#if !defined (NS_IMPL_COCOA) || \ + MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 [self allocateGState]; - +#endif [NSApp registerServicesMenuSendTypes: ns_send_types returnTypes: nil]; @@ -6369,7 +6401,7 @@ if (cols > 0 && rows > 0) } else if (next_maximized == FULLSCREEN_HEIGHT || (next_maximized == -1 - && abs (defaultFrame.size.height - result.size.height) + && abs ((int)(defaultFrame.size.height - result.size.height)) > FRAME_LINE_HEIGHT (emacsframe))) { /* first click */ @@ -6392,7 +6424,7 @@ if (cols > 0 && rows > 0) } else if (next_maximized == FULLSCREEN_MAXIMIZED || (next_maximized == -1 - && abs (defaultFrame.size.width - result.size.width) + && abs ((int)(defaultFrame.size.width - result.size.width)) > FRAME_COLUMN_WIDTH (emacsframe))) { result = defaultFrame; /* second click */ @@ -6639,7 +6671,10 @@ if (cols > 0 && rows > 0) [fw setTitle:[w title]]; [fw setDelegate:self]; [fw setAcceptsMouseMovedEvents: YES]; +#if !defined (NS_IMPL_COCOA) || \ + MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 [fw useOptimizedDrawing: YES]; +#endif [fw setResizeIncrements: sz]; [fw setBackgroundColor: col]; if ([col alphaComponent] != (EmacsCGFloat) 1.0) @@ -6882,7 +6917,7 @@ if (cols > 0 && rows > 0) /* NSDraggingDestination protocol methods. Actually this is not really a protocol, but a category of Object. O well... */ --(NSUInteger) draggingEntered: (id ) sender +-(NSDragOperation) draggingEntered: (id ) sender { NSTRACE (draggingEntered); return NSDragOperationGeneric; @@ -7263,7 +7298,15 @@ if (cols > 0 && rows > 0) { /* TODO: if we want to allow variable widths, this is the place to do it, however neither GNUstep nor Cocoa support it very well */ - return [NSScroller scrollerWidth]; + CGFloat r; +#if !defined (NS_IMPL_COCOA) || \ + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 + r = [NSScroller scrollerWidth]; +#else + r = [NSScroller scrollerWidthForControlSize: NSRegularControlSize + scrollerStyle: NSScrollerStyleLegacy]; +#endif + return r; } commit 2abfe21de9241aea36f7221184886b6b39f7648b Author: Artur Malabarba Date: Fri May 15 10:54:48 2015 +0100 * lisp/emacs-lisp/package.el: Don't ensure-init during startup (package--init-file-ensured): New variable. (package-initialize, package--ensure-init-file): Use it. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 1d27bf7..55fa962 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1346,6 +1346,9 @@ If successful, set `package-archive-contents'." ;; available on disk. (defvar package--initialized nil) +(defvar package--init-file-ensured nil + "Whether we know the init file has package-initialize.") + ;;;###autoload (defun package-initialize (&optional no-activate) "Load Emacs Lisp packages, and activate them. @@ -1355,7 +1358,11 @@ If `user-init-file' does not mention `(package-initialize)', add it to the file." (interactive) (setq package-alist nil) - (package--ensure-init-file) + (if (equal user-init-file load-file-name) + ;; If `package-initialize' is being called as part of loading + ;; the init file, it's obvious we don't need to ensure-init. + (setq package--init-file-ensured t) + (package--ensure-init-file)) (package-load-all-descriptors) (package-read-all-archive-contents) (unless no-activate @@ -1802,6 +1809,7 @@ present somewhere in the file, even as a comment. If it is not, add a call to it along with some explanatory comments." ;; Don't mess with the init-file from "emacs -Q". (when (and (stringp user-init-file) + (not package--init-file-ensured) (file-readable-p user-init-file) (file-writable-p user-init-file)) (let* ((buffer (find-buffer-visiting user-init-file)) @@ -1841,7 +1849,8 @@ add a call to it along with some explanatory comments." (let ((file-precious-flag t)) (save-buffer)) (unless buffer - (kill-buffer (current-buffer)))))))))) + (kill-buffer (current-buffer))))))))) + (setq package--init-file-ensured t)) ;;;###autoload (defun package-install (pkg &optional dont-select async callback) commit 67a878f78f879ce534232408c34dd11f42dd802b Author: Jan Djärv Date: Fri May 15 11:31:38 2015 +0200 Honor :fore/background for XBM on NS (Bug#14969). * nsterm.h (EmacsImage): Add xbm_fg, remove initFromSkipXBM, initFromXBM takes bg, fg args, remove flip arg. (ns_image_from_XBM): Add bg, fg args. * image.c (x_create_bitmap_from_data) (Create_Pixmap_From_Bitmap_Data): ns_image_from_XBM takes bg, fg args. * nsimage.m (ns_image_from_XBM): Add fg, bg args, pass to initFromXBM. Remove flip arg. (initFromSkipXBM): Move code to initFromXBM. (initFromXBM): Actually set fg and bg, instead of playing alpha games. Use fg, bg from args (Bug#14969). Remove if (length) section, was always false. Remove bit flipping (bitPat, swt), generated incorrect images when width/height wasn't a multiple of 8. (setXBMColor:): Modify planes by comparing to saved xbm_fg. * nsterm.m (ns_draw_fringe_bitmap): initFromXBM takes fg, bg args, remove flip arg. diff --git a/src/image.c b/src/image.c index 5e48438..d7f48bd 100644 --- a/src/image.c +++ b/src/image.c @@ -233,7 +233,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi #endif /* HAVE_NTGUI */ #ifdef HAVE_NS - void *bitmap = ns_image_from_XBM (bits, width, height); + void *bitmap = ns_image_from_XBM (bits, width, height, 0, 0); if (!bitmap) return -1; #endif @@ -2648,7 +2648,7 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data, convert_mono_to_color_image (f, img, fg, bg); #elif defined (HAVE_NS) - img->pixmap = ns_image_from_XBM (data, img->width, img->height); + img->pixmap = ns_image_from_XBM (data, img->width, img->height, fg, bg); #else img->pixmap = diff --git a/src/nsimage.m b/src/nsimage.m index f37ad38..3e90226 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -53,12 +53,13 @@ int image_trace_num = 0; ========================================================================== */ void * -ns_image_from_XBM (unsigned char *bits, int width, int height) +ns_image_from_XBM (unsigned char *bits, int width, int height, + unsigned long fg, unsigned long bg) { NSTRACE (ns_image_from_XBM); return [[EmacsImage alloc] initFromXBM: bits width: width height: height - flip: YES]; + fg: fg bg: bg]; } void * @@ -204,14 +205,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) - initFromXBM: (unsigned char *)bits width: (int)w height: (int)h - flip: (BOOL)flip -{ - return [self initFromSkipXBM: bits width: w height: h flip: flip length: 0]; -} - - -- initFromSkipXBM: (unsigned char *)bits width: (int)w height: (int)h - flip: (BOOL)flip length: (int)length; + fg: (unsigned long)fg bg: (unsigned long)bg { int bpr = (w + 7) / 8; unsigned char *planes[5]; @@ -226,57 +220,58 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) bytesPerRow: w bitsPerPixel: 0]; [bmRep getBitmapDataPlanes: planes]; + + if (fg == 0 && bg == 0) + bg = 0xffffff; + { /* pull bits out to set the (bytewise) alpha mask */ int i, j, k; unsigned char *s = bits; + unsigned char *rr = planes[0]; + unsigned char *gg = planes[1]; + unsigned char *bb = planes[2]; unsigned char *alpha = planes[3]; - unsigned char swt[16] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, - 3, 11, 7, 15}; - unsigned char c, bitPat; - - for (j = 0; j < h; j++) - for (i = 0; i < bpr; i++) + unsigned char fgr = (fg >> 16) & 0xff; + unsigned char fgg = (fg >> 8) & 0xff; + unsigned char fgb = fg & 0xff; + unsigned char bgr = (bg >> 16) & 0xff; + unsigned char bgg = (bg >> 8) & 0xff; + unsigned char bgb = bg & 0xff; + unsigned char c; + + int idx = 0; + for (j = 0; j < h; ++j) + for (i = 0; i < w; ) { - if (length) + c = *s++; + for (k = 0; i < w && k < 8; ++k, ++i) { - unsigned char s1, s2; - while (*s++ != 'x' && s < bits + length); - if (s >= bits + length) + *alpha++ = 0xff; + if (c & 1) { - [bmRep release]; - bmRep = nil; - return nil; + *rr++ = fgr; + *gg++ = fgg; + *bb++ = fgb; } -#define hexchar(x) ('0' <= (x) && (x) <= '9' ? (x) - '0' : (x) - 'a' + 10) - s1 = *s++; - s2 = *s++; - c = hexchar (s1) * 0x10 + hexchar (s2); - } - else - c = *s++; - - bitPat = flip ? swt[c >> 4] | (swt[c & 0xf] << 4) : c ^ 255; - for (k =0; k<8; k++) - { - *alpha++ = (bitPat & 0x80) ? 0xff : 0; - bitPat <<= 1; + else + { + *rr++ = bgr; + *gg++ = bgg; + *bb++ = bgb; + } + idx++; + c >>= 1; } } } + xbm_fg = fg; [self addRepresentation: bmRep]; - - memset (planes[0], 0, w*h); - memset (planes[1], 0, w*h); - memset (planes[2], 0, w*h); - [self setXBMColor: [NSColor blackColor]]; return self; } - -/* Set color for a bitmap image (see initFromSkipXBM). Note that the alpha - is used as a mask, so we just memset the entire array. */ +/* Set color for a bitmap image. */ - setXBMColor: (NSColor *)color { NSSize s = [self size]; @@ -296,19 +291,21 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) [bmRep getBitmapDataPlanes: planes]; - /* 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> 16) & 0xff; + unsigned char fgg = (xbm_fg >> 8) & 0xff; + unsigned char fgb = xbm_fg & 0xff; + + for (i = 0; i < len; ++i) + if (planes[0][i] == fgr && planes[1][i] == fgg && planes[2][i] == fgb) { planes[0][i] = rr; planes[1][i] = gg; planes[2][i] = bb; } + xbm_fg = ((rr << 16) & 0xff) + ((gg << 8) & 0xff) + (bb & 0xff); } return self; diff --git a/src/nsterm.h b/src/nsterm.h index 9035ee1..d8ffd93 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -341,13 +341,12 @@ typedef float EmacsCGFloat; NSBitmapImageRep *bmRep; /* used for accessing pixel data */ unsigned char *pixmapData[5]; /* shortcut to access pixel data */ NSColor *stippleMask; + unsigned long xbm_fg; } + allocInitFromFile: (Lisp_Object)file; - (void)dealloc; - initFromXBM: (unsigned char *)bits width: (int)w height: (int)h - flip: (BOOL)flip; -- initFromSkipXBM: (unsigned char *)bits width: (int)w height: (int)h - flip: (BOOL)flip length: (int)length; + fg: (unsigned long)fg bg: (unsigned long)bg; - setXBMColor: (NSColor *)color; - initForXPMWithDepth: (int)depth width: (int)width height: (int)height; - (void)setPixmapData; @@ -864,7 +863,8 @@ extern void syms_of_nsselect (void); /* From nsimage.m, needed in image.c */ struct image; -extern void *ns_image_from_XBM (unsigned char *bits, int width, int height); +extern void *ns_image_from_XBM (unsigned char *bits, int width, int height, + unsigned long fg, unsigned long bg); extern void *ns_image_for_XPM (int width, int height, int depth); extern void *ns_image_from_file (Lisp_Object file); extern bool ns_load_image (struct frame *f, struct image *img, diff --git a/src/nsterm.m b/src/nsterm.m index 187086c..6a4d0a6 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2317,7 +2317,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, for (i = 0; i < len; i++) cbits[i] = ~(bits[i] & 0xff); img = [[EmacsImage alloc] initFromXBM: cbits width: 8 height: p->h - flip: NO]; + fg: 0 bg: 0]; bimgs[p->which - 1] = img; xfree (cbits); } commit b1c23fb94072cca7f08ea5f50430916b9ea168e6 Author: Artur Malabarba Date: Fri May 15 10:17:48 2015 +0100 * lisp/emacs-lisp/package.el: Be more careful with the init file (package--ensure-init-file): Check that user-init-file is set, exists, is readable, and is writable. (Bug#20584) Also expand the docstring. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 6156313..1d27bf7 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1796,9 +1796,14 @@ using `package-compute-transaction'." (callback (funcall callback)))) (defun package--ensure-init-file () - "Ensure that the user's init file calls `package-initialize'." + "Ensure that the user's init file has `package-initialize'. +`package-initialize' doesn't have to be called, as long as it is +present somewhere in the file, even as a comment. If it is not, +add a call to it along with some explanatory comments." ;; Don't mess with the init-file from "emacs -Q". - (when user-init-file + (when (and (stringp user-init-file) + (file-readable-p user-init-file) + (file-writable-p user-init-file)) (let* ((buffer (find-buffer-visiting user-init-file)) (contains-init (if buffer