diff options
| author | Xue Fuqiao | 2013-06-04 07:34:27 +0800 |
|---|---|---|
| committer | Xue Fuqiao | 2013-06-04 07:34:27 +0800 |
| commit | c362f1950814689b0a6f03f0fa48b07784b90a16 (patch) | |
| tree | ecb082e3fcca890b57ddc42f733808cca5e782a3 /src | |
| parent | d3ffe17c6f56435ebd2aca787122a3982ac5fcb2 (diff) | |
| parent | b9110c6b2f796b5147b018c3d70df9d6af657eff (diff) | |
| download | emacs-c362f1950814689b0a6f03f0fa48b07784b90a16.tar.gz emacs-c362f1950814689b0a6f03f0fa48b07784b90a16.zip | |
Merge from mainline.
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 21 | ||||
| -rw-r--r-- | src/ChangeLog | 242 | ||||
| -rw-r--r-- | src/Makefile.in | 20 | ||||
| -rw-r--r-- | src/alloc.c | 17 | ||||
| -rw-r--r-- | src/data.c | 61 | ||||
| -rw-r--r-- | src/emacs.c | 8 | ||||
| -rw-r--r-- | src/eval.c | 485 | ||||
| -rw-r--r-- | src/frame.c | 7 | ||||
| -rw-r--r-- | src/frame.h | 2 | ||||
| -rw-r--r-- | src/gfilenotify.c | 266 | ||||
| -rw-r--r-- | src/keyboard.c | 56 | ||||
| -rw-r--r-- | src/lisp.h | 116 | ||||
| -rw-r--r-- | src/nsfns.m | 71 | ||||
| -rw-r--r-- | src/nsfont.m | 42 | ||||
| -rw-r--r-- | src/nsimage.m | 4 | ||||
| -rw-r--r-- | src/nsmenu.m | 70 | ||||
| -rw-r--r-- | src/nsselect.m | 3 | ||||
| -rw-r--r-- | src/nsterm.h | 44 | ||||
| -rw-r--r-- | src/nsterm.m | 212 | ||||
| -rw-r--r-- | src/process.c | 17 | ||||
| -rw-r--r-- | src/process.h | 3 | ||||
| -rw-r--r-- | src/profiler.c | 17 | ||||
| -rw-r--r-- | src/puresize.h | 4 | ||||
| -rw-r--r-- | src/term.c | 9 | ||||
| -rw-r--r-- | src/termhooks.h | 2 | ||||
| -rw-r--r-- | src/w32.c | 2 | ||||
| -rw-r--r-- | src/w32console.c | 16 | ||||
| -rw-r--r-- | src/w32inevt.c | 8 | ||||
| -rw-r--r-- | src/w32term.c | 7 | ||||
| -rw-r--r-- | src/w32term.h | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 9 | ||||
| -rw-r--r-- | src/xgselect.c | 4 |
32 files changed, 1241 insertions, 606 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index c4604e6e2b0..1bfc293c466 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -1150,17 +1150,18 @@ Print $ assuming it is a list font (font-spec, font-entity, or font-object). | |||
| 1150 | end | 1150 | end |
| 1151 | 1151 | ||
| 1152 | define xbacktrace | 1152 | define xbacktrace |
| 1153 | set $bt = backtrace_list | 1153 | set $bt = backtrace_top () |
| 1154 | while $bt | 1154 | while backtrace_p ($bt) |
| 1155 | xgettype ($bt->function) | 1155 | set $fun = backtrace_function ($bt) |
| 1156 | xgettype $fun | ||
| 1156 | if $type == Lisp_Symbol | 1157 | if $type == Lisp_Symbol |
| 1157 | xprintsym ($bt->function) | 1158 | xprintsym $fun |
| 1158 | printf " (0x%x)\n", $bt->args | 1159 | printf " (0x%x)\n", backtrace_args ($bt) |
| 1159 | else | 1160 | else |
| 1160 | xgetptr $bt->function | 1161 | xgetptr $fun |
| 1161 | printf "0x%x ", $ptr | 1162 | printf "0x%x ", $ptr |
| 1162 | if $type == Lisp_Vectorlike | 1163 | if $type == Lisp_Vectorlike |
| 1163 | xgetptr ($bt->function) | 1164 | xgetptr $fun |
| 1164 | set $size = ((struct Lisp_Vector *) $ptr)->header.size | 1165 | set $size = ((struct Lisp_Vector *) $ptr)->header.size |
| 1165 | if ($size & PSEUDOVECTOR_FLAG) | 1166 | if ($size & PSEUDOVECTOR_FLAG) |
| 1166 | output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS) | 1167 | output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS) |
| @@ -1172,7 +1173,7 @@ define xbacktrace | |||
| 1172 | end | 1173 | end |
| 1173 | echo \n | 1174 | echo \n |
| 1174 | end | 1175 | end |
| 1175 | set $bt = $bt->next | 1176 | set $bt = backtrace_next ($bt) |
| 1176 | end | 1177 | end |
| 1177 | end | 1178 | end |
| 1178 | document xbacktrace | 1179 | document xbacktrace |
| @@ -1220,8 +1221,8 @@ end | |||
| 1220 | 1221 | ||
| 1221 | # Show Lisp backtrace after normal backtrace. | 1222 | # Show Lisp backtrace after normal backtrace. |
| 1222 | define hookpost-backtrace | 1223 | define hookpost-backtrace |
| 1223 | set $bt = backtrace_list | 1224 | set $bt = backtrace_top () |
| 1224 | if $bt | 1225 | if backtrace_p ($bt) |
| 1225 | echo \n | 1226 | echo \n |
| 1226 | echo Lisp Backtrace:\n | 1227 | echo Lisp Backtrace:\n |
| 1227 | xbacktrace | 1228 | xbacktrace |
diff --git a/src/ChangeLog b/src/ChangeLog index 65a49bae1dc..7fdd456c9a7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,245 @@ | |||
| 1 | 2013-06-03 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32console.c (initialize_w32_display): Return the dimensions of | ||
| 4 | the console window via 2 additional arguments, not via the current | ||
| 5 | frame. This avoids crashes due to overrunning the bounds of | ||
| 6 | frame's decode_mode_spec_buffer, which is not resized following | ||
| 7 | the change of the frame dimensions from the initial 10x10. | ||
| 8 | |||
| 9 | * w32term.h (w32_initialize_display_info): Adjust prototype. | ||
| 10 | |||
| 11 | * term.c (init_tty): Take dimensions of the frame from the values | ||
| 12 | returned by initialize_w32_display. | ||
| 13 | |||
| 14 | * Makefile.in (GFILENOTIFY_CFLAGS, GFILENOTIFY_LIBS): New variables. | ||
| 15 | (ALL_CFLAGS): Add $(GFILENOTIFY_CFLAGS). | ||
| 16 | (LIBES): Add $(GFILENOTIFY_LIBS). | ||
| 17 | |||
| 18 | * w32inevt.c (handle_file_notifications): Add dummy implementation | ||
| 19 | for !HAVE_W32NOTIFY. | ||
| 20 | |||
| 21 | * w32term.c: Wrap code with HAVE_W32NOTIFY. | ||
| 22 | |||
| 23 | 2013-06-03 Jan Djärv <jan.h.d@swipnet.se> | ||
| 24 | |||
| 25 | * xgselect.c: Replace #if defined ... with #ifdef HAVE_GLIB. | ||
| 26 | |||
| 27 | * process.c (wait_reading_process_output): Call xg_select if HAVE_GLIB. | ||
| 28 | |||
| 29 | * Makefile.in (XGSELOBJ): New, xgselect.o if GLib is used, or empty. | ||
| 30 | |||
| 31 | 2013-06-03 Paul Eggert <eggert@cs.ucla.edu> | ||
| 32 | |||
| 33 | Fix minor problems found by static checking. | ||
| 34 | * data.c (pure_write_error): | ||
| 35 | Use xsignal2, not Fsignal, as Fsignal might return. | ||
| 36 | * eval.c (set_backtrace_debug_on_exit): Now static. | ||
| 37 | (backtrace_p, backtrace_top, backtrace_next, record_in_backtrace): | ||
| 38 | No longer inline. EXTERN_INLINE is needed only for functions | ||
| 39 | defined in .h files. Reindent function header as per GNU style. | ||
| 40 | (backtrace_p, backtrace_top, backtrace_next): | ||
| 41 | Mark EXTERNALLY_VISIBLE so they don't get optimized away by the | ||
| 42 | compiler or linker. Add extern decls to pacify gcc -Wall. | ||
| 43 | * frame.c, frame.h (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): | ||
| 44 | Now static. | ||
| 45 | * frame.c (free_monitors): Define only on platforms that need it. | ||
| 46 | * nsterm.m (ns_term_init): | ||
| 47 | * process.c (catch_child_signal): | ||
| 48 | Don't worry about whether SIGCHLD is defined, as SIGCHLD is | ||
| 49 | defined on all porting targets these days. | ||
| 50 | * process.c, process.h (catch_child_signal): | ||
| 51 | Make it extern only if NS_IMPL_GNUSTEP is defined. | ||
| 52 | |||
| 53 | 2013-06-03 Eli Zaretskii <eliz@gnu.org> | ||
| 54 | |||
| 55 | * w32.c (gettimeofday): Make the signature identical to prototype | ||
| 56 | in nt/inc/sys/time.h. | ||
| 57 | |||
| 58 | 2013-06-03 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 59 | |||
| 60 | * eval.c (backtrace_p, backtrace_top, backtrace_next): Export them to | ||
| 61 | .gdbinit. | ||
| 62 | |||
| 63 | * keyboard.c (safe_run_hooks_error): Improve error message. | ||
| 64 | |||
| 65 | * data.c (pure_write_error): Add `object' argument. | ||
| 66 | * puresize.h (CHECK_IMPURE): Use it. | ||
| 67 | |||
| 68 | 2013-06-03 Michael Albinus <michael.albinus@gmx.de> | ||
| 69 | |||
| 70 | * Makefile.in (NOTIFY_OBJ): New variable. | ||
| 71 | (base_obj): Replace inotify.o by $(NOTIFY_OBJ). | ||
| 72 | |||
| 73 | * emacs.c (main): Use HAVE_W32NOTIFY to wrap respective code. | ||
| 74 | Call syms_of_gfilenotify. | ||
| 75 | |||
| 76 | * gfilenotify.c: New file. | ||
| 77 | |||
| 78 | * keyboard.c (Qfile_notify): New variable. Replaces Qfile_inotify | ||
| 79 | and Qfile_w32notify. | ||
| 80 | (top): Wrap respective code by HAVE_GFILENOTIFY, HAVE_INOTIFY, | ||
| 81 | HAVE_W32NOTIFY and USE_FILE_NOTIFY. | ||
| 82 | |||
| 83 | * lisp.h: Declare syms_of_gfilenotify. | ||
| 84 | |||
| 85 | * termhooks.h (e): Wrap enum by USE_FILE_NOTIFY. | ||
| 86 | |||
| 87 | 2013-06-03 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 88 | |||
| 89 | Merge the specpdl and backtrace stacks. Make the structure of the | ||
| 90 | specpdl entries more obvious via a tagged union of structs. | ||
| 91 | * lisp.h (BITS_PER_PTRDIFF_T): New constant. | ||
| 92 | (enum specbind_tag): New enum. | ||
| 93 | (struct specbinding): Make it a tagged union of structs. | ||
| 94 | Add a case for backtrace records. | ||
| 95 | (specpdl_symbol, specpdl_old_value, specpdl_where, specpdl_arg) | ||
| 96 | (specpdl_func, backtrace_function, backtrace_nargs, backtrace_args) | ||
| 97 | (backtrace_debug_on_exit): New accessors. | ||
| 98 | (struct backtrace): Remove. | ||
| 99 | (struct catchtag): Remove backlist field. | ||
| 100 | * data.c (let_shadows_buffer_binding_p, let_shadows_global_binding_p): | ||
| 101 | Move to eval.c. | ||
| 102 | (Flocal_variable_p): Speed up the common case where the binding is | ||
| 103 | already loaded. | ||
| 104 | * eval.c (backtrace_list): Remove. | ||
| 105 | (set_specpdl_symbol, set_specpdl_old_value): Remove. | ||
| 106 | (set_backtrace_args, set_backtrace_nargs) | ||
| 107 | (set_backtrace_debug_on_exit, backtrace_p, backtrace_top) | ||
| 108 | (backtrace_next): New functions. | ||
| 109 | (Fdefvaralias, Fdefvar): Adjust to new specpdl format. | ||
| 110 | (unwind_to_catch, internal_lisp_condition_case) | ||
| 111 | (internal_condition_case, internal_condition_case_1) | ||
| 112 | (internal_condition_case_2, internal_condition_case_n): Don't bother | ||
| 113 | with backtrace_list any more. | ||
| 114 | (Fsignal): Adjust to new backtrace format. | ||
| 115 | (grow_specpdl): Move up. | ||
| 116 | (record_in_backtrace): New function. | ||
| 117 | (eval_sub, Ffuncall): Use it. | ||
| 118 | (apply_lambda): Adjust to new backtrace format. | ||
| 119 | (let_shadows_buffer_binding_p, let_shadows_global_binding_p): Move from | ||
| 120 | data.c. | ||
| 121 | (specbind): Adjust to new specpdl format. Simplify. | ||
| 122 | (record_unwind_protect, unbind_to): Adjust to new specpdl format. | ||
| 123 | (Fbacktrace_debug, Fbacktrace, Fbacktrace_frame): Adjust to new | ||
| 124 | backtrace format. | ||
| 125 | (mark_backtrace): Remove. | ||
| 126 | (mark_specpdl, get_backtrace, backtrace_top_function): New functions. | ||
| 127 | * xdisp.c (redisplay_internal): Use record_in_backtrace. | ||
| 128 | * alloc.c (Fgarbage_collect): Use record_in_backtrace. | ||
| 129 | Use mark_specpdl. | ||
| 130 | * profiler.c (record_backtrace): Use get_backtrace. | ||
| 131 | (handle_profiler_signal): Use backtrace_top_function. | ||
| 132 | * .gdbinit (xbacktrace, hookpost-backtrace): Use new backtrace | ||
| 133 | accessor functions. | ||
| 134 | |||
| 135 | 2013-06-02 Jan Djärv <jan.h.d@swipnet.se> | ||
| 136 | |||
| 137 | * process.h (catch_child_signal): Declare. | ||
| 138 | |||
| 139 | * process.c (catch_child_signal): New function. | ||
| 140 | (init_process_emacs): Call it. | ||
| 141 | |||
| 142 | * nsterm.m: Include process.h if NS_IMPL_GNUSTEP. | ||
| 143 | (ns_menu_bar_is_hidden, menu_will_open_state): Define only if | ||
| 144 | NS_IMPL_COCOA. | ||
| 145 | (x_set_cursor_type): Remove declaration. | ||
| 146 | (ns_update_begin): Only use r and bp if NS_IMPL_COCOA. | ||
| 147 | (ns_update_end, ns_focus, ns_unfocus): Remove GNUStep specific code. | ||
| 148 | (x_set_window_size): Remove 3 pixels from toolbar if NS_IMPL_GNUSTEP. | ||
| 149 | (ns_get_color): Use F suffix on float. | ||
| 150 | (ns_color_to_lisp, ns_query_color): Use EmacsCGFloat. | ||
| 151 | (ns_get_rgb_color): Remove. | ||
| 152 | (x_set_frame_alpha): Move view inside NS_IMPL_COCOA. | ||
| 153 | (note_mouse_movement): x and y are CGFloat. | ||
| 154 | (ns_draw_fringe_bitmap): Remove unused rowY. | ||
| 155 | Change #if to COCOA && >= 10_6. | ||
| 156 | (ns_draw_window_cursor): Remove unused overspill. | ||
| 157 | (ns_draw_underwave): width and x are EamcsCGFloat. | ||
| 158 | (ns_draw_box): thickness is CGFloat. | ||
| 159 | (ns_dumpglyphs_image): Change #if to COCOA && >= 10_6. | ||
| 160 | (ns_send_appdefined): When NS_IMPL_GNUSTEP, redirect to main thread | ||
| 161 | if not in main thread. | ||
| 162 | (ns_get_pending_menu_title, ns_check_menu_open) | ||
| 163 | (ns_check_pending_open_menu): Put inside #if COCOA && >= 10_5. | ||
| 164 | (ns_term_init): Call catch_child_signal if NS_IMPL_GNUSTEP && SIGCHLD. | ||
| 165 | (sendFromMainThread:): New method. | ||
| 166 | (changeFont:): size is CGFloat. | ||
| 167 | (keyDown:): Check for Delete when NS_IMPL_GNUSTEP. | ||
| 168 | Disable warning about permanent text. | ||
| 169 | (characterIndexForPoint:): Adjust return type depending on GNUStep | ||
| 170 | version. | ||
| 171 | (mouseDown:): delta is CGFloat. | ||
| 172 | (updateFrameSize): Remove unised variable f. | ||
| 173 | (initFrameFromEmacs): Move toggleButton inside NS_IMPL_COCOA. | ||
| 174 | Cast float to EmacsCGFloat. | ||
| 175 | (windowWillUseStandardFrame:defaultFrame:): Set maximized_height | ||
| 176 | also to -1 when restoring. | ||
| 177 | (windowDidExitFullScreen:): Put call to updateCollectionBehaviour | ||
| 178 | inside NS_IMPL_COCOA. | ||
| 179 | (toggleFullScreen:): Put call to toggleFullScreen inside | ||
| 180 | NS_IMPL_COCOA. Cast float to EmacsCGFloat. | ||
| 181 | (setPosition:portion:whole:): por is CGFloat. | ||
| 182 | (getMouseMotionPart:window:x:y:): Add F suffix to float. | ||
| 183 | (mouseDown:): Use CGFloat. | ||
| 184 | (mouseDragged:): Remove unised variable edge. | ||
| 185 | (EmacsDocument): Implement for NS_IMPL_GNUSTEP. | ||
| 186 | |||
| 187 | * nsterm.h (EmacsCGFloat): Typedef for OSX and GNUStep when the size | ||
| 188 | of CGFloat differs. | ||
| 189 | (EmacsApp): New variable nextappdefined. Declare sendFromMainThread | ||
| 190 | when NS_IMPL_GNUSTEP. | ||
| 191 | (EmacsDocument): Declare when NS_IMPL_GNUSTEP. | ||
| 192 | (EmacsView): Remove unlockFocusNeedsFlush, add windowDidMove. | ||
| 193 | (EmacsToolbar): Add clearAll. Add tag argument to | ||
| 194 | addDisplayItemWithImage. | ||
| 195 | (EmacsSavePanel, EmacsOpenPanel): Remove getFilename and getDirectory. | ||
| 196 | |||
| 197 | * nsselect.m (ns_get_local_selection): Remove unused variable type. | ||
| 198 | |||
| 199 | * nsmenu.m (ns_update_menubar): Make static. | ||
| 200 | (x_activate_menubar): Surround with ifdef NS_IMPL_COCOA | ||
| 201 | (fillWithWidgetValue:): Add cast to SEL for setAction. | ||
| 202 | (addSubmenuWithTitle:forFrame:): Add cast to SEL for action. | ||
| 203 | (update_frame_tool_bar): Update code for GNUStep. | ||
| 204 | (clearAll): New method. | ||
| 205 | (addDisplayItemWithImage:idx:tag:helpText:enabled:): Handle new tag | ||
| 206 | argument. Call insertItemWithItemIdentifier when NS_IMPL_GNUSTEP. Move | ||
| 207 | identifierToItem setObject and activeIdentifiers addObject before | ||
| 208 | call to insertItemWithItemIdentifier. | ||
| 209 | (validateVisibleItems): Fix indentation. | ||
| 210 | (toolbarAllowedItemIdentifiers:): Return activeIdentifiers. | ||
| 211 | (initWithContentRect:styleMask:backing:defer:): Add ClosableWindow and | ||
| 212 | UtilityWindow to aStyle, remove call to setStyleMask. | ||
| 213 | |||
| 214 | * nsimage.m (setXBMColor:, getPixelAtX:Y:): Use EmacsCGFloat. | ||
| 215 | |||
| 216 | * nsfont.m (ns_attribute_fvalue, ns_spec_to_descriptor) | ||
| 217 | (ns_charset_covers, ns_get_covering_families, nsfont_open): | ||
| 218 | Use F suffix on floats. | ||
| 219 | (ns_char_width): Returns CGFloat. | ||
| 220 | (ns_ascii_average_width): w is CGFloat instead of float. | ||
| 221 | (nsfont_draw): cbuf and c are unsigned. Cast to char* in call to | ||
| 222 | DPSxshow. | ||
| 223 | (ns_glyph_metrics): CGFloat instead of float. | ||
| 224 | |||
| 225 | * nsfns.m (x_set_foreground_color, x_set_background_color): Use | ||
| 226 | EmacsCGFloat. | ||
| 227 | (ns_implicitly_set_icon_type, Fx_create_frame): Make static, remove | ||
| 228 | unused variables. | ||
| 229 | (Fns_read_file_name): Keep track if panel is for save. Use | ||
| 230 | ns_filename_from_panel/ns_directory_from_panel. | ||
| 231 | (Fns_list_services): delegate only used for COCOA. | ||
| 232 | (Fns_convert_utf8_nfd_to_nfc): Remove warning for GNUStep. Just | ||
| 233 | return the input if GNUStep. | ||
| 234 | (x_screen_planes): Remove. | ||
| 235 | (Fxw_color_values): Use EmacsCGFloat | ||
| 236 | (Fns_display_monitor_attributes_list): Only get screen number for | ||
| 237 | Cocoa. | ||
| 238 | (getDirectory, getFilename): Removed from EmacsOpenPanel and | ||
| 239 | EmacsSavePanel. | ||
| 240 | (EmacsOpenPanel:ok:): Use ns_filename_from_panel and | ||
| 241 | ns_directory_from_panel. | ||
| 242 | |||
| 1 | 2013-06-01 Paul Eggert <eggert@cs.ucla.edu> | 243 | 2013-06-01 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 244 | ||
| 3 | * process.c (handle_child_signal): Also use WCONTINUED. | 245 | * process.c (handle_child_signal): Also use WCONTINUED. |
diff --git a/src/Makefile.in b/src/Makefile.in index 2fa7fb37348..9d7857e4ca2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -156,6 +156,13 @@ SETTINGS_LIBS = @SETTINGS_LIBS@ | |||
| 156 | ## gtkutil.o if USE_GTK, else empty. | 156 | ## gtkutil.o if USE_GTK, else empty. |
| 157 | GTK_OBJ=@GTK_OBJ@ | 157 | GTK_OBJ=@GTK_OBJ@ |
| 158 | 158 | ||
| 159 | ## gfilenotify.o if HAVE_GFILENOTIFY. | ||
| 160 | ## inotify.o if HAVE_INOTIFY. | ||
| 161 | ## w32notify.o if HAVE_W32NOTIFY. | ||
| 162 | NOTIFY_OBJ = @NOTIFY_OBJ@ | ||
| 163 | GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@ | ||
| 164 | GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@ | ||
| 165 | |||
| 159 | ## -ltermcap, or -lncurses, or -lcurses, or "". | 166 | ## -ltermcap, or -lncurses, or -lcurses, or "". |
| 160 | LIBS_TERMCAP=@LIBS_TERMCAP@ | 167 | LIBS_TERMCAP=@LIBS_TERMCAP@ |
| 161 | ## terminfo.o if TERMINFO, else tparam.o. | 168 | ## terminfo.o if TERMINFO, else tparam.o. |
| @@ -200,10 +207,13 @@ LIBXMENU=@LIBXMENU@ | |||
| 200 | 207 | ||
| 201 | ## xmenu.o if HAVE_X_WINDOWS, else empty. | 208 | ## xmenu.o if HAVE_X_WINDOWS, else empty. |
| 202 | XMENU_OBJ=@XMENU_OBJ@ | 209 | XMENU_OBJ=@XMENU_OBJ@ |
| 203 | ## xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o xgselect.o if | 210 | ## xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o if |
| 204 | ## HAVE_X_WINDOWS, else empty. | 211 | ## HAVE_X_WINDOWS, else empty. |
| 205 | XOBJ=@XOBJ@ | 212 | XOBJ=@XOBJ@ |
| 206 | 213 | ||
| 214 | # xgselect.o if linking with GLib, else empty | ||
| 215 | XGSELOBJ=@XGSELOBJ@ | ||
| 216 | |||
| 207 | TOOLKIT_LIBW=@TOOLKIT_LIBW@ | 217 | TOOLKIT_LIBW=@TOOLKIT_LIBW@ |
| 208 | 218 | ||
| 209 | ## Only used if HAVE_X11, in LIBX_OTHER. | 219 | ## Only used if HAVE_X11, in LIBX_OTHER. |
| @@ -337,7 +347,7 @@ ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \ | |||
| 337 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) \ | 347 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) \ |
| 338 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ | 348 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ |
| 339 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \ | 349 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \ |
| 340 | $(LIBGNUTLS_CFLAGS) \ | 350 | $(LIBGNUTLS_CFLAGS) $(GFILENOTIFY_CFLAGS) \ |
| 341 | $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS) | 351 | $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS) |
| 342 | ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) | 352 | ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) |
| 343 | 353 | ||
| @@ -363,10 +373,10 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ | |||
| 363 | syntax.o $(UNEXEC_OBJ) bytecode.o \ | 373 | syntax.o $(UNEXEC_OBJ) bytecode.o \ |
| 364 | process.o gnutls.o callproc.o \ | 374 | process.o gnutls.o callproc.o \ |
| 365 | region-cache.o sound.o atimer.o \ | 375 | region-cache.o sound.o atimer.o \ |
| 366 | doprnt.o intervals.o textprop.o composite.o xml.o inotify.o \ | 376 | doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \ |
| 367 | profiler.o \ | 377 | profiler.o \ |
| 368 | $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ | 378 | $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ |
| 369 | $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) | 379 | $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) |
| 370 | obj = $(base_obj) $(NS_OBJC_OBJ) | 380 | obj = $(base_obj) $(NS_OBJC_OBJ) |
| 371 | 381 | ||
| 372 | ## Object files used on some machine or other. | 382 | ## Object files used on some machine or other. |
| @@ -419,7 +429,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ | |||
| 419 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 429 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 420 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 430 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
| 421 | $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \ | 431 | $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \ |
| 422 | $(LIB_MATH) | 432 | $(GFILENOTIFY_LIBS) $(LIB_MATH) |
| 423 | 433 | ||
| 424 | all: emacs$(EXEEXT) $(OTHER_FILES) | 434 | all: emacs$(EXEEXT) $(OTHER_FILES) |
| 425 | .PHONY: all | 435 | .PHONY: all |
diff --git a/src/alloc.c b/src/alloc.c index 7a56c78e2ba..cce0fff4fd4 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5165,7 +5165,6 @@ returns nil, because real GC can't be done. | |||
| 5165 | See Info node `(elisp)Garbage Collection'. */) | 5165 | See Info node `(elisp)Garbage Collection'. */) |
| 5166 | (void) | 5166 | (void) |
| 5167 | { | 5167 | { |
| 5168 | struct specbinding *bind; | ||
| 5169 | struct buffer *nextb; | 5168 | struct buffer *nextb; |
| 5170 | char stack_top_variable; | 5169 | char stack_top_variable; |
| 5171 | ptrdiff_t i; | 5170 | ptrdiff_t i; |
| @@ -5174,7 +5173,6 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5174 | EMACS_TIME start; | 5173 | EMACS_TIME start; |
| 5175 | Lisp_Object retval = Qnil; | 5174 | Lisp_Object retval = Qnil; |
| 5176 | size_t tot_before = 0; | 5175 | size_t tot_before = 0; |
| 5177 | struct backtrace backtrace; | ||
| 5178 | 5176 | ||
| 5179 | if (abort_on_gc) | 5177 | if (abort_on_gc) |
| 5180 | emacs_abort (); | 5178 | emacs_abort (); |
| @@ -5185,12 +5183,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5185 | return Qnil; | 5183 | return Qnil; |
| 5186 | 5184 | ||
| 5187 | /* Record this function, so it appears on the profiler's backtraces. */ | 5185 | /* Record this function, so it appears on the profiler's backtraces. */ |
| 5188 | backtrace.next = backtrace_list; | 5186 | record_in_backtrace (Qautomatic_gc, &Qnil, 0); |
| 5189 | backtrace.function = Qautomatic_gc; | ||
| 5190 | backtrace.args = &Qnil; | ||
| 5191 | backtrace.nargs = 0; | ||
| 5192 | backtrace.debug_on_exit = 0; | ||
| 5193 | backtrace_list = &backtrace; | ||
| 5194 | 5187 | ||
| 5195 | check_cons_list (); | 5188 | check_cons_list (); |
| 5196 | 5189 | ||
| @@ -5257,11 +5250,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5257 | for (i = 0; i < staticidx; i++) | 5250 | for (i = 0; i < staticidx; i++) |
| 5258 | mark_object (*staticvec[i]); | 5251 | mark_object (*staticvec[i]); |
| 5259 | 5252 | ||
| 5260 | for (bind = specpdl; bind != specpdl_ptr; bind++) | 5253 | mark_specpdl (); |
| 5261 | { | ||
| 5262 | mark_object (bind->symbol); | ||
| 5263 | mark_object (bind->old_value); | ||
| 5264 | } | ||
| 5265 | mark_terminals (); | 5254 | mark_terminals (); |
| 5266 | mark_kboards (); | 5255 | mark_kboards (); |
| 5267 | 5256 | ||
| @@ -5295,7 +5284,6 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5295 | mark_object (handler->var); | 5284 | mark_object (handler->var); |
| 5296 | } | 5285 | } |
| 5297 | } | 5286 | } |
| 5298 | mark_backtrace (); | ||
| 5299 | #endif | 5287 | #endif |
| 5300 | 5288 | ||
| 5301 | #ifdef HAVE_WINDOW_SYSTEM | 5289 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -5486,7 +5474,6 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5486 | malloc_probe (swept); | 5474 | malloc_probe (swept); |
| 5487 | } | 5475 | } |
| 5488 | 5476 | ||
| 5489 | backtrace_list = backtrace.next; | ||
| 5490 | return retval; | 5477 | return retval; |
| 5491 | } | 5478 | } |
| 5492 | 5479 | ||
diff --git a/src/data.c b/src/data.c index 6622088b648..9f756de014a 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -100,9 +100,9 @@ wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) | |||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | void | 102 | void |
| 103 | pure_write_error (void) | 103 | pure_write_error (Lisp_Object obj) |
| 104 | { | 104 | { |
| 105 | error ("Attempt to modify read-only object"); | 105 | xsignal2 (Qerror, build_string ("Attempt to modify read-only object"), obj); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | void | 108 | void |
| @@ -1069,40 +1069,6 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 1069 | return newval; | 1069 | return newval; |
| 1070 | } | 1070 | } |
| 1071 | 1071 | ||
| 1072 | /* Return true if SYMBOL currently has a let-binding | ||
| 1073 | which was made in the buffer that is now current. */ | ||
| 1074 | |||
| 1075 | static bool | ||
| 1076 | let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) | ||
| 1077 | { | ||
| 1078 | struct specbinding *p; | ||
| 1079 | |||
| 1080 | for (p = specpdl_ptr; p > specpdl; ) | ||
| 1081 | if ((--p)->func == NULL | ||
| 1082 | && CONSP (p->symbol)) | ||
| 1083 | { | ||
| 1084 | struct Lisp_Symbol *let_bound_symbol = XSYMBOL (XCAR (p->symbol)); | ||
| 1085 | eassert (let_bound_symbol->redirect != SYMBOL_VARALIAS); | ||
| 1086 | if (symbol == let_bound_symbol | ||
| 1087 | && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer) | ||
| 1088 | return 1; | ||
| 1089 | } | ||
| 1090 | |||
| 1091 | return 0; | ||
| 1092 | } | ||
| 1093 | |||
| 1094 | static bool | ||
| 1095 | let_shadows_global_binding_p (Lisp_Object symbol) | ||
| 1096 | { | ||
| 1097 | struct specbinding *p; | ||
| 1098 | |||
| 1099 | for (p = specpdl_ptr; p > specpdl; ) | ||
| 1100 | if ((--p)->func == NULL && EQ (p->symbol, symbol)) | ||
| 1101 | return 1; | ||
| 1102 | |||
| 1103 | return 0; | ||
| 1104 | } | ||
| 1105 | |||
| 1106 | /* Store the value NEWVAL into SYMBOL. | 1072 | /* Store the value NEWVAL into SYMBOL. |
| 1107 | If buffer/frame-locality is an issue, WHERE specifies which context to use. | 1073 | If buffer/frame-locality is an issue, WHERE specifies which context to use. |
| 1108 | (nil stands for the current buffer/frame). | 1074 | (nil stands for the current buffer/frame). |
| @@ -1841,17 +1807,18 @@ BUFFER defaults to the current buffer. */) | |||
| 1841 | XSETBUFFER (tmp, buf); | 1807 | XSETBUFFER (tmp, buf); |
| 1842 | XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ | 1808 | XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ |
| 1843 | 1809 | ||
| 1844 | for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail)) | 1810 | if (EQ (blv->where, tmp)) /* The binding is already loaded. */ |
| 1845 | { | 1811 | return blv_found (blv) ? Qt : Qnil; |
| 1846 | elt = XCAR (tail); | 1812 | else |
| 1847 | if (EQ (variable, XCAR (elt))) | 1813 | for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail)) |
| 1848 | { | 1814 | { |
| 1849 | eassert (!blv->frame_local); | 1815 | elt = XCAR (tail); |
| 1850 | eassert (blv_found (blv) || !EQ (blv->where, tmp)); | 1816 | if (EQ (variable, XCAR (elt))) |
| 1851 | return Qt; | 1817 | { |
| 1852 | } | 1818 | eassert (!blv->frame_local); |
| 1853 | } | 1819 | return Qt; |
| 1854 | eassert (!blv_found (blv) || !EQ (blv->where, tmp)); | 1820 | } |
| 1821 | } | ||
| 1855 | return Qnil; | 1822 | return Qnil; |
| 1856 | } | 1823 | } |
| 1857 | case SYMBOL_FORWARDED: | 1824 | case SYMBOL_FORWARDED: |
diff --git a/src/emacs.c b/src/emacs.c index 5115126577b..4e439a601b1 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1252,7 +1252,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1252 | 1252 | ||
| 1253 | #ifdef WINDOWSNT | 1253 | #ifdef WINDOWSNT |
| 1254 | globals_of_w32 (); | 1254 | globals_of_w32 (); |
| 1255 | #ifdef HAVE_W32NOTIFY | ||
| 1255 | globals_of_w32notify (); | 1256 | globals_of_w32notify (); |
| 1257 | #endif | ||
| 1256 | /* Initialize environment from registry settings. */ | 1258 | /* Initialize environment from registry settings. */ |
| 1257 | init_environment (argv); | 1259 | init_environment (argv); |
| 1258 | init_ntproc (dumping); /* must precede init_editfns. */ | 1260 | init_ntproc (dumping); /* must precede init_editfns. */ |
| @@ -1409,6 +1411,10 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1409 | syms_of_gnutls (); | 1411 | syms_of_gnutls (); |
| 1410 | #endif | 1412 | #endif |
| 1411 | 1413 | ||
| 1414 | #ifdef HAVE_GFILENOTIFY | ||
| 1415 | syms_of_gfilenotify (); | ||
| 1416 | #endif /* HAVE_GFILENOTIFY */ | ||
| 1417 | |||
| 1412 | #ifdef HAVE_INOTIFY | 1418 | #ifdef HAVE_INOTIFY |
| 1413 | syms_of_inotify (); | 1419 | syms_of_inotify (); |
| 1414 | #endif /* HAVE_INOTIFY */ | 1420 | #endif /* HAVE_INOTIFY */ |
| @@ -1419,7 +1425,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1419 | 1425 | ||
| 1420 | #ifdef WINDOWSNT | 1426 | #ifdef WINDOWSNT |
| 1421 | syms_of_ntterm (); | 1427 | syms_of_ntterm (); |
| 1428 | #ifdef HAVE_W32NOTIFY | ||
| 1422 | syms_of_w32notify (); | 1429 | syms_of_w32notify (); |
| 1430 | #endif /* HAVE_W32NOTIFY */ | ||
| 1423 | #endif /* WINDOWSNT */ | 1431 | #endif /* WINDOWSNT */ |
| 1424 | 1432 | ||
| 1425 | syms_of_profiler (); | 1433 | syms_of_profiler (); |
diff --git a/src/eval.c b/src/eval.c index 69483a9b205..d1d074df777 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -32,8 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 32 | #include "xterm.h" | 32 | #include "xterm.h" |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | struct backtrace *backtrace_list; | ||
| 36 | |||
| 37 | #if !BYTE_MARK_STACK | 35 | #if !BYTE_MARK_STACK |
| 38 | static | 36 | static |
| 39 | #endif | 37 | #endif |
| @@ -105,7 +103,7 @@ static EMACS_INT when_entered_debugger; | |||
| 105 | 103 | ||
| 106 | /* The function from which the last `signal' was called. Set in | 104 | /* The function from which the last `signal' was called. Set in |
| 107 | Fsignal. */ | 105 | Fsignal. */ |
| 108 | 106 | /* FIXME: We should probably get rid of this! */ | |
| 109 | Lisp_Object Vsignaling_function; | 107 | Lisp_Object Vsignaling_function; |
| 110 | 108 | ||
| 111 | /* If non-nil, Lisp code must not be run since some part of Emacs is | 109 | /* If non-nil, Lisp code must not be run since some part of Emacs is |
| @@ -117,20 +115,48 @@ Lisp_Object inhibit_lisp_code; | |||
| 117 | static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); | 115 | static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); |
| 118 | static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); | 116 | static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); |
| 119 | 117 | ||
| 120 | /* Functions to set Lisp_Object slots of struct specbinding. */ | 118 | /* Functions to modify slots of backtrace records. */ |
| 119 | |||
| 120 | static void | ||
| 121 | set_backtrace_args (struct specbinding *pdl, Lisp_Object *args) | ||
| 122 | { eassert (pdl->kind == SPECPDL_BACKTRACE); pdl->v.bt.args = args; } | ||
| 123 | |||
| 124 | static void | ||
| 125 | set_backtrace_nargs (struct specbinding *pdl, ptrdiff_t n) | ||
| 126 | { eassert (pdl->kind == SPECPDL_BACKTRACE); pdl->v.bt.nargs = n; } | ||
| 121 | 127 | ||
| 122 | static void | 128 | static void |
| 123 | set_specpdl_symbol (Lisp_Object symbol) | 129 | set_backtrace_debug_on_exit (struct specbinding *pdl, bool doe) |
| 130 | { eassert (pdl->kind == SPECPDL_BACKTRACE); pdl->v.bt.debug_on_exit = doe; } | ||
| 131 | |||
| 132 | /* Helper functions to scan the backtrace. */ | ||
| 133 | |||
| 134 | bool backtrace_p (struct specbinding *) EXTERNALLY_VISIBLE; | ||
| 135 | struct specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; | ||
| 136 | struct specbinding *backtrace_next (struct specbinding *pdl) EXTERNALLY_VISIBLE; | ||
| 137 | |||
| 138 | bool backtrace_p (struct specbinding *pdl) | ||
| 139 | { return pdl >= specpdl; } | ||
| 140 | |||
| 141 | struct specbinding * | ||
| 142 | backtrace_top (void) | ||
| 124 | { | 143 | { |
| 125 | specpdl_ptr->symbol = symbol; | 144 | struct specbinding *pdl = specpdl_ptr - 1; |
| 145 | while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE) | ||
| 146 | pdl--; | ||
| 147 | return pdl; | ||
| 126 | } | 148 | } |
| 127 | 149 | ||
| 128 | static void | 150 | struct specbinding * |
| 129 | set_specpdl_old_value (Lisp_Object oldval) | 151 | backtrace_next (struct specbinding *pdl) |
| 130 | { | 152 | { |
| 131 | specpdl_ptr->old_value = oldval; | 153 | pdl--; |
| 154 | while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE) | ||
| 155 | pdl--; | ||
| 156 | return pdl; | ||
| 132 | } | 157 | } |
| 133 | 158 | ||
| 159 | |||
| 134 | void | 160 | void |
| 135 | init_eval_once (void) | 161 | init_eval_once (void) |
| 136 | { | 162 | { |
| @@ -151,7 +177,6 @@ init_eval (void) | |||
| 151 | specpdl_ptr = specpdl; | 177 | specpdl_ptr = specpdl; |
| 152 | catchlist = 0; | 178 | catchlist = 0; |
| 153 | handlerlist = 0; | 179 | handlerlist = 0; |
| 154 | backtrace_list = 0; | ||
| 155 | Vquit_flag = Qnil; | 180 | Vquit_flag = Qnil; |
| 156 | debug_on_next_call = 0; | 181 | debug_on_next_call = 0; |
| 157 | lisp_eval_depth = 0; | 182 | lisp_eval_depth = 0; |
| @@ -234,7 +259,7 @@ static void | |||
| 234 | do_debug_on_call (Lisp_Object code) | 259 | do_debug_on_call (Lisp_Object code) |
| 235 | { | 260 | { |
| 236 | debug_on_next_call = 0; | 261 | debug_on_next_call = 0; |
| 237 | backtrace_list->debug_on_exit = 1; | 262 | set_backtrace_debug_on_exit (specpdl_ptr - 1, true); |
| 238 | call_debugger (Fcons (code, Qnil)); | 263 | call_debugger (Fcons (code, Qnil)); |
| 239 | } | 264 | } |
| 240 | 265 | ||
| @@ -530,9 +555,8 @@ The return value is BASE-VARIABLE. */) | |||
| 530 | struct specbinding *p; | 555 | struct specbinding *p; |
| 531 | 556 | ||
| 532 | for (p = specpdl_ptr; p > specpdl; ) | 557 | for (p = specpdl_ptr; p > specpdl; ) |
| 533 | if ((--p)->func == NULL | 558 | if ((--p)->kind >= SPECPDL_LET |
| 534 | && (EQ (new_alias, | 559 | && (EQ (new_alias, specpdl_symbol (p)))) |
| 535 | CONSP (p->symbol) ? XCAR (p->symbol) : p->symbol))) | ||
| 536 | error ("Don't know how to make a let-bound variable an alias"); | 560 | error ("Don't know how to make a let-bound variable an alias"); |
| 537 | } | 561 | } |
| 538 | 562 | ||
| @@ -597,8 +621,9 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) | |||
| 597 | struct specbinding *pdl = specpdl_ptr; | 621 | struct specbinding *pdl = specpdl_ptr; |
| 598 | while (pdl > specpdl) | 622 | while (pdl > specpdl) |
| 599 | { | 623 | { |
| 600 | if (EQ ((--pdl)->symbol, sym) && !pdl->func | 624 | if ((--pdl)->kind >= SPECPDL_LET |
| 601 | && EQ (pdl->old_value, Qunbound)) | 625 | && EQ (specpdl_symbol (pdl), sym) |
| 626 | && EQ (specpdl_old_value (pdl), Qunbound)) | ||
| 602 | { | 627 | { |
| 603 | message_with_string | 628 | message_with_string |
| 604 | ("Warning: defvar ignored because %s is let-bound", | 629 | ("Warning: defvar ignored because %s is let-bound", |
| @@ -937,7 +962,7 @@ usage: (catch TAG BODY...) */) | |||
| 937 | 962 | ||
| 938 | /* Set up a catch, then call C function FUNC on argument ARG. | 963 | /* Set up a catch, then call C function FUNC on argument ARG. |
| 939 | FUNC should return a Lisp_Object. | 964 | FUNC should return a Lisp_Object. |
| 940 | This is how catches are done from within C code. */ | 965 | This is how catches are done from within C code. */ |
| 941 | 966 | ||
| 942 | Lisp_Object | 967 | Lisp_Object |
| 943 | internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object arg) | 968 | internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object arg) |
| @@ -949,7 +974,6 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object | |||
| 949 | c.next = catchlist; | 974 | c.next = catchlist; |
| 950 | c.tag = tag; | 975 | c.tag = tag; |
| 951 | c.val = Qnil; | 976 | c.val = Qnil; |
| 952 | c.backlist = backtrace_list; | ||
| 953 | c.handlerlist = handlerlist; | 977 | c.handlerlist = handlerlist; |
| 954 | c.lisp_eval_depth = lisp_eval_depth; | 978 | c.lisp_eval_depth = lisp_eval_depth; |
| 955 | c.pdlcount = SPECPDL_INDEX (); | 979 | c.pdlcount = SPECPDL_INDEX (); |
| @@ -1014,7 +1038,6 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) | |||
| 1014 | #ifdef DEBUG_GCPRO | 1038 | #ifdef DEBUG_GCPRO |
| 1015 | gcpro_level = gcprolist ? gcprolist->level + 1 : 0; | 1039 | gcpro_level = gcprolist ? gcprolist->level + 1 : 0; |
| 1016 | #endif | 1040 | #endif |
| 1017 | backtrace_list = catch->backlist; | ||
| 1018 | lisp_eval_depth = catch->lisp_eval_depth; | 1041 | lisp_eval_depth = catch->lisp_eval_depth; |
| 1019 | 1042 | ||
| 1020 | sys_longjmp (catch->jmp, 1); | 1043 | sys_longjmp (catch->jmp, 1); |
| @@ -1115,7 +1138,6 @@ internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform, | |||
| 1115 | 1138 | ||
| 1116 | c.tag = Qnil; | 1139 | c.tag = Qnil; |
| 1117 | c.val = Qnil; | 1140 | c.val = Qnil; |
| 1118 | c.backlist = backtrace_list; | ||
| 1119 | c.handlerlist = handlerlist; | 1141 | c.handlerlist = handlerlist; |
| 1120 | c.lisp_eval_depth = lisp_eval_depth; | 1142 | c.lisp_eval_depth = lisp_eval_depth; |
| 1121 | c.pdlcount = SPECPDL_INDEX (); | 1143 | c.pdlcount = SPECPDL_INDEX (); |
| @@ -1131,7 +1153,7 @@ internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform, | |||
| 1131 | 1153 | ||
| 1132 | /* Note that this just undoes the binding of h.var; whoever | 1154 | /* Note that this just undoes the binding of h.var; whoever |
| 1133 | longjumped to us unwound the stack to c.pdlcount before | 1155 | longjumped to us unwound the stack to c.pdlcount before |
| 1134 | throwing. */ | 1156 | throwing. */ |
| 1135 | unbind_to (c.pdlcount, Qnil); | 1157 | unbind_to (c.pdlcount, Qnil); |
| 1136 | return val; | 1158 | return val; |
| 1137 | } | 1159 | } |
| @@ -1170,7 +1192,6 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers, | |||
| 1170 | 1192 | ||
| 1171 | c.tag = Qnil; | 1193 | c.tag = Qnil; |
| 1172 | c.val = Qnil; | 1194 | c.val = Qnil; |
| 1173 | c.backlist = backtrace_list; | ||
| 1174 | c.handlerlist = handlerlist; | 1195 | c.handlerlist = handlerlist; |
| 1175 | c.lisp_eval_depth = lisp_eval_depth; | 1196 | c.lisp_eval_depth = lisp_eval_depth; |
| 1176 | c.pdlcount = SPECPDL_INDEX (); | 1197 | c.pdlcount = SPECPDL_INDEX (); |
| @@ -1208,7 +1229,6 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg, | |||
| 1208 | 1229 | ||
| 1209 | c.tag = Qnil; | 1230 | c.tag = Qnil; |
| 1210 | c.val = Qnil; | 1231 | c.val = Qnil; |
| 1211 | c.backlist = backtrace_list; | ||
| 1212 | c.handlerlist = handlerlist; | 1232 | c.handlerlist = handlerlist; |
| 1213 | c.lisp_eval_depth = lisp_eval_depth; | 1233 | c.lisp_eval_depth = lisp_eval_depth; |
| 1214 | c.pdlcount = SPECPDL_INDEX (); | 1234 | c.pdlcount = SPECPDL_INDEX (); |
| @@ -1250,7 +1270,6 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object), | |||
| 1250 | 1270 | ||
| 1251 | c.tag = Qnil; | 1271 | c.tag = Qnil; |
| 1252 | c.val = Qnil; | 1272 | c.val = Qnil; |
| 1253 | c.backlist = backtrace_list; | ||
| 1254 | c.handlerlist = handlerlist; | 1273 | c.handlerlist = handlerlist; |
| 1255 | c.lisp_eval_depth = lisp_eval_depth; | 1274 | c.lisp_eval_depth = lisp_eval_depth; |
| 1256 | c.pdlcount = SPECPDL_INDEX (); | 1275 | c.pdlcount = SPECPDL_INDEX (); |
| @@ -1294,7 +1313,6 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), | |||
| 1294 | 1313 | ||
| 1295 | c.tag = Qnil; | 1314 | c.tag = Qnil; |
| 1296 | c.val = Qnil; | 1315 | c.val = Qnil; |
| 1297 | c.backlist = backtrace_list; | ||
| 1298 | c.handlerlist = handlerlist; | 1316 | c.handlerlist = handlerlist; |
| 1299 | c.lisp_eval_depth = lisp_eval_depth; | 1317 | c.lisp_eval_depth = lisp_eval_depth; |
| 1300 | c.pdlcount = SPECPDL_INDEX (); | 1318 | c.pdlcount = SPECPDL_INDEX (); |
| @@ -1362,7 +1380,6 @@ See also the function `condition-case'. */) | |||
| 1362 | = (NILP (error_symbol) ? Fcar (data) : error_symbol); | 1380 | = (NILP (error_symbol) ? Fcar (data) : error_symbol); |
| 1363 | register Lisp_Object clause = Qnil; | 1381 | register Lisp_Object clause = Qnil; |
| 1364 | struct handler *h; | 1382 | struct handler *h; |
| 1365 | struct backtrace *bp; | ||
| 1366 | 1383 | ||
| 1367 | immediate_quit = 0; | 1384 | immediate_quit = 0; |
| 1368 | abort_on_gc = 0; | 1385 | abort_on_gc = 0; |
| @@ -1398,13 +1415,13 @@ See also the function `condition-case'. */) | |||
| 1398 | too. Don't do this when ERROR_SYMBOL is nil, because that | 1415 | too. Don't do this when ERROR_SYMBOL is nil, because that |
| 1399 | is a memory-full error. */ | 1416 | is a memory-full error. */ |
| 1400 | Vsignaling_function = Qnil; | 1417 | Vsignaling_function = Qnil; |
| 1401 | if (backtrace_list && !NILP (error_symbol)) | 1418 | if (!NILP (error_symbol)) |
| 1402 | { | 1419 | { |
| 1403 | bp = backtrace_list->next; | 1420 | struct specbinding *pdl = backtrace_next (backtrace_top ()); |
| 1404 | if (bp && EQ (bp->function, Qerror)) | 1421 | if (backtrace_p (pdl) && EQ (backtrace_function (pdl), Qerror)) |
| 1405 | bp = bp->next; | 1422 | pdl = backtrace_next (pdl); |
| 1406 | if (bp) | 1423 | if (backtrace_p (pdl)) |
| 1407 | Vsignaling_function = bp->function; | 1424 | Vsignaling_function = backtrace_function (pdl); |
| 1408 | } | 1425 | } |
| 1409 | 1426 | ||
| 1410 | for (h = handlerlist; h; h = h->next) | 1427 | for (h = handlerlist; h; h = h->next) |
| @@ -1901,6 +1918,36 @@ If LEXICAL is t, evaluate using lexical scoping. */) | |||
| 1901 | return unbind_to (count, eval_sub (form)); | 1918 | return unbind_to (count, eval_sub (form)); |
| 1902 | } | 1919 | } |
| 1903 | 1920 | ||
| 1921 | static void | ||
| 1922 | grow_specpdl (void) | ||
| 1923 | { | ||
| 1924 | register ptrdiff_t count = SPECPDL_INDEX (); | ||
| 1925 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX); | ||
| 1926 | if (max_size <= specpdl_size) | ||
| 1927 | { | ||
| 1928 | if (max_specpdl_size < 400) | ||
| 1929 | max_size = max_specpdl_size = 400; | ||
| 1930 | if (max_size <= specpdl_size) | ||
| 1931 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); | ||
| 1932 | } | ||
| 1933 | specpdl = xpalloc (specpdl, &specpdl_size, 1, max_size, sizeof *specpdl); | ||
| 1934 | specpdl_ptr = specpdl + count; | ||
| 1935 | } | ||
| 1936 | |||
| 1937 | void | ||
| 1938 | record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) | ||
| 1939 | { | ||
| 1940 | eassert (nargs >= UNEVALLED); | ||
| 1941 | if (specpdl_ptr == specpdl + specpdl_size) | ||
| 1942 | grow_specpdl (); | ||
| 1943 | specpdl_ptr->kind = SPECPDL_BACKTRACE; | ||
| 1944 | specpdl_ptr->v.bt.function = function; | ||
| 1945 | specpdl_ptr->v.bt.args = args; | ||
| 1946 | specpdl_ptr->v.bt.nargs = nargs; | ||
| 1947 | specpdl_ptr->v.bt.debug_on_exit = false; | ||
| 1948 | specpdl_ptr++; | ||
| 1949 | } | ||
| 1950 | |||
| 1904 | /* Eval a sub-expression of the current expression (i.e. in the same | 1951 | /* Eval a sub-expression of the current expression (i.e. in the same |
| 1905 | lexical scope). */ | 1952 | lexical scope). */ |
| 1906 | Lisp_Object | 1953 | Lisp_Object |
| @@ -1908,7 +1955,6 @@ eval_sub (Lisp_Object form) | |||
| 1908 | { | 1955 | { |
| 1909 | Lisp_Object fun, val, original_fun, original_args; | 1956 | Lisp_Object fun, val, original_fun, original_args; |
| 1910 | Lisp_Object funcar; | 1957 | Lisp_Object funcar; |
| 1911 | struct backtrace backtrace; | ||
| 1912 | struct gcpro gcpro1, gcpro2, gcpro3; | 1958 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 1913 | 1959 | ||
| 1914 | if (SYMBOLP (form)) | 1960 | if (SYMBOLP (form)) |
| @@ -1946,12 +1992,8 @@ eval_sub (Lisp_Object form) | |||
| 1946 | original_fun = XCAR (form); | 1992 | original_fun = XCAR (form); |
| 1947 | original_args = XCDR (form); | 1993 | original_args = XCDR (form); |
| 1948 | 1994 | ||
| 1949 | backtrace.next = backtrace_list; | 1995 | /* This also protects them from gc. */ |
| 1950 | backtrace.function = original_fun; /* This also protects them from gc. */ | 1996 | record_in_backtrace (original_fun, &original_args, UNEVALLED); |
| 1951 | backtrace.args = &original_args; | ||
| 1952 | backtrace.nargs = UNEVALLED; | ||
| 1953 | backtrace.debug_on_exit = 0; | ||
| 1954 | backtrace_list = &backtrace; | ||
| 1955 | 1997 | ||
| 1956 | if (debug_on_next_call) | 1998 | if (debug_on_next_call) |
| 1957 | do_debug_on_call (Qt); | 1999 | do_debug_on_call (Qt); |
| @@ -2005,8 +2047,8 @@ eval_sub (Lisp_Object form) | |||
| 2005 | gcpro3.nvars = argnum; | 2047 | gcpro3.nvars = argnum; |
| 2006 | } | 2048 | } |
| 2007 | 2049 | ||
| 2008 | backtrace.args = vals; | 2050 | set_backtrace_args (specpdl_ptr - 1, vals); |
| 2009 | backtrace.nargs = XINT (numargs); | 2051 | set_backtrace_nargs (specpdl_ptr - 1, XINT (numargs)); |
| 2010 | 2052 | ||
| 2011 | val = (XSUBR (fun)->function.aMANY) (XINT (numargs), vals); | 2053 | val = (XSUBR (fun)->function.aMANY) (XINT (numargs), vals); |
| 2012 | UNGCPRO; | 2054 | UNGCPRO; |
| @@ -2027,8 +2069,8 @@ eval_sub (Lisp_Object form) | |||
| 2027 | 2069 | ||
| 2028 | UNGCPRO; | 2070 | UNGCPRO; |
| 2029 | 2071 | ||
| 2030 | backtrace.args = argvals; | 2072 | set_backtrace_args (specpdl_ptr - 1, argvals); |
| 2031 | backtrace.nargs = XINT (numargs); | 2073 | set_backtrace_nargs (specpdl_ptr - 1, XINT (numargs)); |
| 2032 | 2074 | ||
| 2033 | switch (i) | 2075 | switch (i) |
| 2034 | { | 2076 | { |
| @@ -2118,9 +2160,9 @@ eval_sub (Lisp_Object form) | |||
| 2118 | check_cons_list (); | 2160 | check_cons_list (); |
| 2119 | 2161 | ||
| 2120 | lisp_eval_depth--; | 2162 | lisp_eval_depth--; |
| 2121 | if (backtrace.debug_on_exit) | 2163 | if (backtrace_debug_on_exit (specpdl_ptr - 1)) |
| 2122 | val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); | 2164 | val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); |
| 2123 | backtrace_list = backtrace.next; | 2165 | specpdl_ptr--; |
| 2124 | 2166 | ||
| 2125 | return val; | 2167 | return val; |
| 2126 | } | 2168 | } |
| @@ -2600,7 +2642,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2600 | ptrdiff_t numargs = nargs - 1; | 2642 | ptrdiff_t numargs = nargs - 1; |
| 2601 | Lisp_Object lisp_numargs; | 2643 | Lisp_Object lisp_numargs; |
| 2602 | Lisp_Object val; | 2644 | Lisp_Object val; |
| 2603 | struct backtrace backtrace; | ||
| 2604 | register Lisp_Object *internal_args; | 2645 | register Lisp_Object *internal_args; |
| 2605 | ptrdiff_t i; | 2646 | ptrdiff_t i; |
| 2606 | 2647 | ||
| @@ -2614,12 +2655,8 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2614 | error ("Lisp nesting exceeds `max-lisp-eval-depth'"); | 2655 | error ("Lisp nesting exceeds `max-lisp-eval-depth'"); |
| 2615 | } | 2656 | } |
| 2616 | 2657 | ||
| 2617 | backtrace.next = backtrace_list; | 2658 | /* This also GCPROs them. */ |
| 2618 | backtrace.function = args[0]; | 2659 | record_in_backtrace (args[0], &args[1], nargs - 1); |
| 2619 | backtrace.args = &args[1]; /* This also GCPROs them. */ | ||
| 2620 | backtrace.nargs = nargs - 1; | ||
| 2621 | backtrace.debug_on_exit = 0; | ||
| 2622 | backtrace_list = &backtrace; | ||
| 2623 | 2660 | ||
| 2624 | /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ | 2661 | /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ |
| 2625 | maybe_gc (); | 2662 | maybe_gc (); |
| @@ -2744,9 +2781,9 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2744 | } | 2781 | } |
| 2745 | check_cons_list (); | 2782 | check_cons_list (); |
| 2746 | lisp_eval_depth--; | 2783 | lisp_eval_depth--; |
| 2747 | if (backtrace.debug_on_exit) | 2784 | if (backtrace_debug_on_exit (specpdl_ptr - 1)) |
| 2748 | val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); | 2785 | val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); |
| 2749 | backtrace_list = backtrace.next; | 2786 | specpdl_ptr--; |
| 2750 | return val; | 2787 | return val; |
| 2751 | } | 2788 | } |
| 2752 | 2789 | ||
| @@ -2778,15 +2815,17 @@ apply_lambda (Lisp_Object fun, Lisp_Object args) | |||
| 2778 | 2815 | ||
| 2779 | UNGCPRO; | 2816 | UNGCPRO; |
| 2780 | 2817 | ||
| 2781 | backtrace_list->args = arg_vector; | 2818 | set_backtrace_args (specpdl_ptr - 1, arg_vector); |
| 2782 | backtrace_list->nargs = i; | 2819 | set_backtrace_nargs (specpdl_ptr - 1, i); |
| 2783 | tem = funcall_lambda (fun, numargs, arg_vector); | 2820 | tem = funcall_lambda (fun, numargs, arg_vector); |
| 2784 | 2821 | ||
| 2785 | /* Do the debug-on-exit now, while arg_vector still exists. */ | 2822 | /* Do the debug-on-exit now, while arg_vector still exists. */ |
| 2786 | if (backtrace_list->debug_on_exit) | 2823 | if (backtrace_debug_on_exit (specpdl_ptr - 1)) |
| 2787 | tem = call_debugger (Fcons (Qexit, Fcons (tem, Qnil))); | 2824 | { |
| 2788 | /* Don't do it again when we return to eval. */ | 2825 | /* Don't do it again when we return to eval. */ |
| 2789 | backtrace_list->debug_on_exit = 0; | 2826 | set_backtrace_debug_on_exit (specpdl_ptr - 1, false); |
| 2827 | tem = call_debugger (Fcons (Qexit, Fcons (tem, Qnil))); | ||
| 2828 | } | ||
| 2790 | SAFE_FREE (); | 2829 | SAFE_FREE (); |
| 2791 | return tem; | 2830 | return tem; |
| 2792 | } | 2831 | } |
| @@ -2936,20 +2975,38 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, | |||
| 2936 | return object; | 2975 | return object; |
| 2937 | } | 2976 | } |
| 2938 | 2977 | ||
| 2939 | static void | 2978 | /* Return true if SYMBOL currently has a let-binding |
| 2940 | grow_specpdl (void) | 2979 | which was made in the buffer that is now current. */ |
| 2980 | |||
| 2981 | bool | ||
| 2982 | let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) | ||
| 2941 | { | 2983 | { |
| 2942 | register ptrdiff_t count = SPECPDL_INDEX (); | 2984 | struct specbinding *p; |
| 2943 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX); | 2985 | Lisp_Object buf = Fcurrent_buffer (); |
| 2944 | if (max_size <= specpdl_size) | 2986 | |
| 2945 | { | 2987 | for (p = specpdl_ptr; p > specpdl; ) |
| 2946 | if (max_specpdl_size < 400) | 2988 | if ((--p)->kind > SPECPDL_LET) |
| 2947 | max_size = max_specpdl_size = 400; | 2989 | { |
| 2948 | if (max_size <= specpdl_size) | 2990 | struct Lisp_Symbol *let_bound_symbol = XSYMBOL (specpdl_symbol (p)); |
| 2949 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); | 2991 | eassert (let_bound_symbol->redirect != SYMBOL_VARALIAS); |
| 2950 | } | 2992 | if (symbol == let_bound_symbol |
| 2951 | specpdl = xpalloc (specpdl, &specpdl_size, 1, max_size, sizeof *specpdl); | 2993 | && EQ (specpdl_where (p), buf)) |
| 2952 | specpdl_ptr = specpdl + count; | 2994 | return 1; |
| 2995 | } | ||
| 2996 | |||
| 2997 | return 0; | ||
| 2998 | } | ||
| 2999 | |||
| 3000 | bool | ||
| 3001 | let_shadows_global_binding_p (Lisp_Object symbol) | ||
| 3002 | { | ||
| 3003 | struct specbinding *p; | ||
| 3004 | |||
| 3005 | for (p = specpdl_ptr; p > specpdl; ) | ||
| 3006 | if ((--p)->kind >= SPECPDL_LET && EQ (specpdl_symbol (p), symbol)) | ||
| 3007 | return 1; | ||
| 3008 | |||
| 3009 | return 0; | ||
| 2953 | } | 3010 | } |
| 2954 | 3011 | ||
| 2955 | /* `specpdl_ptr->symbol' is a field which describes which variable is | 3012 | /* `specpdl_ptr->symbol' is a field which describes which variable is |
| @@ -2985,9 +3042,9 @@ specbind (Lisp_Object symbol, Lisp_Object value) | |||
| 2985 | case SYMBOL_PLAINVAL: | 3042 | case SYMBOL_PLAINVAL: |
| 2986 | /* The most common case is that of a non-constant symbol with a | 3043 | /* The most common case is that of a non-constant symbol with a |
| 2987 | trivial value. Make that as fast as we can. */ | 3044 | trivial value. Make that as fast as we can. */ |
| 2988 | set_specpdl_symbol (symbol); | 3045 | specpdl_ptr->kind = SPECPDL_LET; |
| 2989 | set_specpdl_old_value (SYMBOL_VAL (sym)); | 3046 | specpdl_ptr->v.let.symbol = symbol; |
| 2990 | specpdl_ptr->func = NULL; | 3047 | specpdl_ptr->v.let.old_value = SYMBOL_VAL (sym); |
| 2991 | ++specpdl_ptr; | 3048 | ++specpdl_ptr; |
| 2992 | if (!sym->constant) | 3049 | if (!sym->constant) |
| 2993 | SET_SYMBOL_VAL (sym, value); | 3050 | SET_SYMBOL_VAL (sym, value); |
| @@ -3000,59 +3057,36 @@ specbind (Lisp_Object symbol, Lisp_Object value) | |||
| 3000 | case SYMBOL_FORWARDED: | 3057 | case SYMBOL_FORWARDED: |
| 3001 | { | 3058 | { |
| 3002 | Lisp_Object ovalue = find_symbol_value (symbol); | 3059 | Lisp_Object ovalue = find_symbol_value (symbol); |
| 3003 | specpdl_ptr->func = 0; | 3060 | specpdl_ptr->kind = SPECPDL_LET_LOCAL; |
| 3004 | set_specpdl_old_value (ovalue); | 3061 | specpdl_ptr->v.let.symbol = symbol; |
| 3062 | specpdl_ptr->v.let.old_value = ovalue; | ||
| 3063 | specpdl_ptr->v.let.where = Fcurrent_buffer (); | ||
| 3005 | 3064 | ||
| 3006 | eassert (sym->redirect != SYMBOL_LOCALIZED | 3065 | eassert (sym->redirect != SYMBOL_LOCALIZED |
| 3007 | || (EQ (SYMBOL_BLV (sym)->where, | 3066 | || (EQ (SYMBOL_BLV (sym)->where, Fcurrent_buffer ()))); |
| 3008 | SYMBOL_BLV (sym)->frame_local ? | ||
| 3009 | Fselected_frame () : Fcurrent_buffer ()))); | ||
| 3010 | 3067 | ||
| 3011 | if (sym->redirect == SYMBOL_LOCALIZED | 3068 | if (sym->redirect == SYMBOL_LOCALIZED) |
| 3012 | || BUFFER_OBJFWDP (SYMBOL_FWD (sym))) | 3069 | { |
| 3070 | if (!blv_found (SYMBOL_BLV (sym))) | ||
| 3071 | specpdl_ptr->kind = SPECPDL_LET_DEFAULT; | ||
| 3072 | } | ||
| 3073 | else if (BUFFER_OBJFWDP (SYMBOL_FWD (sym))) | ||
| 3013 | { | 3074 | { |
| 3014 | Lisp_Object where, cur_buf = Fcurrent_buffer (); | ||
| 3015 | |||
| 3016 | /* For a local variable, record both the symbol and which | ||
| 3017 | buffer's or frame's value we are saving. */ | ||
| 3018 | if (!NILP (Flocal_variable_p (symbol, Qnil))) | ||
| 3019 | { | ||
| 3020 | eassert (sym->redirect != SYMBOL_LOCALIZED | ||
| 3021 | || (blv_found (SYMBOL_BLV (sym)) | ||
| 3022 | && EQ (cur_buf, SYMBOL_BLV (sym)->where))); | ||
| 3023 | where = cur_buf; | ||
| 3024 | } | ||
| 3025 | else if (sym->redirect == SYMBOL_LOCALIZED | ||
| 3026 | && blv_found (SYMBOL_BLV (sym))) | ||
| 3027 | where = SYMBOL_BLV (sym)->where; | ||
| 3028 | else | ||
| 3029 | where = Qnil; | ||
| 3030 | |||
| 3031 | /* We're not using the `unused' slot in the specbinding | ||
| 3032 | structure because this would mean we have to do more | ||
| 3033 | work for simple variables. */ | ||
| 3034 | /* FIXME: The third value `current_buffer' is only used in | ||
| 3035 | let_shadows_buffer_binding_p which is itself only used | ||
| 3036 | in set_internal for local_if_set. */ | ||
| 3037 | eassert (NILP (where) || EQ (where, cur_buf)); | ||
| 3038 | set_specpdl_symbol (Fcons (symbol, Fcons (where, cur_buf))); | ||
| 3039 | |||
| 3040 | /* If SYMBOL is a per-buffer variable which doesn't have a | 3075 | /* If SYMBOL is a per-buffer variable which doesn't have a |
| 3041 | buffer-local value here, make the `let' change the global | 3076 | buffer-local value here, make the `let' change the global |
| 3042 | value by changing the value of SYMBOL in all buffers not | 3077 | value by changing the value of SYMBOL in all buffers not |
| 3043 | having their own value. This is consistent with what | 3078 | having their own value. This is consistent with what |
| 3044 | happens with other buffer-local variables. */ | 3079 | happens with other buffer-local variables. */ |
| 3045 | if (NILP (where) | 3080 | if (NILP (Flocal_variable_p (symbol, Qnil))) |
| 3046 | && sym->redirect == SYMBOL_FORWARDED) | ||
| 3047 | { | 3081 | { |
| 3048 | eassert (BUFFER_OBJFWDP (SYMBOL_FWD (sym))); | 3082 | specpdl_ptr->kind = SPECPDL_LET_DEFAULT; |
| 3049 | ++specpdl_ptr; | 3083 | ++specpdl_ptr; |
| 3050 | Fset_default (symbol, value); | 3084 | Fset_default (symbol, value); |
| 3051 | return; | 3085 | return; |
| 3052 | } | 3086 | } |
| 3053 | } | 3087 | } |
| 3054 | else | 3088 | else |
| 3055 | set_specpdl_symbol (symbol); | 3089 | specpdl_ptr->kind = SPECPDL_LET; |
| 3056 | 3090 | ||
| 3057 | specpdl_ptr++; | 3091 | specpdl_ptr++; |
| 3058 | set_internal (symbol, value, Qnil, 1); | 3092 | set_internal (symbol, value, Qnil, 1); |
| @@ -3067,9 +3101,9 @@ record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) | |||
| 3067 | { | 3101 | { |
| 3068 | if (specpdl_ptr == specpdl + specpdl_size) | 3102 | if (specpdl_ptr == specpdl + specpdl_size) |
| 3069 | grow_specpdl (); | 3103 | grow_specpdl (); |
| 3070 | specpdl_ptr->func = function; | 3104 | specpdl_ptr->kind = SPECPDL_UNWIND; |
| 3071 | set_specpdl_symbol (Qnil); | 3105 | specpdl_ptr->v.unwind.func = function; |
| 3072 | set_specpdl_old_value (arg); | 3106 | specpdl_ptr->v.unwind.arg = arg; |
| 3073 | specpdl_ptr++; | 3107 | specpdl_ptr++; |
| 3074 | } | 3108 | } |
| 3075 | 3109 | ||
| @@ -3093,41 +3127,50 @@ unbind_to (ptrdiff_t count, Lisp_Object value) | |||
| 3093 | struct specbinding this_binding; | 3127 | struct specbinding this_binding; |
| 3094 | this_binding = *--specpdl_ptr; | 3128 | this_binding = *--specpdl_ptr; |
| 3095 | 3129 | ||
| 3096 | if (this_binding.func != 0) | 3130 | switch (this_binding.kind) |
| 3097 | (*this_binding.func) (this_binding.old_value); | ||
| 3098 | /* If the symbol is a list, it is really (SYMBOL WHERE | ||
| 3099 | . CURRENT-BUFFER) where WHERE is either nil, a buffer, or a | ||
| 3100 | frame. If WHERE is a buffer or frame, this indicates we | ||
| 3101 | bound a variable that had a buffer-local or frame-local | ||
| 3102 | binding. WHERE nil means that the variable had the default | ||
| 3103 | value when it was bound. CURRENT-BUFFER is the buffer that | ||
| 3104 | was current when the variable was bound. */ | ||
| 3105 | else if (CONSP (this_binding.symbol)) | ||
| 3106 | { | 3131 | { |
| 3107 | Lisp_Object symbol, where; | 3132 | case SPECPDL_UNWIND: |
| 3108 | 3133 | (*specpdl_func (&this_binding)) (specpdl_arg (&this_binding)); | |
| 3109 | symbol = XCAR (this_binding.symbol); | 3134 | break; |
| 3110 | where = XCAR (XCDR (this_binding.symbol)); | 3135 | case SPECPDL_LET: |
| 3111 | 3136 | /* If variable has a trivial value (no forwarding), we can | |
| 3112 | if (NILP (where)) | 3137 | just set it. No need to check for constant symbols here, |
| 3113 | Fset_default (symbol, this_binding.old_value); | 3138 | since that was already done by specbind. */ |
| 3114 | /* If `where' is non-nil, reset the value in the appropriate | 3139 | if (XSYMBOL (specpdl_symbol (&this_binding))->redirect |
| 3115 | local binding, but only if that binding still exists. */ | 3140 | == SYMBOL_PLAINVAL) |
| 3116 | else if (BUFFERP (where) | 3141 | SET_SYMBOL_VAL (XSYMBOL (specpdl_symbol (&this_binding)), |
| 3117 | ? !NILP (Flocal_variable_p (symbol, where)) | 3142 | specpdl_old_value (&this_binding)); |
| 3118 | : !NILP (Fassq (symbol, XFRAME (where)->param_alist))) | 3143 | else |
| 3119 | set_internal (symbol, this_binding.old_value, where, 1); | 3144 | /* NOTE: we only ever come here if make_local_foo was used for |
| 3145 | the first time on this var within this let. */ | ||
| 3146 | Fset_default (specpdl_symbol (&this_binding), | ||
| 3147 | specpdl_old_value (&this_binding)); | ||
| 3148 | break; | ||
| 3149 | case SPECPDL_BACKTRACE: | ||
| 3150 | break; | ||
| 3151 | case SPECPDL_LET_LOCAL: | ||
| 3152 | case SPECPDL_LET_DEFAULT: | ||
| 3153 | { /* If the symbol is a list, it is really (SYMBOL WHERE | ||
| 3154 | . CURRENT-BUFFER) where WHERE is either nil, a buffer, or a | ||
| 3155 | frame. If WHERE is a buffer or frame, this indicates we | ||
| 3156 | bound a variable that had a buffer-local or frame-local | ||
| 3157 | binding. WHERE nil means that the variable had the default | ||
| 3158 | value when it was bound. CURRENT-BUFFER is the buffer that | ||
| 3159 | was current when the variable was bound. */ | ||
| 3160 | Lisp_Object symbol = specpdl_symbol (&this_binding); | ||
| 3161 | Lisp_Object where = specpdl_where (&this_binding); | ||
| 3162 | eassert (BUFFERP (where)); | ||
| 3163 | |||
| 3164 | if (this_binding.kind == SPECPDL_LET_DEFAULT) | ||
| 3165 | Fset_default (symbol, specpdl_old_value (&this_binding)); | ||
| 3166 | /* If this was a local binding, reset the value in the appropriate | ||
| 3167 | buffer, but only if that buffer's binding still exists. */ | ||
| 3168 | else if (!NILP (Flocal_variable_p (symbol, where))) | ||
| 3169 | set_internal (symbol, specpdl_old_value (&this_binding), | ||
| 3170 | where, 1); | ||
| 3171 | } | ||
| 3172 | break; | ||
| 3120 | } | 3173 | } |
| 3121 | /* If variable has a trivial value (no forwarding), we can | ||
| 3122 | just set it. No need to check for constant symbols here, | ||
| 3123 | since that was already done by specbind. */ | ||
| 3124 | else if (XSYMBOL (this_binding.symbol)->redirect == SYMBOL_PLAINVAL) | ||
| 3125 | SET_SYMBOL_VAL (XSYMBOL (this_binding.symbol), | ||
| 3126 | this_binding.old_value); | ||
| 3127 | else | ||
| 3128 | /* NOTE: we only ever come here if make_local_foo was used for | ||
| 3129 | the first time on this var within this let. */ | ||
| 3130 | Fset_default (this_binding.symbol, this_binding.old_value); | ||
| 3131 | } | 3174 | } |
| 3132 | 3175 | ||
| 3133 | if (NILP (Vquit_flag) && !NILP (quitf)) | 3176 | if (NILP (Vquit_flag) && !NILP (quitf)) |
| @@ -3153,18 +3196,16 @@ DEFUN ("backtrace-debug", Fbacktrace_debug, Sbacktrace_debug, 2, 2, 0, | |||
| 3153 | The debugger is entered when that frame exits, if the flag is non-nil. */) | 3196 | The debugger is entered when that frame exits, if the flag is non-nil. */) |
| 3154 | (Lisp_Object level, Lisp_Object flag) | 3197 | (Lisp_Object level, Lisp_Object flag) |
| 3155 | { | 3198 | { |
| 3156 | register struct backtrace *backlist = backtrace_list; | 3199 | struct specbinding *pdl = backtrace_top (); |
| 3157 | register EMACS_INT i; | 3200 | register EMACS_INT i; |
| 3158 | 3201 | ||
| 3159 | CHECK_NUMBER (level); | 3202 | CHECK_NUMBER (level); |
| 3160 | 3203 | ||
| 3161 | for (i = 0; backlist && i < XINT (level); i++) | 3204 | for (i = 0; backtrace_p (pdl) && i < XINT (level); i++) |
| 3162 | { | 3205 | pdl = backtrace_next (pdl); |
| 3163 | backlist = backlist->next; | ||
| 3164 | } | ||
| 3165 | 3206 | ||
| 3166 | if (backlist) | 3207 | if (backtrace_p (pdl)) |
| 3167 | backlist->debug_on_exit = !NILP (flag); | 3208 | set_backtrace_debug_on_exit (pdl, !NILP (flag)); |
| 3168 | 3209 | ||
| 3169 | return flag; | 3210 | return flag; |
| 3170 | } | 3211 | } |
| @@ -3174,58 +3215,41 @@ DEFUN ("backtrace", Fbacktrace, Sbacktrace, 0, 0, "", | |||
| 3174 | Output stream used is value of `standard-output'. */) | 3215 | Output stream used is value of `standard-output'. */) |
| 3175 | (void) | 3216 | (void) |
| 3176 | { | 3217 | { |
| 3177 | register struct backtrace *backlist = backtrace_list; | 3218 | struct specbinding *pdl = backtrace_top (); |
| 3178 | Lisp_Object tail; | ||
| 3179 | Lisp_Object tem; | 3219 | Lisp_Object tem; |
| 3180 | struct gcpro gcpro1; | ||
| 3181 | Lisp_Object old_print_level = Vprint_level; | 3220 | Lisp_Object old_print_level = Vprint_level; |
| 3182 | 3221 | ||
| 3183 | if (NILP (Vprint_level)) | 3222 | if (NILP (Vprint_level)) |
| 3184 | XSETFASTINT (Vprint_level, 8); | 3223 | XSETFASTINT (Vprint_level, 8); |
| 3185 | 3224 | ||
| 3186 | tail = Qnil; | 3225 | while (backtrace_p (pdl)) |
| 3187 | GCPRO1 (tail); | ||
| 3188 | |||
| 3189 | while (backlist) | ||
| 3190 | { | 3226 | { |
| 3191 | write_string (backlist->debug_on_exit ? "* " : " ", 2); | 3227 | write_string (backtrace_debug_on_exit (pdl) ? "* " : " ", 2); |
| 3192 | if (backlist->nargs == UNEVALLED) | 3228 | if (backtrace_nargs (pdl) == UNEVALLED) |
| 3193 | { | 3229 | { |
| 3194 | Fprin1 (Fcons (backlist->function, *backlist->args), Qnil); | 3230 | Fprin1 (Fcons (backtrace_function (pdl), *backtrace_args (pdl)), |
| 3231 | Qnil); | ||
| 3195 | write_string ("\n", -1); | 3232 | write_string ("\n", -1); |
| 3196 | } | 3233 | } |
| 3197 | else | 3234 | else |
| 3198 | { | 3235 | { |
| 3199 | tem = backlist->function; | 3236 | tem = backtrace_function (pdl); |
| 3200 | Fprin1 (tem, Qnil); /* This can QUIT. */ | 3237 | Fprin1 (tem, Qnil); /* This can QUIT. */ |
| 3201 | write_string ("(", -1); | 3238 | write_string ("(", -1); |
| 3202 | if (backlist->nargs == MANY) | 3239 | { |
| 3203 | { /* FIXME: Can this happen? */ | 3240 | ptrdiff_t i; |
| 3204 | bool later_arg = 0; | 3241 | for (i = 0; i < backtrace_nargs (pdl); i++) |
| 3205 | for (tail = *backlist->args; !NILP (tail); tail = Fcdr (tail)) | 3242 | { |
| 3206 | { | 3243 | if (i) write_string (" ", -1); |
| 3207 | if (later_arg) | 3244 | Fprin1 (backtrace_args (pdl)[i], Qnil); |
| 3208 | write_string (" ", -1); | 3245 | } |
| 3209 | Fprin1 (Fcar (tail), Qnil); | 3246 | } |
| 3210 | later_arg = 1; | ||
| 3211 | } | ||
| 3212 | } | ||
| 3213 | else | ||
| 3214 | { | ||
| 3215 | ptrdiff_t i; | ||
| 3216 | for (i = 0; i < backlist->nargs; i++) | ||
| 3217 | { | ||
| 3218 | if (i) write_string (" ", -1); | ||
| 3219 | Fprin1 (backlist->args[i], Qnil); | ||
| 3220 | } | ||
| 3221 | } | ||
| 3222 | write_string (")\n", -1); | 3247 | write_string (")\n", -1); |
| 3223 | } | 3248 | } |
| 3224 | backlist = backlist->next; | 3249 | pdl = backtrace_next (pdl); |
| 3225 | } | 3250 | } |
| 3226 | 3251 | ||
| 3227 | Vprint_level = old_print_level; | 3252 | Vprint_level = old_print_level; |
| 3228 | UNGCPRO; | ||
| 3229 | return Qnil; | 3253 | return Qnil; |
| 3230 | } | 3254 | } |
| 3231 | 3255 | ||
| @@ -3241,53 +3265,84 @@ or a lambda expression for macro calls. | |||
| 3241 | If NFRAMES is more than the number of frames, the value is nil. */) | 3265 | If NFRAMES is more than the number of frames, the value is nil. */) |
| 3242 | (Lisp_Object nframes) | 3266 | (Lisp_Object nframes) |
| 3243 | { | 3267 | { |
| 3244 | register struct backtrace *backlist = backtrace_list; | 3268 | struct specbinding *pdl = backtrace_top (); |
| 3245 | register EMACS_INT i; | 3269 | register EMACS_INT i; |
| 3246 | Lisp_Object tem; | ||
| 3247 | 3270 | ||
| 3248 | CHECK_NATNUM (nframes); | 3271 | CHECK_NATNUM (nframes); |
| 3249 | 3272 | ||
| 3250 | /* Find the frame requested. */ | 3273 | /* Find the frame requested. */ |
| 3251 | for (i = 0; backlist && i < XFASTINT (nframes); i++) | 3274 | for (i = 0; backtrace_p (pdl) && i < XFASTINT (nframes); i++) |
| 3252 | backlist = backlist->next; | 3275 | pdl = backtrace_next (pdl); |
| 3253 | 3276 | ||
| 3254 | if (!backlist) | 3277 | if (!backtrace_p (pdl)) |
| 3255 | return Qnil; | 3278 | return Qnil; |
| 3256 | if (backlist->nargs == UNEVALLED) | 3279 | if (backtrace_nargs (pdl) == UNEVALLED) |
| 3257 | return Fcons (Qnil, Fcons (backlist->function, *backlist->args)); | 3280 | return Fcons (Qnil, |
| 3281 | Fcons (backtrace_function (pdl), *backtrace_args (pdl))); | ||
| 3258 | else | 3282 | else |
| 3259 | { | 3283 | { |
| 3260 | if (backlist->nargs == MANY) /* FIXME: Can this happen? */ | 3284 | Lisp_Object tem = Flist (backtrace_nargs (pdl), backtrace_args (pdl)); |
| 3261 | tem = *backlist->args; | ||
| 3262 | else | ||
| 3263 | tem = Flist (backlist->nargs, backlist->args); | ||
| 3264 | 3285 | ||
| 3265 | return Fcons (Qt, Fcons (backlist->function, tem)); | 3286 | return Fcons (Qt, Fcons (backtrace_function (pdl), tem)); |
| 3266 | } | 3287 | } |
| 3267 | } | 3288 | } |
| 3268 | 3289 | ||
| 3269 | 3290 | ||
| 3270 | #if BYTE_MARK_STACK | ||
| 3271 | void | 3291 | void |
| 3272 | mark_backtrace (void) | 3292 | mark_specpdl (void) |
| 3273 | { | 3293 | { |
| 3274 | register struct backtrace *backlist; | 3294 | struct specbinding *pdl; |
| 3275 | ptrdiff_t i; | 3295 | for (pdl = specpdl; pdl != specpdl_ptr; pdl++) |
| 3276 | |||
| 3277 | for (backlist = backtrace_list; backlist; backlist = backlist->next) | ||
| 3278 | { | 3296 | { |
| 3279 | mark_object (backlist->function); | 3297 | switch (pdl->kind) |
| 3298 | { | ||
| 3299 | case SPECPDL_UNWIND: | ||
| 3300 | mark_object (specpdl_arg (pdl)); | ||
| 3301 | break; | ||
| 3302 | case SPECPDL_BACKTRACE: | ||
| 3303 | { | ||
| 3304 | ptrdiff_t nargs = backtrace_nargs (pdl); | ||
| 3305 | mark_object (backtrace_function (pdl)); | ||
| 3306 | if (nargs == UNEVALLED) | ||
| 3307 | nargs = 1; | ||
| 3308 | while (nargs--) | ||
| 3309 | mark_object (backtrace_args (pdl)[nargs]); | ||
| 3310 | } | ||
| 3311 | break; | ||
| 3312 | case SPECPDL_LET_DEFAULT: | ||
| 3313 | case SPECPDL_LET_LOCAL: | ||
| 3314 | mark_object (specpdl_where (pdl)); | ||
| 3315 | case SPECPDL_LET: | ||
| 3316 | mark_object (specpdl_symbol (pdl)); | ||
| 3317 | mark_object (specpdl_old_value (pdl)); | ||
| 3318 | } | ||
| 3319 | } | ||
| 3320 | } | ||
| 3321 | |||
| 3322 | void | ||
| 3323 | get_backtrace (Lisp_Object array) | ||
| 3324 | { | ||
| 3325 | struct specbinding *pdl = backtrace_next (backtrace_top ()); | ||
| 3326 | ptrdiff_t i = 0, asize = ASIZE (array); | ||
| 3280 | 3327 | ||
| 3281 | if (backlist->nargs == UNEVALLED | 3328 | /* Copy the backtrace contents into working memory. */ |
| 3282 | || backlist->nargs == MANY) /* FIXME: Can this happen? */ | 3329 | for (; i < asize; i++) |
| 3283 | i = 1; | 3330 | { |
| 3331 | if (backtrace_p (pdl)) | ||
| 3332 | { | ||
| 3333 | ASET (array, i, backtrace_function (pdl)); | ||
| 3334 | pdl = backtrace_next (pdl); | ||
| 3335 | } | ||
| 3284 | else | 3336 | else |
| 3285 | i = backlist->nargs; | 3337 | ASET (array, i, Qnil); |
| 3286 | while (i--) | ||
| 3287 | mark_object (backlist->args[i]); | ||
| 3288 | } | 3338 | } |
| 3289 | } | 3339 | } |
| 3290 | #endif | 3340 | |
| 3341 | Lisp_Object backtrace_top_function (void) | ||
| 3342 | { | ||
| 3343 | struct specbinding *pdl = backtrace_top (); | ||
| 3344 | return (backtrace_p (pdl) ? backtrace_function (pdl) : Qnil); | ||
| 3345 | } | ||
| 3291 | 3346 | ||
| 3292 | void | 3347 | void |
| 3293 | syms_of_eval (void) | 3348 | syms_of_eval (void) |
diff --git a/src/frame.c b/src/frame.c index e88432b9802..a207ef690da 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -114,7 +114,7 @@ Lisp_Object Qface_set_after_frame_default; | |||
| 114 | 114 | ||
| 115 | static Lisp_Object Qdelete_frame_functions; | 115 | static Lisp_Object Qdelete_frame_functions; |
| 116 | 116 | ||
| 117 | Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; | 117 | static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; |
| 118 | 118 | ||
| 119 | #ifdef HAVE_WINDOW_SYSTEM | 119 | #ifdef HAVE_WINDOW_SYSTEM |
| 120 | static void x_report_frame_params (struct frame *, Lisp_Object *); | 120 | static void x_report_frame_params (struct frame *, Lisp_Object *); |
| @@ -167,7 +167,7 @@ struct frame * | |||
| 167 | decode_window_system_frame (Lisp_Object frame) | 167 | decode_window_system_frame (Lisp_Object frame) |
| 168 | { | 168 | { |
| 169 | struct frame *f = decode_live_frame (frame); | 169 | struct frame *f = decode_live_frame (frame); |
| 170 | 170 | ||
| 171 | if (!window_system_available (f)) | 171 | if (!window_system_available (f)) |
| 172 | error ("Window system frame should be used"); | 172 | error ("Window system frame should be used"); |
| 173 | return f; | 173 | return f; |
| @@ -4138,6 +4138,8 @@ selected frame. This is useful when `make-pointer-invisible' is set. */) | |||
| 4138 | 4138 | ||
| 4139 | #ifdef HAVE_WINDOW_SYSTEM | 4139 | #ifdef HAVE_WINDOW_SYSTEM |
| 4140 | 4140 | ||
| 4141 | # if (defined HAVE_NS \ | ||
| 4142 | || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR))) | ||
| 4141 | void | 4143 | void |
| 4142 | free_monitors (struct MonitorInfo *monitors, int n_monitors) | 4144 | free_monitors (struct MonitorInfo *monitors, int n_monitors) |
| 4143 | { | 4145 | { |
| @@ -4146,6 +4148,7 @@ free_monitors (struct MonitorInfo *monitors, int n_monitors) | |||
| 4146 | xfree (monitors[i].name); | 4148 | xfree (monitors[i].name); |
| 4147 | xfree (monitors); | 4149 | xfree (monitors); |
| 4148 | } | 4150 | } |
| 4151 | # endif | ||
| 4149 | 4152 | ||
| 4150 | Lisp_Object | 4153 | Lisp_Object |
| 4151 | make_monitor_attribute_list (struct MonitorInfo *monitors, | 4154 | make_monitor_attribute_list (struct MonitorInfo *monitors, |
diff --git a/src/frame.h b/src/frame.h index 12aa48b2d92..31d3e73c3c3 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -1198,8 +1198,6 @@ extern Lisp_Object Qdisplay; | |||
| 1198 | 1198 | ||
| 1199 | extern Lisp_Object Qrun_hook_with_args; | 1199 | extern Lisp_Object Qrun_hook_with_args; |
| 1200 | 1200 | ||
| 1201 | extern Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; | ||
| 1202 | |||
| 1203 | #ifdef HAVE_WINDOW_SYSTEM | 1201 | #ifdef HAVE_WINDOW_SYSTEM |
| 1204 | 1202 | ||
| 1205 | /* The class of this X application. */ | 1203 | /* The class of this X application. */ |
diff --git a/src/gfilenotify.c b/src/gfilenotify.c new file mode 100644 index 00000000000..4ccc430d815 --- /dev/null +++ b/src/gfilenotify.c | |||
| @@ -0,0 +1,266 @@ | |||
| 1 | /* Filesystem notifications support with glib API. | ||
| 2 | Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This file is part of GNU Emacs. | ||
| 5 | |||
| 6 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation, either version 3 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 18 | |||
| 19 | #include <config.h> | ||
| 20 | |||
| 21 | #ifdef HAVE_GFILENOTIFY | ||
| 22 | #include <stdio.h> | ||
| 23 | #include <gio/gio.h> | ||
| 24 | #include "lisp.h" | ||
| 25 | #include "coding.h" | ||
| 26 | #include "frame.h" | ||
| 27 | #include "termhooks.h" | ||
| 28 | #include "keyboard.h" | ||
| 29 | #include "process.h" | ||
| 30 | |||
| 31 | |||
| 32 | /* Subroutines. */ | ||
| 33 | static Lisp_Object Qgfile_add_watch; | ||
| 34 | static Lisp_Object Qgfile_rm_watch; | ||
| 35 | |||
| 36 | /* Filter objects. */ | ||
| 37 | static Lisp_Object Qwatch_mounts; /* G_FILE_MONITOR_WATCH_MOUNTS */ | ||
| 38 | static Lisp_Object Qsend_moved; /* G_FILE_MONITOR_SEND_MOVED */ | ||
| 39 | |||
| 40 | /* Event types. */ | ||
| 41 | static Lisp_Object Qchanged; /* G_FILE_MONITOR_EVENT_CHANGED */ | ||
| 42 | static Lisp_Object Qchanges_done_hint; /* G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT */ | ||
| 43 | static Lisp_Object Qdeleted; /* G_FILE_MONITOR_EVENT_DELETED */ | ||
| 44 | static Lisp_Object Qcreated; /* G_FILE_MONITOR_EVENT_CREATED */ | ||
| 45 | static Lisp_Object Qattribute_changed; /* G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED */ | ||
| 46 | static Lisp_Object Qpre_unmount; /* G_FILE_MONITOR_EVENT_PRE_UNMOUNT */ | ||
| 47 | static Lisp_Object Qunmounted; /* G_FILE_MONITOR_EVENT_UNMOUNTED */ | ||
| 48 | static Lisp_Object Qmoved; /* G_FILE_MONITOR_EVENT_MOVED */ | ||
| 49 | |||
| 50 | static Lisp_Object watch_list; | ||
| 51 | |||
| 52 | /* This is the callback function for arriving signals from | ||
| 53 | g_file_monitor. It shall create a Lisp event, and put it into | ||
| 54 | Emacs input queue. */ | ||
| 55 | static gboolean | ||
| 56 | dir_monitor_callback (GFileMonitor* monitor, | ||
| 57 | GFile* file, | ||
| 58 | GFile* other_file, | ||
| 59 | GFileMonitorEvent event_type, | ||
| 60 | gpointer user_data) | ||
| 61 | { | ||
| 62 | Lisp_Object symbol, watch_object; | ||
| 63 | char *name = g_file_get_parse_name (file); | ||
| 64 | char *oname = other_file ? g_file_get_parse_name (other_file) : NULL; | ||
| 65 | |||
| 66 | /* Determine event symbol. */ | ||
| 67 | switch (event_type) | ||
| 68 | { | ||
| 69 | case G_FILE_MONITOR_EVENT_CHANGED: | ||
| 70 | symbol = Qchanged; | ||
| 71 | break; | ||
| 72 | case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: | ||
| 73 | symbol = Qchanges_done_hint; | ||
| 74 | break; | ||
| 75 | case G_FILE_MONITOR_EVENT_DELETED: | ||
| 76 | symbol = Qdeleted; | ||
| 77 | break; | ||
| 78 | case G_FILE_MONITOR_EVENT_CREATED: | ||
| 79 | symbol = Qcreated; | ||
| 80 | break; | ||
| 81 | case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: | ||
| 82 | symbol = Qattribute_changed; | ||
| 83 | break; | ||
| 84 | case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: | ||
| 85 | symbol = Qpre_unmount; | ||
| 86 | break; | ||
| 87 | case G_FILE_MONITOR_EVENT_UNMOUNTED: | ||
| 88 | symbol = Qunmounted; | ||
| 89 | break; | ||
| 90 | case G_FILE_MONITOR_EVENT_MOVED: | ||
| 91 | symbol = Qmoved; | ||
| 92 | break; | ||
| 93 | default: | ||
| 94 | goto cleanup; | ||
| 95 | } | ||
| 96 | |||
| 97 | /* Determine callback function. */ | ||
| 98 | watch_object = Fassoc (XIL ((EMACS_INT) monitor), watch_list); | ||
| 99 | |||
| 100 | if (FUNCTIONP (CDR_SAFE (watch_object))) | ||
| 101 | { | ||
| 102 | /* Construct an event. */ | ||
| 103 | struct input_event event; | ||
| 104 | EVENT_INIT (event); | ||
| 105 | event.kind = FILE_NOTIFY_EVENT; | ||
| 106 | event.frame_or_window = Qnil; | ||
| 107 | event.arg = oname | ||
| 108 | ? list2 (list4 (XIL ((EMACS_INT) monitor), symbol, | ||
| 109 | build_string (name), build_string (oname)), | ||
| 110 | CDR_SAFE (watch_object)) | ||
| 111 | : list2 (list3 (XIL ((EMACS_INT) monitor), symbol, build_string (name)), | ||
| 112 | CDR_SAFE (watch_object)); | ||
| 113 | |||
| 114 | /* Store it into the input event queue. */ | ||
| 115 | kbd_buffer_store_event (&event); | ||
| 116 | } | ||
| 117 | |||
| 118 | /* Cleanup. */ | ||
| 119 | cleanup: | ||
| 120 | g_free (name); | ||
| 121 | g_free (oname); | ||
| 122 | |||
| 123 | return TRUE; | ||
| 124 | } | ||
| 125 | |||
| 126 | DEFUN ("gfile-add-watch", Fgfile_add_watch, Sgfile_add_watch, 3, 3, 0, | ||
| 127 | doc: /* Add a watch for filesystem events pertaining to FILE. | ||
| 128 | |||
| 129 | This arranges for filesystem events pertaining to FILE to be reported | ||
| 130 | to Emacs. Use `gfile-rm-watch' to cancel the watch. | ||
| 131 | |||
| 132 | Value is a descriptor for the added watch. If the file cannot be | ||
| 133 | watched for some reason, this function signals a `file-error' error. | ||
| 134 | |||
| 135 | FLAGS is a list of conditions to set what will be watched for. It can | ||
| 136 | include the following symbols: | ||
| 137 | |||
| 138 | 'watch-mounts' -- watch for mount events | ||
| 139 | 'send-moved' -- pair 'deleted' and 'created' events caused by file | ||
| 140 | renames (moves) and send a single 'event-moved' | ||
| 141 | event instead | ||
| 142 | |||
| 143 | When any event happens, Emacs will call the CALLBACK function passing | ||
| 144 | it a single argument EVENT, which is of the form | ||
| 145 | |||
| 146 | (DESCRIPTOR ACTION FILE [FILE1]) | ||
| 147 | |||
| 148 | DESCRIPTOR is the same object as the one returned by this function. | ||
| 149 | ACTION is the description of the event. It could be any one of the | ||
| 150 | following: | ||
| 151 | |||
| 152 | 'changed' -- FILE has changed | ||
| 153 | 'changes-done-hint' -- a hint that this was probably the last change | ||
| 154 | in a set of changes | ||
| 155 | 'deleted' -- FILE was deleted | ||
| 156 | 'created' -- FILE was created | ||
| 157 | 'attribute-changed' -- a FILE attribute was changed | ||
| 158 | 'pre-unmount' -- the FILE location will soon be unmounted | ||
| 159 | 'unmounted' -- the FILE location was unmounted | ||
| 160 | 'moved' -- FILE was moved to FILE1 | ||
| 161 | |||
| 162 | FILE is the name of the file whose event is being reported. FILE1 | ||
| 163 | will be reported only in case of the 'moved' event. */) | ||
| 164 | (Lisp_Object file, Lisp_Object flags, Lisp_Object callback) | ||
| 165 | { | ||
| 166 | Lisp_Object watch_descriptor, watch_object; | ||
| 167 | GFile *gfile; | ||
| 168 | GFileMonitor* monitor; | ||
| 169 | GFileMonitorFlags gflags = G_FILE_MONITOR_NONE; | ||
| 170 | |||
| 171 | /* Check parameters. */ | ||
| 172 | CHECK_STRING (file); | ||
| 173 | file = Fdirectory_file_name (Fexpand_file_name (file, Qnil)); | ||
| 174 | if (NILP (Ffile_exists_p (file))) | ||
| 175 | report_file_error ("File does not exists", Fcons (file, Qnil)); | ||
| 176 | |||
| 177 | CHECK_LIST (flags); | ||
| 178 | |||
| 179 | if (!FUNCTIONP (callback)) | ||
| 180 | wrong_type_argument (Qinvalid_function, callback); | ||
| 181 | |||
| 182 | /* Create GFile name. */ | ||
| 183 | gfile = g_file_new_for_path (SSDATA (ENCODE_FILE (file))); | ||
| 184 | |||
| 185 | /* Assemble flags. */ | ||
| 186 | if (!NILP (Fmember (Qwatch_mounts, flags))) | ||
| 187 | gflags |= G_FILE_MONITOR_WATCH_MOUNTS; | ||
| 188 | if (!NILP (Fmember (Qsend_moved, flags))) | ||
| 189 | gflags |= G_FILE_MONITOR_SEND_MOVED; | ||
| 190 | |||
| 191 | /* Enable watch. */ | ||
| 192 | monitor = g_file_monitor (gfile, gflags, NULL, NULL); | ||
| 193 | if (monitor != NULL) | ||
| 194 | g_signal_connect (monitor, "changed", | ||
| 195 | (GCallback) dir_monitor_callback, NULL); | ||
| 196 | else | ||
| 197 | report_file_error ("Cannot watch file", Fcons (file, Qnil)); | ||
| 198 | |||
| 199 | /* Store watch object in watch list. */ | ||
| 200 | watch_descriptor = XIL ((EMACS_INT) monitor); | ||
| 201 | watch_object = Fcons (watch_descriptor, callback); | ||
| 202 | watch_list = Fcons (watch_object, watch_list); | ||
| 203 | |||
| 204 | return watch_descriptor; | ||
| 205 | } | ||
| 206 | |||
| 207 | DEFUN ("gfile-rm-watch", Fgfile_rm_watch, Sgfile_rm_watch, 1, 1, 0, | ||
| 208 | doc: /* Remove an existing WATCH-DESCRIPTOR. | ||
| 209 | |||
| 210 | WATCH-DESCRIPTOR should be an object returned by `gfile-add-watch'. */) | ||
| 211 | (Lisp_Object watch_descriptor) | ||
| 212 | { | ||
| 213 | Lisp_Object watch_object; | ||
| 214 | GFileMonitor *monitor = (GFileMonitor *) XLI (watch_descriptor); | ||
| 215 | |||
| 216 | watch_object = Fassoc (watch_descriptor, watch_list); | ||
| 217 | if (NILP (watch_object)) | ||
| 218 | report_file_error ("Not a watch descriptor", | ||
| 219 | Fcons (watch_descriptor, Qnil)); | ||
| 220 | |||
| 221 | if (!g_file_monitor_cancel (monitor)) | ||
| 222 | report_file_error ("Could not rm watch", | ||
| 223 | Fcons (watch_descriptor, Qnil)); | ||
| 224 | |||
| 225 | /* Remove watch descriptor from watch list. */ | ||
| 226 | watch_list = Fdelete (watch_object, watch_list); | ||
| 227 | |||
| 228 | /* Cleanup. */ | ||
| 229 | g_object_unref (monitor); | ||
| 230 | |||
| 231 | return Qt; | ||
| 232 | } | ||
| 233 | |||
| 234 | |||
| 235 | void | ||
| 236 | syms_of_gfilenotify (void) | ||
| 237 | { | ||
| 238 | |||
| 239 | g_type_init (); | ||
| 240 | |||
| 241 | DEFSYM (Qgfile_add_watch, "gfile-add-watch"); | ||
| 242 | defsubr (&Sgfile_add_watch); | ||
| 243 | |||
| 244 | DEFSYM (Qgfile_rm_watch, "gfile-rm-watch"); | ||
| 245 | defsubr (&Sgfile_rm_watch); | ||
| 246 | |||
| 247 | DEFSYM (Qwatch_mounts, "watch-mounts"); | ||
| 248 | DEFSYM (Qsend_moved, "send-moved"); | ||
| 249 | DEFSYM (Qchanged, "changed"); | ||
| 250 | DEFSYM (Qchanges_done_hint, "changes-done-hint"); | ||
| 251 | DEFSYM (Qdeleted, "deleted"); | ||
| 252 | DEFSYM (Qcreated, "created"); | ||
| 253 | DEFSYM (Qattribute_changed, "attribute-changed"); | ||
| 254 | DEFSYM (Qpre_unmount, "pre-unmount"); | ||
| 255 | DEFSYM (Qunmounted, "unmounted"); | ||
| 256 | DEFSYM (Qmoved, "moved"); | ||
| 257 | |||
| 258 | /* Initialize internal objects. */ | ||
| 259 | watch_list = Qnil; | ||
| 260 | staticpro (&watch_list); | ||
| 261 | |||
| 262 | Fprovide (intern_c_string ("gfilenotify"), Qnil); | ||
| 263 | |||
| 264 | } | ||
| 265 | |||
| 266 | #endif /* HAVE_GFILENOTIFY */ | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 0a7577b859e..8dd109d252d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -308,18 +308,15 @@ static Lisp_Object Qfunction_key; | |||
| 308 | Lisp_Object Qmouse_click; | 308 | Lisp_Object Qmouse_click; |
| 309 | #ifdef HAVE_NTGUI | 309 | #ifdef HAVE_NTGUI |
| 310 | Lisp_Object Qlanguage_change; | 310 | Lisp_Object Qlanguage_change; |
| 311 | #ifdef WINDOWSNT | ||
| 312 | Lisp_Object Qfile_w32notify; | ||
| 313 | #endif | ||
| 314 | #endif | 311 | #endif |
| 315 | static Lisp_Object Qdrag_n_drop; | 312 | static Lisp_Object Qdrag_n_drop; |
| 316 | static Lisp_Object Qsave_session; | 313 | static Lisp_Object Qsave_session; |
| 317 | #ifdef HAVE_DBUS | 314 | #ifdef HAVE_DBUS |
| 318 | static Lisp_Object Qdbus_event; | 315 | static Lisp_Object Qdbus_event; |
| 319 | #endif | 316 | #endif |
| 320 | #ifdef HAVE_INOTIFY | 317 | #ifdef USE_FILE_NOTIFY |
| 321 | static Lisp_Object Qfile_inotify; | 318 | static Lisp_Object Qfile_notify; |
| 322 | #endif /* HAVE_INOTIFY */ | 319 | #endif /* USE_FILE_NOTIFY */ |
| 323 | static Lisp_Object Qconfig_changed_event; | 320 | static Lisp_Object Qconfig_changed_event; |
| 324 | 321 | ||
| 325 | /* Lisp_Object Qmouse_movement; - also an event header */ | 322 | /* Lisp_Object Qmouse_movement; - also an event header */ |
| @@ -1885,7 +1882,7 @@ safe_run_hooks_error (Lisp_Object error_data) | |||
| 1885 | = CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit; | 1882 | = CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit; |
| 1886 | Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil; | 1883 | Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil; |
| 1887 | Lisp_Object args[4]; | 1884 | Lisp_Object args[4]; |
| 1888 | args[0] = build_string ("Error in %s (%s): %S"); | 1885 | args[0] = build_string ("Error in %s (%S): %S"); |
| 1889 | args[1] = hook; | 1886 | args[1] = hook; |
| 1890 | args[2] = fun; | 1887 | args[2] = fun; |
| 1891 | args[3] = error_data; | 1888 | args[3] = error_data; |
| @@ -4013,18 +4010,22 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4013 | kbd_fetch_ptr = event + 1; | 4010 | kbd_fetch_ptr = event + 1; |
| 4014 | } | 4011 | } |
| 4015 | #endif | 4012 | #endif |
| 4016 | #ifdef WINDOWSNT | 4013 | #ifdef USE_FILE_NOTIFY |
| 4017 | else if (event->kind == FILE_NOTIFY_EVENT) | 4014 | else if (event->kind == FILE_NOTIFY_EVENT) |
| 4018 | { | 4015 | { |
| 4016 | #ifdef HAVE_W32NOTIFY | ||
| 4019 | /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */ | 4017 | /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */ |
| 4020 | obj = Fcons (Qfile_w32notify, | 4018 | obj = Fcons (Qfile_notify, |
| 4021 | list2 (list3 (make_number (event->code), | 4019 | list2 (list3 (make_number (event->code), |
| 4022 | XCAR (event->arg), | 4020 | XCAR (event->arg), |
| 4023 | XCDR (event->arg)), | 4021 | XCDR (event->arg)), |
| 4024 | event->frame_or_window)); | 4022 | event->frame_or_window)); |
| 4023 | #else | ||
| 4024 | obj = make_lispy_event (event); | ||
| 4025 | #endif | ||
| 4025 | kbd_fetch_ptr = event + 1; | 4026 | kbd_fetch_ptr = event + 1; |
| 4026 | } | 4027 | } |
| 4027 | #endif | 4028 | #endif /* USE_FILE_NOTIFY */ |
| 4028 | else if (event->kind == SAVE_SESSION_EVENT) | 4029 | else if (event->kind == SAVE_SESSION_EVENT) |
| 4029 | { | 4030 | { |
| 4030 | obj = Fcons (Qsave_session, Fcons (event->arg, Qnil)); | 4031 | obj = Fcons (Qsave_session, Fcons (event->arg, Qnil)); |
| @@ -4082,13 +4083,6 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4082 | kbd_fetch_ptr = event + 1; | 4083 | kbd_fetch_ptr = event + 1; |
| 4083 | } | 4084 | } |
| 4084 | #endif | 4085 | #endif |
| 4085 | #ifdef HAVE_INOTIFY | ||
| 4086 | else if (event->kind == FILE_NOTIFY_EVENT) | ||
| 4087 | { | ||
| 4088 | obj = make_lispy_event (event); | ||
| 4089 | kbd_fetch_ptr = event + 1; | ||
| 4090 | } | ||
| 4091 | #endif | ||
| 4092 | else if (event->kind == CONFIG_CHANGED_EVENT) | 4086 | else if (event->kind == CONFIG_CHANGED_EVENT) |
| 4093 | { | 4087 | { |
| 4094 | obj = make_lispy_event (event); | 4088 | obj = make_lispy_event (event); |
| @@ -5991,12 +5985,12 @@ make_lispy_event (struct input_event *event) | |||
| 5991 | } | 5985 | } |
| 5992 | #endif /* HAVE_DBUS */ | 5986 | #endif /* HAVE_DBUS */ |
| 5993 | 5987 | ||
| 5994 | #ifdef HAVE_INOTIFY | 5988 | #if defined HAVE_GFILENOTIFY || defined HAVE_INOTIFY |
| 5995 | case FILE_NOTIFY_EVENT: | 5989 | case FILE_NOTIFY_EVENT: |
| 5996 | { | 5990 | { |
| 5997 | return Fcons (Qfile_inotify, event->arg); | 5991 | return Fcons (Qfile_notify, event->arg); |
| 5998 | } | 5992 | } |
| 5999 | #endif /* HAVE_INOTIFY */ | 5993 | #endif /* defined HAVE_GFILENOTIFY || defined HAVE_INOTIFY */ |
| 6000 | 5994 | ||
| 6001 | case CONFIG_CHANGED_EVENT: | 5995 | case CONFIG_CHANGED_EVENT: |
| 6002 | return Fcons (Qconfig_changed_event, | 5996 | return Fcons (Qconfig_changed_event, |
| @@ -11006,17 +11000,13 @@ syms_of_keyboard (void) | |||
| 11006 | DEFSYM (Qlanguage_change, "language-change"); | 11000 | DEFSYM (Qlanguage_change, "language-change"); |
| 11007 | #endif | 11001 | #endif |
| 11008 | 11002 | ||
| 11009 | #ifdef WINDOWSNT | ||
| 11010 | DEFSYM (Qfile_w32notify, "file-w32notify"); | ||
| 11011 | #endif | ||
| 11012 | |||
| 11013 | #ifdef HAVE_DBUS | 11003 | #ifdef HAVE_DBUS |
| 11014 | DEFSYM (Qdbus_event, "dbus-event"); | 11004 | DEFSYM (Qdbus_event, "dbus-event"); |
| 11015 | #endif | 11005 | #endif |
| 11016 | 11006 | ||
| 11017 | #ifdef HAVE_INOTIFY | 11007 | #ifdef USE_FILE_NOTIFY |
| 11018 | DEFSYM (Qfile_inotify, "file-inotify"); | 11008 | DEFSYM (Qfile_notify, "file-notify"); |
| 11019 | #endif /* HAVE_INOTIFY */ | 11009 | #endif /* USE_FILE_NOTIFY */ |
| 11020 | 11010 | ||
| 11021 | DEFSYM (QCenable, ":enable"); | 11011 | DEFSYM (QCenable, ":enable"); |
| 11022 | DEFSYM (QCvisible, ":visible"); | 11012 | DEFSYM (QCvisible, ":visible"); |
| @@ -11762,20 +11752,18 @@ keys_of_keyboard (void) | |||
| 11762 | "dbus-handle-event"); | 11752 | "dbus-handle-event"); |
| 11763 | #endif | 11753 | #endif |
| 11764 | 11754 | ||
| 11765 | #ifdef HAVE_INOTIFY | 11755 | #ifdef USE_FILE_NOTIFY |
| 11766 | /* Define a special event which is raised for inotify callback | 11756 | /* Define a special event which is raised for notification callback |
| 11767 | functions. */ | 11757 | functions. */ |
| 11768 | initial_define_lispy_key (Vspecial_event_map, "file-inotify", | 11758 | initial_define_lispy_key (Vspecial_event_map, "file-notify", |
| 11769 | "inotify-handle-event"); | 11759 | "file-notify-handle-event"); |
| 11770 | #endif /* HAVE_INOTIFY */ | 11760 | #endif /* USE_FILE_NOTIFY */ |
| 11771 | 11761 | ||
| 11772 | initial_define_lispy_key (Vspecial_event_map, "config-changed-event", | 11762 | initial_define_lispy_key (Vspecial_event_map, "config-changed-event", |
| 11773 | "ignore"); | 11763 | "ignore"); |
| 11774 | #if defined (WINDOWSNT) | 11764 | #if defined (WINDOWSNT) |
| 11775 | initial_define_lispy_key (Vspecial_event_map, "language-change", | 11765 | initial_define_lispy_key (Vspecial_event_map, "language-change", |
| 11776 | "ignore"); | 11766 | "ignore"); |
| 11777 | initial_define_lispy_key (Vspecial_event_map, "file-w32notify", | ||
| 11778 | "w32notify-handle-event"); | ||
| 11779 | #endif | 11767 | #endif |
| 11780 | } | 11768 | } |
| 11781 | 11769 | ||
diff --git a/src/lisp.h b/src/lisp.h index 79d32c90f73..517d0abbb61 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -73,6 +73,7 @@ enum | |||
| 73 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), | 73 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), |
| 74 | BITS_PER_INT = CHAR_BIT * sizeof (int), | 74 | BITS_PER_INT = CHAR_BIT * sizeof (int), |
| 75 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), | 75 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), |
| 76 | BITS_PER_PTRDIFF_T = CHAR_BIT * sizeof (ptrdiff_t), | ||
| 76 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) | 77 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) |
| 77 | }; | 78 | }; |
| 78 | 79 | ||
| @@ -2176,12 +2177,24 @@ typedef jmp_buf sys_jmp_buf; | |||
| 2176 | #endif | 2177 | #endif |
| 2177 | 2178 | ||
| 2178 | 2179 | ||
| 2180 | /* Elisp uses several stacks: | ||
| 2181 | - the C stack. | ||
| 2182 | - the bytecode stack: used internally by the bytecode interpreter. | ||
| 2183 | Allocated from the C stack. | ||
| 2184 | - The specpdl stack: keeps track of active unwind-protect and | ||
| 2185 | dynamic-let-bindings. Allocated from the `specpdl' array, a manually | ||
| 2186 | managed stack. | ||
| 2187 | - The catch stack: keeps track of active catch tags. | ||
| 2188 | Allocated on the C stack. This is where the setmp data is kept. | ||
| 2189 | - The handler stack: keeps track of active condition-case handlers. | ||
| 2190 | Allocated on the C stack. Every entry there also uses an entry in | ||
| 2191 | the catch stack. */ | ||
| 2192 | |||
| 2179 | /* Structure for recording Lisp call stack for backtrace purposes. */ | 2193 | /* Structure for recording Lisp call stack for backtrace purposes. */ |
| 2180 | 2194 | ||
| 2181 | /* The special binding stack holds the outer values of variables while | 2195 | /* The special binding stack holds the outer values of variables while |
| 2182 | they are bound by a function application or a let form, stores the | 2196 | they are bound by a function application or a let form, stores the |
| 2183 | code to be executed for Lisp unwind-protect forms, and stores the C | 2197 | code to be executed for unwind-protect forms. |
| 2184 | functions to be called for record_unwind_protect. | ||
| 2185 | 2198 | ||
| 2186 | If func is non-zero, undoing this binding applies func to old_value; | 2199 | If func is non-zero, undoing this binding applies func to old_value; |
| 2187 | This implements record_unwind_protect. | 2200 | This implements record_unwind_protect. |
| @@ -2194,35 +2207,77 @@ typedef jmp_buf sys_jmp_buf; | |||
| 2194 | which means having bound a local value while CURRENT-BUFFER was active. | 2207 | which means having bound a local value while CURRENT-BUFFER was active. |
| 2195 | If WHERE is nil this means we saw the default value when binding SYMBOL. | 2208 | If WHERE is nil this means we saw the default value when binding SYMBOL. |
| 2196 | WHERE being a buffer or frame means we saw a buffer-local or frame-local | 2209 | WHERE being a buffer or frame means we saw a buffer-local or frame-local |
| 2197 | value. Other values of WHERE mean an internal error. */ | 2210 | value. Other values of WHERE mean an internal error. |
| 2211 | |||
| 2212 | NOTE: The specbinding struct is defined here, because SPECPDL_INDEX is | ||
| 2213 | used all over the place, needs to be fast, and needs to know the size of | ||
| 2214 | struct specbinding. But only eval.c should access it. */ | ||
| 2198 | 2215 | ||
| 2199 | typedef Lisp_Object (*specbinding_func) (Lisp_Object); | 2216 | typedef Lisp_Object (*specbinding_func) (Lisp_Object); |
| 2200 | 2217 | ||
| 2218 | enum specbind_tag { | ||
| 2219 | SPECPDL_UNWIND, /* An unwind_protect function. */ | ||
| 2220 | SPECPDL_BACKTRACE, /* An element of the backtrace. */ | ||
| 2221 | SPECPDL_LET, /* A plain and simple dynamic let-binding. */ | ||
| 2222 | /* Tags greater than SPECPDL_LET must be "subkinds" of LET. */ | ||
| 2223 | SPECPDL_LET_LOCAL, /* A buffer-local let-binding. */ | ||
| 2224 | SPECPDL_LET_DEFAULT /* A global binding for a localized var. */ | ||
| 2225 | }; | ||
| 2226 | |||
| 2201 | struct specbinding | 2227 | struct specbinding |
| 2202 | { | 2228 | { |
| 2203 | Lisp_Object symbol, old_value; | 2229 | enum specbind_tag kind; |
| 2204 | specbinding_func func; | 2230 | union { |
| 2205 | Lisp_Object unused; /* Dividing by 16 is faster than by 12. */ | 2231 | struct { |
| 2232 | Lisp_Object arg; | ||
| 2233 | specbinding_func func; | ||
| 2234 | } unwind; | ||
| 2235 | struct { | ||
| 2236 | /* `where' is not used in the case of SPECPDL_LET. */ | ||
| 2237 | Lisp_Object symbol, old_value, where; | ||
| 2238 | } let; | ||
| 2239 | struct { | ||
| 2240 | Lisp_Object function; | ||
| 2241 | Lisp_Object *args; | ||
| 2242 | ptrdiff_t nargs : BITS_PER_PTRDIFF_T - 1; | ||
| 2243 | bool debug_on_exit : 1; | ||
| 2244 | } bt; | ||
| 2245 | } v; | ||
| 2206 | }; | 2246 | }; |
| 2207 | 2247 | ||
| 2248 | LISP_INLINE Lisp_Object specpdl_symbol (struct specbinding *pdl) | ||
| 2249 | { eassert (pdl->kind >= SPECPDL_LET); return pdl->v.let.symbol; } | ||
| 2250 | |||
| 2251 | LISP_INLINE Lisp_Object specpdl_old_value (struct specbinding *pdl) | ||
| 2252 | { eassert (pdl->kind >= SPECPDL_LET); return pdl->v.let.old_value; } | ||
| 2253 | |||
| 2254 | LISP_INLINE Lisp_Object specpdl_where (struct specbinding *pdl) | ||
| 2255 | { eassert (pdl->kind > SPECPDL_LET); return pdl->v.let.where; } | ||
| 2256 | |||
| 2257 | LISP_INLINE Lisp_Object specpdl_arg (struct specbinding *pdl) | ||
| 2258 | { eassert (pdl->kind == SPECPDL_UNWIND); return pdl->v.unwind.arg; } | ||
| 2259 | |||
| 2260 | LISP_INLINE specbinding_func specpdl_func (struct specbinding *pdl) | ||
| 2261 | { eassert (pdl->kind == SPECPDL_UNWIND); return pdl->v.unwind.func; } | ||
| 2262 | |||
| 2263 | LISP_INLINE Lisp_Object backtrace_function (struct specbinding *pdl) | ||
| 2264 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.function; } | ||
| 2265 | |||
| 2266 | LISP_INLINE ptrdiff_t backtrace_nargs (struct specbinding *pdl) | ||
| 2267 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.nargs; } | ||
| 2268 | |||
| 2269 | LISP_INLINE Lisp_Object *backtrace_args (struct specbinding *pdl) | ||
| 2270 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.args; } | ||
| 2271 | |||
| 2272 | LISP_INLINE bool backtrace_debug_on_exit (struct specbinding *pdl) | ||
| 2273 | { eassert (pdl->kind == SPECPDL_BACKTRACE); return pdl->v.bt.debug_on_exit; } | ||
| 2274 | |||
| 2208 | extern struct specbinding *specpdl; | 2275 | extern struct specbinding *specpdl; |
| 2209 | extern struct specbinding *specpdl_ptr; | 2276 | extern struct specbinding *specpdl_ptr; |
| 2210 | extern ptrdiff_t specpdl_size; | 2277 | extern ptrdiff_t specpdl_size; |
| 2211 | 2278 | ||
| 2212 | #define SPECPDL_INDEX() (specpdl_ptr - specpdl) | 2279 | #define SPECPDL_INDEX() (specpdl_ptr - specpdl) |
| 2213 | 2280 | ||
| 2214 | struct backtrace | ||
| 2215 | { | ||
| 2216 | struct backtrace *next; | ||
| 2217 | Lisp_Object function; | ||
| 2218 | Lisp_Object *args; /* Points to vector of args. */ | ||
| 2219 | ptrdiff_t nargs; /* Length of vector. */ | ||
| 2220 | /* Nonzero means call value of debugger when done with this operation. */ | ||
| 2221 | unsigned int debug_on_exit : 1; | ||
| 2222 | }; | ||
| 2223 | |||
| 2224 | extern struct backtrace *backtrace_list; | ||
| 2225 | |||
| 2226 | /* Everything needed to describe an active condition case. | 2281 | /* Everything needed to describe an active condition case. |
| 2227 | 2282 | ||
| 2228 | Members are volatile if their values need to survive _longjmp when | 2283 | Members are volatile if their values need to survive _longjmp when |
| @@ -2277,9 +2332,10 @@ struct catchtag | |||
| 2277 | Lisp_Object tag; | 2332 | Lisp_Object tag; |
| 2278 | Lisp_Object volatile val; | 2333 | Lisp_Object volatile val; |
| 2279 | struct catchtag *volatile next; | 2334 | struct catchtag *volatile next; |
| 2335 | #if 1 /* GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS, but they're defined later. */ | ||
| 2280 | struct gcpro *gcpro; | 2336 | struct gcpro *gcpro; |
| 2337 | #endif | ||
| 2281 | sys_jmp_buf jmp; | 2338 | sys_jmp_buf jmp; |
| 2282 | struct backtrace *backlist; | ||
| 2283 | struct handler *handlerlist; | 2339 | struct handler *handlerlist; |
| 2284 | EMACS_INT lisp_eval_depth; | 2340 | EMACS_INT lisp_eval_depth; |
| 2285 | ptrdiff_t volatile pdlcount; | 2341 | ptrdiff_t volatile pdlcount; |
| @@ -3337,10 +3393,15 @@ extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); | |||
| 3337 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); | 3393 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); |
| 3338 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); | 3394 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3339 | extern void init_eval (void); | 3395 | extern void init_eval (void); |
| 3340 | #if BYTE_MARK_STACK | ||
| 3341 | extern void mark_backtrace (void); | ||
| 3342 | #endif | ||
| 3343 | extern void syms_of_eval (void); | 3396 | extern void syms_of_eval (void); |
| 3397 | extern void record_in_backtrace (Lisp_Object function, | ||
| 3398 | Lisp_Object *args, ptrdiff_t nargs); | ||
| 3399 | extern void mark_specpdl (void); | ||
| 3400 | extern void get_backtrace (Lisp_Object array); | ||
| 3401 | Lisp_Object backtrace_top_function (void); | ||
| 3402 | extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); | ||
| 3403 | extern bool let_shadows_global_binding_p (Lisp_Object symbol); | ||
| 3404 | |||
| 3344 | 3405 | ||
| 3345 | /* Defined in editfns.c. */ | 3406 | /* Defined in editfns.c. */ |
| 3346 | extern Lisp_Object Qfield; | 3407 | extern Lisp_Object Qfield; |
| @@ -3723,9 +3784,9 @@ extern void syms_of_fontset (void); | |||
| 3723 | extern Lisp_Object Qfont_param; | 3784 | extern Lisp_Object Qfont_param; |
| 3724 | #endif | 3785 | #endif |
| 3725 | 3786 | ||
| 3726 | #ifdef WINDOWSNT | 3787 | /* Defined in gfilenotify.c */ |
| 3727 | /* Defined on w32notify.c. */ | 3788 | #ifdef HAVE_GFILENOTIFY |
| 3728 | extern void syms_of_w32notify (void); | 3789 | extern void syms_of_gfilenotify (void); |
| 3729 | #endif | 3790 | #endif |
| 3730 | 3791 | ||
| 3731 | /* Defined in inotify.c */ | 3792 | /* Defined in inotify.c */ |
| @@ -3733,6 +3794,11 @@ extern void syms_of_w32notify (void); | |||
| 3733 | extern void syms_of_inotify (void); | 3794 | extern void syms_of_inotify (void); |
| 3734 | #endif | 3795 | #endif |
| 3735 | 3796 | ||
| 3797 | #ifdef HAVE_W32NOTIFY | ||
| 3798 | /* Defined on w32notify.c. */ | ||
| 3799 | extern void syms_of_w32notify (void); | ||
| 3800 | #endif | ||
| 3801 | |||
| 3736 | /* Defined in xfaces.c. */ | 3802 | /* Defined in xfaces.c. */ |
| 3737 | extern Lisp_Object Qdefault, Qtool_bar, Qfringe; | 3803 | extern Lisp_Object Qdefault, Qtool_bar, Qfringe; |
| 3738 | extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; | 3804 | extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor; |
diff --git a/src/nsfns.m b/src/nsfns.m index 1170472573e..94339183159 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -287,7 +287,7 @@ static void | |||
| 287 | x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | 287 | x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
| 288 | { | 288 | { |
| 289 | NSColor *col; | 289 | NSColor *col; |
| 290 | CGFloat r, g, b, alpha; | 290 | EmacsCGFloat r, g, b, alpha; |
| 291 | 291 | ||
| 292 | if (ns_lisp_to_color (arg, &col)) | 292 | if (ns_lisp_to_color (arg, &col)) |
| 293 | { | 293 | { |
| @@ -319,7 +319,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 319 | struct face *face; | 319 | struct face *face; |
| 320 | NSColor *col; | 320 | NSColor *col; |
| 321 | NSView *view = FRAME_NS_VIEW (f); | 321 | NSView *view = FRAME_NS_VIEW (f); |
| 322 | CGFloat r, g, b, alpha; | 322 | EmacsCGFloat r, g, b, alpha; |
| 323 | 323 | ||
| 324 | if (ns_lisp_to_color (arg, &col)) | 324 | if (ns_lisp_to_color (arg, &col)) |
| 325 | { | 325 | { |
| @@ -344,7 +344,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 344 | { | 344 | { |
| 345 | [[view window] setBackgroundColor: col]; | 345 | [[view window] setBackgroundColor: col]; |
| 346 | 346 | ||
| 347 | if (alpha != 1.0) | 347 | if (alpha != (EmacsCGFloat) 1.0) |
| 348 | [[view window] setOpaque: NO]; | 348 | [[view window] setOpaque: NO]; |
| 349 | else | 349 | else |
| 350 | [[view window] setOpaque: YES]; | 350 | [[view window] setOpaque: YES]; |
| @@ -714,7 +714,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) | |||
| 714 | } | 714 | } |
| 715 | 715 | ||
| 716 | 716 | ||
| 717 | void | 717 | static void |
| 718 | ns_implicitly_set_icon_type (struct frame *f) | 718 | ns_implicitly_set_icon_type (struct frame *f) |
| 719 | { | 719 | { |
| 720 | Lisp_Object tem; | 720 | Lisp_Object tem; |
| @@ -859,7 +859,7 @@ ns_cursor_type_to_lisp (int arg) | |||
| 859 | } | 859 | } |
| 860 | 860 | ||
| 861 | /* This is the same as the xfns.c definition. */ | 861 | /* This is the same as the xfns.c definition. */ |
| 862 | void | 862 | static void |
| 863 | x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) | 863 | x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) |
| 864 | { | 864 | { |
| 865 | set_frame_cursor_types (f, arg); | 865 | set_frame_cursor_types (f, arg); |
| @@ -1082,7 +1082,6 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1082 | struct ns_display_info *dpyinfo = NULL; | 1082 | struct ns_display_info *dpyinfo = NULL; |
| 1083 | Lisp_Object parent; | 1083 | Lisp_Object parent; |
| 1084 | struct kboard *kb; | 1084 | struct kboard *kb; |
| 1085 | Lisp_Object tfont, tfontsize; | ||
| 1086 | static int desc_ctr = 1; | 1085 | static int desc_ctr = 1; |
| 1087 | 1086 | ||
| 1088 | /* x_get_arg modifies parms. */ | 1087 | /* x_get_arg modifies parms. */ |
| @@ -1189,10 +1188,10 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1189 | { | 1188 | { |
| 1190 | /* use for default font name */ | 1189 | /* use for default font name */ |
| 1191 | id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */ | 1190 | id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */ |
| 1192 | tfontsize = x_default_parameter (f, parms, Qfontsize, | 1191 | x_default_parameter (f, parms, Qfontsize, |
| 1193 | make_number (0 /*(int)[font pointSize]*/), | 1192 | make_number (0 /*(int)[font pointSize]*/), |
| 1194 | "fontSize", "FontSize", RES_TYPE_NUMBER); | 1193 | "fontSize", "FontSize", RES_TYPE_NUMBER); |
| 1195 | tfont = x_default_parameter (f, parms, Qfont, | 1194 | x_default_parameter (f, parms, Qfont, |
| 1196 | build_string ([[font fontName] UTF8String]), | 1195 | build_string ([[font fontName] UTF8String]), |
| 1197 | "font", "Font", RES_TYPE_STRING); | 1196 | "font", "Font", RES_TYPE_STRING); |
| 1198 | } | 1197 | } |
| @@ -1410,6 +1409,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) | |||
| 1410 | { | 1409 | { |
| 1411 | static id fileDelegate = nil; | 1410 | static id fileDelegate = nil; |
| 1412 | BOOL ret; | 1411 | BOOL ret; |
| 1412 | BOOL isSave = NILP (mustmatch) && NILP (dir_only_p); | ||
| 1413 | id panel; | 1413 | id panel; |
| 1414 | Lisp_Object fname; | 1414 | Lisp_Object fname; |
| 1415 | 1415 | ||
| @@ -1431,7 +1431,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) | |||
| 1431 | if ([dirS characterAtIndex: 0] == '~') | 1431 | if ([dirS characterAtIndex: 0] == '~') |
| 1432 | dirS = [dirS stringByExpandingTildeInPath]; | 1432 | dirS = [dirS stringByExpandingTildeInPath]; |
| 1433 | 1433 | ||
| 1434 | panel = NILP (mustmatch) && NILP (dir_only_p) ? | 1434 | panel = isSave ? |
| 1435 | (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel]; | 1435 | (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel]; |
| 1436 | 1436 | ||
| 1437 | [panel setTitle: promptS]; | 1437 | [panel setTitle: promptS]; |
| @@ -1446,7 +1446,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) | |||
| 1446 | [panel setCanChooseDirectories: YES]; | 1446 | [panel setCanChooseDirectories: YES]; |
| 1447 | [panel setCanChooseFiles: NO]; | 1447 | [panel setCanChooseFiles: NO]; |
| 1448 | } | 1448 | } |
| 1449 | else | 1449 | else if (! isSave) |
| 1450 | { | 1450 | { |
| 1451 | /* This is not quite what the documentation says, but it is compatible | 1451 | /* This is not quite what the documentation says, but it is compatible |
| 1452 | with the Gtk+ code. Also, the menu entry says "Open File...". */ | 1452 | with the Gtk+ code. Also, the menu entry says "Open File...". */ |
| @@ -1481,8 +1481,8 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) | |||
| 1481 | 1481 | ||
| 1482 | if (ret) | 1482 | if (ret) |
| 1483 | { | 1483 | { |
| 1484 | NSString *str = [panel getFilename]; | 1484 | NSString *str = ns_filename_from_panel (panel); |
| 1485 | if (! str) str = [panel getDirectory]; | 1485 | if (! str) str = ns_directory_from_panel (panel); |
| 1486 | if (! str) ret = NO; | 1486 | if (! str) ret = NO; |
| 1487 | else fname = build_string ([str UTF8String]); | 1487 | else fname = build_string ([str UTF8String]); |
| 1488 | } | 1488 | } |
| @@ -1909,7 +1909,9 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0, | |||
| 1909 | #else | 1909 | #else |
| 1910 | Lisp_Object ret = Qnil; | 1910 | Lisp_Object ret = Qnil; |
| 1911 | NSMenu *svcs; | 1911 | NSMenu *svcs; |
| 1912 | #ifdef NS_IMPL_COCOA | ||
| 1912 | id delegate; | 1913 | id delegate; |
| 1914 | #endif | ||
| 1913 | 1915 | ||
| 1914 | check_window_system (NULL); | 1916 | check_window_system (NULL); |
| 1915 | svcs = [[NSMenu alloc] initWithTitle: @"Services"]; | 1917 | svcs = [[NSMenu alloc] initWithTitle: @"Services"]; |
| @@ -1992,15 +1994,9 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, | |||
| 1992 | 1994 | ||
| 1993 | CHECK_STRING (str); | 1995 | CHECK_STRING (str); |
| 1994 | utfStr = [NSString stringWithUTF8String: SSDATA (str)]; | 1996 | utfStr = [NSString stringWithUTF8String: SSDATA (str)]; |
| 1995 | if (![utfStr respondsToSelector: | 1997 | #ifdef NS_IMPL_COCOA |
| 1996 | @selector (precomposedStringWithCanonicalMapping)]) | ||
| 1997 | { | ||
| 1998 | message1 | ||
| 1999 | ("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n"); | ||
| 2000 | return Qnil; | ||
| 2001 | } | ||
| 2002 | else | ||
| 2003 | utfStr = [utfStr precomposedStringWithCanonicalMapping]; | 1998 | utfStr = [utfStr precomposedStringWithCanonicalMapping]; |
| 1999 | #endif | ||
| 2004 | return build_string ([utfStr UTF8String]); | 2000 | return build_string ([utfStr UTF8String]); |
| 2005 | } | 2001 | } |
| 2006 | 2002 | ||
| @@ -2155,6 +2151,9 @@ x_set_scroll_bar_default_width (struct frame *f) | |||
| 2155 | } | 2151 | } |
| 2156 | 2152 | ||
| 2157 | 2153 | ||
| 2154 | extern const char *x_get_string_resource (XrmDatabase, char *, char *); | ||
| 2155 | |||
| 2156 | |||
| 2158 | /* terms impl this instead of x-get-resource directly */ | 2157 | /* terms impl this instead of x-get-resource directly */ |
| 2159 | const char * | 2158 | const char * |
| 2160 | x_get_string_resource (XrmDatabase rdb, char *name, char *class) | 2159 | x_get_string_resource (XrmDatabase rdb, char *name, char *class) |
| @@ -2203,13 +2202,6 @@ x_pixel_height (struct frame *f) | |||
| 2203 | } | 2202 | } |
| 2204 | 2203 | ||
| 2205 | 2204 | ||
| 2206 | int | ||
| 2207 | x_screen_planes (struct frame *f) | ||
| 2208 | { | ||
| 2209 | return FRAME_NS_DISPLAY_INFO (f)->n_planes; | ||
| 2210 | } | ||
| 2211 | |||
| 2212 | |||
| 2213 | void | 2205 | void |
| 2214 | x_sync (struct frame *f) | 2206 | x_sync (struct frame *f) |
| 2215 | { | 2207 | { |
| @@ -2242,7 +2234,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, | |||
| 2242 | (Lisp_Object color, Lisp_Object frame) | 2234 | (Lisp_Object color, Lisp_Object frame) |
| 2243 | { | 2235 | { |
| 2244 | NSColor * col; | 2236 | NSColor * col; |
| 2245 | CGFloat red, green, blue, alpha; | 2237 | EmacsCGFloat red, green, blue, alpha; |
| 2246 | 2238 | ||
| 2247 | check_window_system (NULL); | 2239 | check_window_system (NULL); |
| 2248 | CHECK_STRING (color); | 2240 | CHECK_STRING (color); |
| @@ -2434,11 +2426,10 @@ Internal use only, use `display-monitor-attributes-list' instead. */) | |||
| 2434 | struct MonitorInfo *m = &monitors[i]; | 2426 | struct MonitorInfo *m = &monitors[i]; |
| 2435 | NSRect fr = [s frame]; | 2427 | NSRect fr = [s frame]; |
| 2436 | NSRect vfr = [s visibleFrame]; | 2428 | NSRect vfr = [s visibleFrame]; |
| 2437 | NSDictionary *dict = [s deviceDescription]; | ||
| 2438 | NSValue *resval = [dict valueForKey:NSDeviceResolution]; | ||
| 2439 | short y, vy; | 2429 | short y, vy; |
| 2440 | 2430 | ||
| 2441 | #ifdef NS_IMPL_COCOA | 2431 | #ifdef NS_IMPL_COCOA |
| 2432 | NSDictionary *dict = [s deviceDescription]; | ||
| 2442 | NSNumber *nid = [dict objectForKey:@"NSScreenNumber"]; | 2433 | NSNumber *nid = [dict objectForKey:@"NSScreenNumber"]; |
| 2443 | CGDirectDisplayID did = [nid unsignedIntValue]; | 2434 | CGDirectDisplayID did = [nid unsignedIntValue]; |
| 2444 | #endif | 2435 | #endif |
| @@ -2776,14 +2767,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent) | |||
| 2776 | [NSApp stop: self]; | 2767 | [NSApp stop: self]; |
| 2777 | } | 2768 | } |
| 2778 | #endif | 2769 | #endif |
| 2779 | - (NSString *) getFilename | ||
| 2780 | { | ||
| 2781 | return ns_filename_from_panel (self); | ||
| 2782 | } | ||
| 2783 | - (NSString *) getDirectory | ||
| 2784 | { | ||
| 2785 | return ns_directory_from_panel (self); | ||
| 2786 | } | ||
| 2787 | 2770 | ||
| 2788 | - (BOOL)performKeyEquivalent:(NSEvent *)theEvent | 2771 | - (BOOL)performKeyEquivalent:(NSEvent *)theEvent |
| 2789 | { | 2772 | { |
| @@ -2807,8 +2790,8 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent) | |||
| 2807 | [super ok: sender]; | 2790 | [super ok: sender]; |
| 2808 | 2791 | ||
| 2809 | // If not choosing directories, and Open is pressed on a directory, return. | 2792 | // If not choosing directories, and Open is pressed on a directory, return. |
| 2810 | if (! [self canChooseDirectories] && [self getDirectory] && | 2793 | if (! [self canChooseDirectories] && ns_directory_from_panel (self) && |
| 2811 | ! [self getFilename]) | 2794 | ! ns_filename_from_panel (self)) |
| 2812 | return; | 2795 | return; |
| 2813 | 2796 | ||
| 2814 | panelOK = 1; | 2797 | panelOK = 1; |
| @@ -2821,14 +2804,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent) | |||
| 2821 | } | 2804 | } |
| 2822 | 2805 | ||
| 2823 | #endif | 2806 | #endif |
| 2824 | - (NSString *) getFilename | ||
| 2825 | { | ||
| 2826 | return ns_filename_from_panel (self); | ||
| 2827 | } | ||
| 2828 | - (NSString *) getDirectory | ||
| 2829 | { | ||
| 2830 | return ns_directory_from_panel (self); | ||
| 2831 | } | ||
| 2832 | - (BOOL)performKeyEquivalent:(NSEvent *)theEvent | 2807 | - (BOOL)performKeyEquivalent:(NSEvent *)theEvent |
| 2833 | { | 2808 | { |
| 2834 | // NSOpenPanel inherits NSSavePanel, so passing self is OK. | 2809 | // NSOpenPanel inherits NSSavePanel, so passing self is OK. |
diff --git a/src/nsfont.m b/src/nsfont.m index 9ab369d1fcd..709f2cb0d86 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -119,7 +119,7 @@ ns_attribute_fvalue (NSFontDescriptor *fdesc, NSString *trait) | |||
| 119 | { | 119 | { |
| 120 | NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute]; | 120 | NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute]; |
| 121 | NSNumber *val = [tdict objectForKey: trait]; | 121 | NSNumber *val = [tdict objectForKey: trait]; |
| 122 | return val == nil ? 0.0 : [val floatValue]; | 122 | return val == nil ? 0.0F : [val floatValue]; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | 125 | ||
| @@ -138,15 +138,15 @@ ns_spec_to_descriptor (Lisp_Object font_spec) | |||
| 138 | /* add each attr in font_spec to fdAttrs.. */ | 138 | /* add each attr in font_spec to fdAttrs.. */ |
| 139 | n = min (FONT_WEIGHT_NUMERIC (font_spec), 200); | 139 | n = min (FONT_WEIGHT_NUMERIC (font_spec), 200); |
| 140 | if (n != -1 && n != STYLE_REF) | 140 | if (n != -1 && n != STYLE_REF) |
| 141 | [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0] | 141 | [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F] |
| 142 | forKey: NSFontWeightTrait]; | 142 | forKey: NSFontWeightTrait]; |
| 143 | n = min (FONT_SLANT_NUMERIC (font_spec), 200); | 143 | n = min (FONT_SLANT_NUMERIC (font_spec), 200); |
| 144 | if (n != -1 && n != STYLE_REF) | 144 | if (n != -1 && n != STYLE_REF) |
| 145 | [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0] | 145 | [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F] |
| 146 | forKey: NSFontSlantTrait]; | 146 | forKey: NSFontSlantTrait]; |
| 147 | n = min (FONT_WIDTH_NUMERIC (font_spec), 200); | 147 | n = min (FONT_WIDTH_NUMERIC (font_spec), 200); |
| 148 | if (n > -1 && (n > STYLE_REF + 10 || n < STYLE_REF - 10)) | 148 | if (n > -1 && (n > STYLE_REF + 10 || n < STYLE_REF - 10)) |
| 149 | [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0] | 149 | [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F] |
| 150 | forKey: NSFontWidthTrait]; | 150 | forKey: NSFontWidthTrait]; |
| 151 | if ([tdict count] > 0) | 151 | if ([tdict count] > 0) |
| 152 | [fdAttrs setObject: tdict forKey: NSFontTraitsAttribute]; | 152 | [fdAttrs setObject: tdict forKey: NSFontTraitsAttribute]; |
| @@ -240,10 +240,10 @@ ns_fallback_entity (void) | |||
| 240 | 240 | ||
| 241 | 241 | ||
| 242 | /* Utility: get width of a char c in screen font SFONT */ | 242 | /* Utility: get width of a char c in screen font SFONT */ |
| 243 | static float | 243 | static CGFloat |
| 244 | ns_char_width (NSFont *sfont, int c) | 244 | ns_char_width (NSFont *sfont, int c) |
| 245 | { | 245 | { |
| 246 | float w = -1.0; | 246 | CGFloat w = -1.0; |
| 247 | NSString *cstr = [NSString stringWithFormat: @"%c", c]; | 247 | NSString *cstr = [NSString stringWithFormat: @"%c", c]; |
| 248 | 248 | ||
| 249 | #ifdef NS_IMPL_COCOA | 249 | #ifdef NS_IMPL_COCOA |
| @@ -269,7 +269,7 @@ static NSString *ascii_printable; | |||
| 269 | static int | 269 | static int |
| 270 | ns_ascii_average_width (NSFont *sfont) | 270 | ns_ascii_average_width (NSFont *sfont) |
| 271 | { | 271 | { |
| 272 | float w = -1.0; | 272 | CGFloat w = -1.0; |
| 273 | 273 | ||
| 274 | if (!ascii_printable) | 274 | if (!ascii_printable) |
| 275 | { | 275 | { |
| @@ -288,14 +288,14 @@ ns_ascii_average_width (NSFont *sfont) | |||
| 288 | w = [sfont advancementForGlyph: glyph].width; | 288 | w = [sfont advancementForGlyph: glyph].width; |
| 289 | #endif | 289 | #endif |
| 290 | 290 | ||
| 291 | if (w < 0.0) | 291 | if (w < (CGFloat) 0.0) |
| 292 | { | 292 | { |
| 293 | NSDictionary *attrsDictionary = | 293 | NSDictionary *attrsDictionary = |
| 294 | [NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName]; | 294 | [NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName]; |
| 295 | w = [ascii_printable sizeWithAttributes: attrsDictionary].width; | 295 | w = [ascii_printable sizeWithAttributes: attrsDictionary].width; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | return lrint (w / 95.0); | 298 | return lrint (w / (CGFloat) 95.0); |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | 301 | ||
| @@ -323,7 +323,7 @@ ns_charset_covers(NSCharacterSet *set1, NSCharacterSet *set2, float pct) | |||
| 323 | off++; | 323 | off++; |
| 324 | } | 324 | } |
| 325 | //fprintf(stderr, "off = %d\ttot = %d\n", off,tot); | 325 | //fprintf(stderr, "off = %d\ttot = %d\n", off,tot); |
| 326 | return (float)off / tot < 1.0 - pct; | 326 | return (float)off / tot < 1.0F - pct; |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | 329 | ||
| @@ -514,8 +514,8 @@ static NSSet | |||
| 514 | if (ns_charset_covers(fset, charset, pct)) | 514 | if (ns_charset_covers(fset, charset, pct)) |
| 515 | [families addObject: family]; | 515 | [families addObject: family]; |
| 516 | } | 516 | } |
| 517 | pct -= 0.2; | 517 | pct -= 0.2F; |
| 518 | if ([families count] > 0 || pct < 0.05) | 518 | if ([families count] > 0 || pct < 0.05F) |
| 519 | break; | 519 | break; |
| 520 | } | 520 | } |
| 521 | [charset release]; | 521 | [charset release]; |
| @@ -763,9 +763,9 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 763 | family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; | 763 | family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; |
| 764 | /* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that | 764 | /* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that |
| 765 | when setting family in ns_spec_to_descriptor(). */ | 765 | when setting family in ns_spec_to_descriptor(). */ |
| 766 | if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50) | 766 | if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F) |
| 767 | traits |= NSBoldFontMask; | 767 | traits |= NSBoldFontMask; |
| 768 | if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05)) | 768 | if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F)) |
| 769 | traits |= NSItalicFontMask; | 769 | traits |= NSItalicFontMask; |
| 770 | 770 | ||
| 771 | /* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */ | 771 | /* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */ |
| @@ -880,7 +880,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 880 | font_info->max_bounds.width = lrint (font_info->width); | 880 | font_info->max_bounds.width = lrint (font_info->width); |
| 881 | font_info->max_bounds.lbearing = lrint (brect.origin.x); | 881 | font_info->max_bounds.lbearing = lrint (brect.origin.x); |
| 882 | font_info->max_bounds.rbearing = | 882 | font_info->max_bounds.rbearing = |
| 883 | lrint (brect.size.width - font_info->width); | 883 | lrint (brect.size.width - (CGFloat) font_info->width); |
| 884 | 884 | ||
| 885 | #ifdef NS_IMPL_COCOA | 885 | #ifdef NS_IMPL_COCOA |
| 886 | /* set up synthItal and the CG font */ | 886 | /* set up synthItal and the CG font */ |
| @@ -1041,8 +1041,8 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1041 | /* NOTE: focus and clip must be set | 1041 | /* NOTE: focus and clip must be set |
| 1042 | also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */ | 1042 | also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */ |
| 1043 | { | 1043 | { |
| 1044 | static char cbuf[1024]; | 1044 | static unsigned char cbuf[1024]; |
| 1045 | char *c = cbuf; | 1045 | unsigned char *c = cbuf; |
| 1046 | #ifdef NS_IMPL_GNUSTEP | 1046 | #ifdef NS_IMPL_GNUSTEP |
| 1047 | static float advances[1024]; | 1047 | static float advances[1024]; |
| 1048 | float *adv = advances; | 1048 | float *adv = advances; |
| @@ -1209,7 +1209,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1209 | [bgCol set]; | 1209 | [bgCol set]; |
| 1210 | DPSmoveto (context, r.origin.x, r.origin.y); | 1210 | DPSmoveto (context, r.origin.x, r.origin.y); |
| 1211 | /*[context GSSetTextDrawingMode: GSTextFillStroke]; /// not implemented yet */ | 1211 | /*[context GSSetTextDrawingMode: GSTextFillStroke]; /// not implemented yet */ |
| 1212 | DPSxshow (context, cbuf, advances, len); | 1212 | DPSxshow (context, (const char *) cbuf, advances, len); |
| 1213 | DPSstroke (context); | 1213 | DPSstroke (context); |
| 1214 | [col set]; | 1214 | [col set]; |
| 1215 | /*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */ | 1215 | /*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */ |
| @@ -1219,7 +1219,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1219 | 1219 | ||
| 1220 | /* draw with DPSxshow () */ | 1220 | /* draw with DPSxshow () */ |
| 1221 | DPSmoveto (context, r.origin.x, r.origin.y); | 1221 | DPSmoveto (context, r.origin.x, r.origin.y); |
| 1222 | DPSxshow (context, cbuf, advances, len); | 1222 | DPSxshow (context, (const char *) cbuf, advances, len); |
| 1223 | DPSstroke (context); | 1223 | DPSstroke (context); |
| 1224 | 1224 | ||
| 1225 | DPSgrestore (context); | 1225 | DPSgrestore (context); |
| @@ -1407,7 +1407,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) | |||
| 1407 | metrics = font_info->metrics[block]; | 1407 | metrics = font_info->metrics[block]; |
| 1408 | for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++) | 1408 | for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++) |
| 1409 | { | 1409 | { |
| 1410 | float w, lb, rb; | 1410 | CGFloat w, lb, rb; |
| 1411 | NSRect r = [sfont boundingRectForGlyph: g]; | 1411 | NSRect r = [sfont boundingRectForGlyph: g]; |
| 1412 | 1412 | ||
| 1413 | w = max ([sfont advancementForGlyph: g].width, 2.0); | 1413 | w = max ([sfont advancementForGlyph: g].width, 2.0); |
| @@ -1419,7 +1419,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) | |||
| 1419 | if (lb < 0) | 1419 | if (lb < 0) |
| 1420 | metrics->lbearing = round (lb - LCD_SMOOTHING_MARGIN); | 1420 | metrics->lbearing = round (lb - LCD_SMOOTHING_MARGIN); |
| 1421 | if (font_info->ital) | 1421 | if (font_info->ital) |
| 1422 | rb += 0.22 * font_info->height; | 1422 | rb += (CGFloat) (0.22F * font_info->height); |
| 1423 | metrics->rbearing = lrint (w + rb + LCD_SMOOTHING_MARGIN); | 1423 | metrics->rbearing = lrint (w + rb + LCD_SMOOTHING_MARGIN); |
| 1424 | 1424 | ||
| 1425 | metrics->descent = r.origin.y < 0 ? -r.origin.y : 0; | 1425 | metrics->descent = r.origin.y < 0 ? -r.origin.y : 0; |
diff --git a/src/nsimage.m b/src/nsimage.m index 9d21ba8afca..a1703272ad2 100644 --- a/src/nsimage.m +++ b/src/nsimage.m | |||
| @@ -334,7 +334,7 @@ static EmacsImage *ImageList = nil; | |||
| 334 | { | 334 | { |
| 335 | NSSize s = [self size]; | 335 | NSSize s = [self size]; |
| 336 | unsigned char *planes[5]; | 336 | unsigned char *planes[5]; |
| 337 | CGFloat r, g, b, a; | 337 | EmacsCGFloat r, g, b, a; |
| 338 | NSColor *rgbColor; | 338 | NSColor *rgbColor; |
| 339 | 339 | ||
| 340 | if (bmRep == nil || color == nil) | 340 | if (bmRep == nil || color == nil) |
| @@ -437,7 +437,7 @@ static EmacsImage *ImageList = nil; | |||
| 437 | else | 437 | else |
| 438 | { | 438 | { |
| 439 | NSColor *color = [bmRep colorAtX: x y: y]; | 439 | NSColor *color = [bmRep colorAtX: x y: y]; |
| 440 | CGFloat r, g, b, a; | 440 | EmacsCGFloat r, g, b, a; |
| 441 | [color getRed: &r green: &g blue: &b alpha: &a]; | 441 | [color getRed: &r green: &g blue: &b alpha: &a]; |
| 442 | return ((int)(a * 255.0) << 24) | 442 | return ((int)(a * 255.0) << 24) |
| 443 | | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8) | 443 | | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8) |
diff --git a/src/nsmenu.m b/src/nsmenu.m index baa683941f8..1d3d111e9a1 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -45,8 +45,6 @@ Carbon version by Yamamoto Mitsuharu. */ | |||
| 45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
| 46 | #endif | 46 | #endif |
| 47 | 47 | ||
| 48 | #define MenuStagger 10.0 | ||
| 49 | |||
| 50 | #if 0 | 48 | #if 0 |
| 51 | int menu_trace_num = 0; | 49 | int menu_trace_num = 0; |
| 52 | #define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \ | 50 | #define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \ |
| @@ -112,7 +110,7 @@ popup_activated (void) | |||
| 112 | 2) deep_p, submenu = nil: Recompute all submenus. | 110 | 2) deep_p, submenu = nil: Recompute all submenus. |
| 113 | 3) deep_p, submenu = non-nil: Update contents of a single submenu. | 111 | 3) deep_p, submenu = non-nil: Update contents of a single submenu. |
| 114 | -------------------------------------------------------------------------- */ | 112 | -------------------------------------------------------------------------- */ |
| 115 | void | 113 | static void |
| 116 | ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu) | 114 | ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu) |
| 117 | { | 115 | { |
| 118 | NSAutoreleasePool *pool; | 116 | NSAutoreleasePool *pool; |
| @@ -505,6 +503,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) | |||
| 505 | void | 503 | void |
| 506 | x_activate_menubar (struct frame *f) | 504 | x_activate_menubar (struct frame *f) |
| 507 | { | 505 | { |
| 506 | #ifdef NS_IMPL_COCOA | ||
| 508 | NSArray *a = [[NSApp mainMenu] itemArray]; | 507 | NSArray *a = [[NSApp mainMenu] itemArray]; |
| 509 | /* Update each submenu separately so ns_update_menubar doesn't reset | 508 | /* Update each submenu separately so ns_update_menubar doesn't reset |
| 510 | the delegate. */ | 509 | the delegate. */ |
| @@ -521,6 +520,7 @@ x_activate_menubar (struct frame *f) | |||
| 521 | ++i; | 520 | ++i; |
| 522 | } | 521 | } |
| 523 | ns_check_pending_open_menu (); | 522 | ns_check_pending_open_menu (); |
| 523 | #endif | ||
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | 526 | ||
| @@ -740,7 +740,7 @@ extern NSString *NSMenuDidBeginTrackingNotification; | |||
| 740 | [self setSubmenu: submenu forItem: item]; | 740 | [self setSubmenu: submenu forItem: item]; |
| 741 | [submenu fillWithWidgetValue: wv->contents]; | 741 | [submenu fillWithWidgetValue: wv->contents]; |
| 742 | [submenu release]; | 742 | [submenu release]; |
| 743 | [item setAction: nil]; | 743 | [item setAction: (SEL)nil]; |
| 744 | } | 744 | } |
| 745 | } | 745 | } |
| 746 | 746 | ||
| @@ -757,7 +757,7 @@ extern NSString *NSMenuDidBeginTrackingNotification; | |||
| 757 | { | 757 | { |
| 758 | NSString *titleStr = [NSString stringWithUTF8String: title]; | 758 | NSString *titleStr = [NSString stringWithUTF8String: title]; |
| 759 | NSMenuItem *item = [self addItemWithTitle: titleStr | 759 | NSMenuItem *item = [self addItemWithTitle: titleStr |
| 760 | action: nil /*@selector (menuDown:) */ | 760 | action: (SEL)nil /*@selector (menuDown:) */ |
| 761 | keyEquivalent: @""]; | 761 | keyEquivalent: @""]; |
| 762 | EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr frame: f]; | 762 | EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr frame: f]; |
| 763 | [self setSubmenu: submenu forItem: item]; | 763 | [self setSubmenu: submenu forItem: item]; |
| @@ -1045,13 +1045,18 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1045 | Update toolbar contents | 1045 | Update toolbar contents |
| 1046 | -------------------------------------------------------------------------- */ | 1046 | -------------------------------------------------------------------------- */ |
| 1047 | { | 1047 | { |
| 1048 | int i; | 1048 | int i, k = 0; |
| 1049 | EmacsView *view = FRAME_NS_VIEW (f); | 1049 | EmacsView *view = FRAME_NS_VIEW (f); |
| 1050 | NSWindow *window = [view window]; | 1050 | NSWindow *window = [view window]; |
| 1051 | EmacsToolbar *toolbar = [view toolbar]; | 1051 | EmacsToolbar *toolbar = [view toolbar]; |
| 1052 | 1052 | ||
| 1053 | block_input (); | 1053 | block_input (); |
| 1054 | |||
| 1055 | #ifdef NS_IMPL_COCOA | ||
| 1054 | [toolbar clearActive]; | 1056 | [toolbar clearActive]; |
| 1057 | #else | ||
| 1058 | [toolbar clearAll]; | ||
| 1059 | #endif | ||
| 1055 | 1060 | ||
| 1056 | /* update EmacsToolbar as in GtkUtils, build items list */ | 1061 | /* update EmacsToolbar as in GtkUtils, build items list */ |
| 1057 | for (i = 0; i < f->n_tool_bar_items; ++i) | 1062 | for (i = 0; i < f->n_tool_bar_items; ++i) |
| @@ -1067,6 +1072,15 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1067 | Lisp_Object helpObj; | 1072 | Lisp_Object helpObj; |
| 1068 | const char *helpText; | 1073 | const char *helpText; |
| 1069 | 1074 | ||
| 1075 | /* Check if this is a separator. */ | ||
| 1076 | if (EQ (TOOLPROP (TOOL_BAR_ITEM_TYPE), Qt)) | ||
| 1077 | { | ||
| 1078 | /* Skip separators. Newer OSX don't show them, and on GNUStep they | ||
| 1079 | are wide as a button, thus overflowing the toolbar most of | ||
| 1080 | the time. */ | ||
| 1081 | continue; | ||
| 1082 | } | ||
| 1083 | |||
| 1070 | /* If image is a vector, choose the image according to the | 1084 | /* If image is a vector, choose the image according to the |
| 1071 | button state. */ | 1085 | button state. */ |
| 1072 | image = TOOLPROP (TOOL_BAR_ITEM_IMAGES); | 1086 | image = TOOLPROP (TOOL_BAR_ITEM_IMAGES); |
| @@ -1103,7 +1117,10 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1103 | continue; | 1117 | continue; |
| 1104 | } | 1118 | } |
| 1105 | 1119 | ||
| 1106 | [toolbar addDisplayItemWithImage: img->pixmap idx: i helpText: helpText | 1120 | [toolbar addDisplayItemWithImage: img->pixmap |
| 1121 | idx: k++ | ||
| 1122 | tag: i | ||
| 1123 | helpText: helpText | ||
| 1107 | enabled: enabled_p]; | 1124 | enabled: enabled_p]; |
| 1108 | #undef TOOLPROP | 1125 | #undef TOOLPROP |
| 1109 | } | 1126 | } |
| @@ -1111,6 +1128,7 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1111 | if (![toolbar isVisible]) | 1128 | if (![toolbar isVisible]) |
| 1112 | [toolbar setVisible: YES]; | 1129 | [toolbar setVisible: YES]; |
| 1113 | 1130 | ||
| 1131 | #ifdef NS_IMPL_COCOA | ||
| 1114 | if ([toolbar changed]) | 1132 | if ([toolbar changed]) |
| 1115 | { | 1133 | { |
| 1116 | /* inform app that toolbar has changed */ | 1134 | /* inform app that toolbar has changed */ |
| @@ -1132,6 +1150,7 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1132 | [toolbar setConfigurationFromDictionary: newDict]; | 1150 | [toolbar setConfigurationFromDictionary: newDict]; |
| 1133 | [newDict release]; | 1151 | [newDict release]; |
| 1134 | } | 1152 | } |
| 1153 | #endif | ||
| 1135 | 1154 | ||
| 1136 | FRAME_TOOLBAR_HEIGHT (f) = | 1155 | FRAME_TOOLBAR_HEIGHT (f) = |
| 1137 | NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) | 1156 | NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) |
| @@ -1159,6 +1178,7 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1159 | [self setDelegate: self]; | 1178 | [self setDelegate: self]; |
| 1160 | identifierToItem = [[NSMutableDictionary alloc] initWithCapacity: 10]; | 1179 | identifierToItem = [[NSMutableDictionary alloc] initWithCapacity: 10]; |
| 1161 | activeIdentifiers = [[NSMutableArray alloc] initWithCapacity: 8]; | 1180 | activeIdentifiers = [[NSMutableArray alloc] initWithCapacity: 8]; |
| 1181 | prevIdentifiers = nil; | ||
| 1162 | prevEnablement = enablement = 0L; | 1182 | prevEnablement = enablement = 0L; |
| 1163 | return self; | 1183 | return self; |
| 1164 | } | 1184 | } |
| @@ -1180,18 +1200,29 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1180 | enablement = 0L; | 1200 | enablement = 0L; |
| 1181 | } | 1201 | } |
| 1182 | 1202 | ||
| 1203 | - (void) clearAll | ||
| 1204 | { | ||
| 1205 | [self clearActive]; | ||
| 1206 | while ([[self items] count] > 0) | ||
| 1207 | [self removeItemAtIndex: 0]; | ||
| 1208 | } | ||
| 1209 | |||
| 1183 | - (BOOL) changed | 1210 | - (BOOL) changed |
| 1184 | { | 1211 | { |
| 1185 | return [activeIdentifiers isEqualToArray: prevIdentifiers] && | 1212 | return [activeIdentifiers isEqualToArray: prevIdentifiers] && |
| 1186 | enablement == prevEnablement ? NO : YES; | 1213 | enablement == prevEnablement ? NO : YES; |
| 1187 | } | 1214 | } |
| 1188 | 1215 | ||
| 1189 | - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx | 1216 | - (void) addDisplayItemWithImage: (EmacsImage *)img |
| 1190 | helpText: (const char *)help enabled: (BOOL)enabled | 1217 | idx: (int)idx |
| 1218 | tag: (int)tag | ||
| 1219 | helpText: (const char *)help | ||
| 1220 | enabled: (BOOL)enabled | ||
| 1191 | { | 1221 | { |
| 1192 | /* 1) come up w/identifier */ | 1222 | /* 1) come up w/identifier */ |
| 1193 | NSString *identifier | 1223 | NSString *identifier |
| 1194 | = [NSString stringWithFormat: @"%u", [img hash]]; | 1224 | = [NSString stringWithFormat: @"%u", [img hash]]; |
| 1225 | [activeIdentifiers addObject: identifier]; | ||
| 1195 | 1226 | ||
| 1196 | /* 2) create / reuse item */ | 1227 | /* 2) create / reuse item */ |
| 1197 | NSToolbarItem *item = [identifierToItem objectForKey: identifier]; | 1228 | NSToolbarItem *item = [identifierToItem objectForKey: identifier]; |
| @@ -1203,20 +1234,25 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1203 | [item setToolTip: [NSString stringWithUTF8String: help]]; | 1234 | [item setToolTip: [NSString stringWithUTF8String: help]]; |
| 1204 | [item setTarget: emacsView]; | 1235 | [item setTarget: emacsView]; |
| 1205 | [item setAction: @selector (toolbarClicked:)]; | 1236 | [item setAction: @selector (toolbarClicked:)]; |
| 1237 | [identifierToItem setObject: item forKey: identifier]; | ||
| 1206 | } | 1238 | } |
| 1207 | 1239 | ||
| 1208 | [item setTag: idx]; | 1240 | #ifdef NS_IMPL_GNUSTEP |
| 1241 | [self insertItemWithItemIdentifier: identifier atIndex: idx]; | ||
| 1242 | #endif | ||
| 1243 | |||
| 1244 | [item setTag: tag]; | ||
| 1209 | [item setEnabled: enabled]; | 1245 | [item setEnabled: enabled]; |
| 1210 | 1246 | ||
| 1211 | /* 3) update state */ | 1247 | /* 3) update state */ |
| 1212 | [identifierToItem setObject: item forKey: identifier]; | ||
| 1213 | [activeIdentifiers addObject: identifier]; | ||
| 1214 | enablement = (enablement << 1) | (enabled == YES); | 1248 | enablement = (enablement << 1) | (enabled == YES); |
| 1215 | } | 1249 | } |
| 1216 | 1250 | ||
| 1217 | /* This overrides super's implementation, which automatically sets | 1251 | /* This overrides super's implementation, which automatically sets |
| 1218 | all items to enabled state (for some reason). */ | 1252 | all items to enabled state (for some reason). */ |
| 1219 | - (void)validateVisibleItems { } | 1253 | - (void)validateVisibleItems |
| 1254 | { | ||
| 1255 | } | ||
| 1220 | 1256 | ||
| 1221 | 1257 | ||
| 1222 | /* delegate methods */ | 1258 | /* delegate methods */ |
| @@ -1239,7 +1275,8 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1239 | - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar | 1275 | - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar |
| 1240 | { | 1276 | { |
| 1241 | /* return entire set... */ | 1277 | /* return entire set... */ |
| 1242 | return [identifierToItem allKeys]; | 1278 | return activeIdentifiers; |
| 1279 | //return [identifierToItem allKeys]; | ||
| 1243 | } | 1280 | } |
| 1244 | 1281 | ||
| 1245 | /* optional and unneeded */ | 1282 | /* optional and unneeded */ |
| @@ -1531,7 +1568,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1531 | [img autorelease]; | 1568 | [img autorelease]; |
| 1532 | [imgView autorelease]; | 1569 | [imgView autorelease]; |
| 1533 | 1570 | ||
| 1534 | aStyle = NSTitledWindowMask; | 1571 | aStyle = NSTitledWindowMask|NSClosableWindowMask|NSUtilityWindowMask; |
| 1535 | flag = YES; | 1572 | flag = YES; |
| 1536 | rows = 0; | 1573 | rows = 0; |
| 1537 | cols = 1; | 1574 | cols = 1; |
| @@ -1599,9 +1636,6 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1599 | [self setOneShot: YES]; | 1636 | [self setOneShot: YES]; |
| 1600 | [self setReleasedWhenClosed: YES]; | 1637 | [self setReleasedWhenClosed: YES]; |
| 1601 | [self setHidesOnDeactivate: YES]; | 1638 | [self setHidesOnDeactivate: YES]; |
| 1602 | [self setStyleMask: | ||
| 1603 | NSTitledWindowMask|NSClosableWindowMask|NSUtilityWindowMask]; | ||
| 1604 | |||
| 1605 | return self; | 1639 | return self; |
| 1606 | } | 1640 | } |
| 1607 | 1641 | ||
diff --git a/src/nsselect.m b/src/nsselect.m index bb9eacd23cd..6053ee9ceb2 100644 --- a/src/nsselect.m +++ b/src/nsselect.m | |||
| @@ -182,7 +182,7 @@ ns_get_local_selection (Lisp_Object selection_name, | |||
| 182 | Lisp_Object target_type) | 182 | Lisp_Object target_type) |
| 183 | { | 183 | { |
| 184 | Lisp_Object local_value; | 184 | Lisp_Object local_value; |
| 185 | Lisp_Object handler_fn, value, type, check; | 185 | Lisp_Object handler_fn, value, check; |
| 186 | ptrdiff_t count; | 186 | ptrdiff_t count; |
| 187 | 187 | ||
| 188 | local_value = assq_no_quit (selection_name, Vselection_alist); | 188 | local_value = assq_no_quit (selection_name, Vselection_alist); |
| @@ -203,7 +203,6 @@ ns_get_local_selection (Lisp_Object selection_name, | |||
| 203 | check = value; | 203 | check = value; |
| 204 | if (CONSP (value) && SYMBOLP (XCAR (value))) | 204 | if (CONSP (value) && SYMBOLP (XCAR (value))) |
| 205 | { | 205 | { |
| 206 | type = XCAR (value); | ||
| 207 | check = XCDR (value); | 206 | check = XCDR (value); |
| 208 | } | 207 | } |
| 209 | 208 | ||
diff --git a/src/nsterm.h b/src/nsterm.h index 07cfc2e022e..fd8c9baa3e4 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -51,6 +51,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 51 | 51 | ||
| 52 | #ifdef __OBJC__ | 52 | #ifdef __OBJC__ |
| 53 | 53 | ||
| 54 | /* CGFloat on GNUStep may be 4 or 8 byte, but functions expect float* for some | ||
| 55 | versions. | ||
| 56 | On Cocoa, functions expect CGFloat*. Make compatible type. */ | ||
| 57 | #if defined (NS_IMPL_COCOA) || GNUSTEP_GUI_MAJOR_VERSION > 0 || \ | ||
| 58 | GNUSTEP_GUI_MINOR_VERSION >= 22 | ||
| 59 | typedef CGFloat EmacsCGFloat; | ||
| 60 | #else | ||
| 61 | typedef float EmacsCGFloat; | ||
| 62 | #endif | ||
| 63 | |||
| 54 | /* ========================================================================== | 64 | /* ========================================================================== |
| 55 | 65 | ||
| 56 | The Emacs application | 66 | The Emacs application |
| @@ -60,6 +70,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 60 | /* We override sendEvent: as a means to stop/start the event loop */ | 70 | /* We override sendEvent: as a means to stop/start the event loop */ |
| 61 | @interface EmacsApp : NSApplication | 71 | @interface EmacsApp : NSApplication |
| 62 | { | 72 | { |
| 73 | #ifdef NS_IMPL_GNUSTEP | ||
| 74 | @public | ||
| 75 | int nextappdefined; | ||
| 76 | #endif | ||
| 63 | } | 77 | } |
| 64 | - (void)logNotification: (NSNotification *)notification; | 78 | - (void)logNotification: (NSNotification *)notification; |
| 65 | - (void)sendEvent: (NSEvent *)theEvent; | 79 | - (void)sendEvent: (NSEvent *)theEvent; |
| @@ -68,8 +82,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 68 | - (void)fd_handler: (id)unused; | 82 | - (void)fd_handler: (id)unused; |
| 69 | - (void)timeout_handler: (NSTimer *)timedEntry; | 83 | - (void)timeout_handler: (NSTimer *)timedEntry; |
| 70 | - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg; | 84 | - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg; |
| 85 | #ifdef NS_IMPL_GNUSTEP | ||
| 86 | - (void)sendFromMainThread:(id)unused; | ||
| 87 | #endif | ||
| 71 | @end | 88 | @end |
| 72 | 89 | ||
| 90 | #ifdef NS_IMPL_GNUSTEP | ||
| 91 | /* Dummy class to get rid of startup warnings. */ | ||
| 92 | @interface EmacsDocument : NSDocument | ||
| 93 | { | ||
| 94 | } | ||
| 95 | @end | ||
| 96 | #endif | ||
| 73 | 97 | ||
| 74 | /* ========================================================================== | 98 | /* ========================================================================== |
| 75 | 99 | ||
| @@ -128,8 +152,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 128 | #endif | 152 | #endif |
| 129 | 153 | ||
| 130 | #ifdef NS_IMPL_GNUSTEP | 154 | #ifdef NS_IMPL_GNUSTEP |
| 131 | /* Not declared, but useful. */ | 155 | - (void)windowDidMove: (id)sender; |
| 132 | - (void) unlockFocusNeedsFlush: (BOOL)needs; | ||
| 133 | #endif | 156 | #endif |
| 134 | @end | 157 | @end |
| 135 | 158 | ||
| @@ -199,10 +222,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 199 | } | 222 | } |
| 200 | - initForView: (EmacsView *)view withIdentifier: (NSString *)identifier; | 223 | - initForView: (EmacsView *)view withIdentifier: (NSString *)identifier; |
| 201 | - (void) clearActive; | 224 | - (void) clearActive; |
| 225 | - (void) clearAll; | ||
| 202 | - (BOOL) changed; | 226 | - (BOOL) changed; |
| 203 | - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx | 227 | - (void) addDisplayItemWithImage: (EmacsImage *)img |
| 228 | idx: (int)idx | ||
| 229 | tag: (int)tag | ||
| 204 | helpText: (const char *)help | 230 | helpText: (const char *)help |
| 205 | enabled: (BOOL)enabled; | 231 | enabled: (BOOL)enabled; |
| 232 | |||
| 206 | /* delegate methods */ | 233 | /* delegate methods */ |
| 207 | - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar | 234 | - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar |
| 208 | itemForItemIdentifier: (NSString *)itemIdentifier | 235 | itemForItemIdentifier: (NSString *)itemIdentifier |
| @@ -267,14 +294,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 267 | @interface EmacsSavePanel : NSSavePanel | 294 | @interface EmacsSavePanel : NSSavePanel |
| 268 | { | 295 | { |
| 269 | } | 296 | } |
| 270 | - (NSString *) getFilename; | ||
| 271 | - (NSString *) getDirectory; | ||
| 272 | @end | 297 | @end |
| 273 | @interface EmacsOpenPanel : NSOpenPanel | 298 | @interface EmacsOpenPanel : NSOpenPanel |
| 274 | { | 299 | { |
| 275 | } | 300 | } |
| 276 | - (NSString *) getFilename; | ||
| 277 | - (NSString *) getDirectory; | ||
| 278 | @end | 301 | @end |
| 279 | 302 | ||
| 280 | @interface EmacsFileDelegate : NSObject | 303 | @interface EmacsFileDelegate : NSObject |
| @@ -335,7 +358,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 335 | NSResponder *prevResponder; | 358 | NSResponder *prevResponder; |
| 336 | 359 | ||
| 337 | /* offset to the bottom of knob of last mouse down */ | 360 | /* offset to the bottom of knob of last mouse down */ |
| 338 | float last_mouse_offset; | 361 | CGFloat last_mouse_offset; |
| 339 | float min_portion; | 362 | float min_portion; |
| 340 | int pixel_height; | 363 | int pixel_height; |
| 341 | int last_hit_part; | 364 | int last_hit_part; |
| @@ -789,9 +812,9 @@ extern int ns_lisp_to_color (Lisp_Object color, NSColor **col); | |||
| 789 | extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f); | 812 | extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f); |
| 790 | extern unsigned long ns_index_color (NSColor *color, struct frame *f); | 813 | extern unsigned long ns_index_color (NSColor *color, struct frame *f); |
| 791 | extern void ns_free_indexed_color (unsigned long idx, struct frame *f); | 814 | extern void ns_free_indexed_color (unsigned long idx, struct frame *f); |
| 792 | extern const char *ns_get_pending_menu_title (); | 815 | extern const char *ns_get_pending_menu_title (void); |
| 793 | extern void ns_check_menu_open (NSMenu *menu); | 816 | extern void ns_check_menu_open (NSMenu *menu); |
| 794 | extern void ns_check_pending_open_menu (); | 817 | extern void ns_check_pending_open_menu (void); |
| 795 | #endif | 818 | #endif |
| 796 | 819 | ||
| 797 | /* C access to ObjC functionality */ | 820 | /* C access to ObjC functionality */ |
| @@ -840,6 +863,7 @@ extern int x_display_pixel_height (struct ns_display_info *); | |||
| 840 | extern int x_display_pixel_width (struct ns_display_info *); | 863 | extern int x_display_pixel_width (struct ns_display_info *); |
| 841 | 864 | ||
| 842 | /* This in nsterm.m */ | 865 | /* This in nsterm.m */ |
| 866 | extern void x_destroy_window (struct frame *f); | ||
| 843 | extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, | 867 | extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, |
| 844 | fd_set *exceptfds, EMACS_TIME *timeout, | 868 | fd_set *exceptfds, EMACS_TIME *timeout, |
| 845 | sigset_t *sigmask); | 869 | sigset_t *sigmask); |
diff --git a/src/nsterm.m b/src/nsterm.m index e882f00e977..93f693fe55e 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -60,6 +60,10 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 60 | #include "buffer.h" | 60 | #include "buffer.h" |
| 61 | #include "font.h" | 61 | #include "font.h" |
| 62 | 62 | ||
| 63 | #ifdef NS_IMPL_GNUSTEP | ||
| 64 | #include "process.h" | ||
| 65 | #endif | ||
| 66 | |||
| 63 | /* call tracing */ | 67 | /* call tracing */ |
| 64 | #if 0 | 68 | #if 0 |
| 65 | int term_trace_num = 0; | 69 | int term_trace_num = 0; |
| @@ -196,7 +200,9 @@ static BOOL gsaved = NO; | |||
| 196 | static BOOL ns_fake_keydown = NO; | 200 | static BOOL ns_fake_keydown = NO; |
| 197 | int ns_tmp_flags; /* FIXME */ | 201 | int ns_tmp_flags; /* FIXME */ |
| 198 | struct nsfont_info *ns_tmp_font; /* FIXME */ | 202 | struct nsfont_info *ns_tmp_font; /* FIXME */ |
| 203 | #ifdef NS_IMPL_COCOA | ||
| 199 | static BOOL ns_menu_bar_is_hidden = NO; | 204 | static BOOL ns_menu_bar_is_hidden = NO; |
| 205 | #endif | ||
| 200 | /*static int debug_lock = 0; */ | 206 | /*static int debug_lock = 0; */ |
| 201 | 207 | ||
| 202 | /* event loop */ | 208 | /* event loop */ |
| @@ -228,6 +234,7 @@ static struct { | |||
| 228 | NULL, 0, 0 | 234 | NULL, 0, 0 |
| 229 | }; | 235 | }; |
| 230 | 236 | ||
| 237 | #ifdef NS_IMPL_COCOA | ||
| 231 | /* | 238 | /* |
| 232 | * State for pending menu activation: | 239 | * State for pending menu activation: |
| 233 | * MENU_NONE Normal state | 240 | * MENU_NONE Normal state |
| @@ -246,6 +253,7 @@ static CGPoint menu_mouse_point; | |||
| 246 | 253 | ||
| 247 | /* Title for the menu to open. */ | 254 | /* Title for the menu to open. */ |
| 248 | static char *menu_pending_title = 0; | 255 | static char *menu_pending_title = 0; |
| 256 | #endif | ||
| 249 | 257 | ||
| 250 | /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ | 258 | /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ |
| 251 | #define NS_FUNCTION_KEY_MASK 0x800000 | 259 | #define NS_FUNCTION_KEY_MASK 0x800000 |
| @@ -317,8 +325,6 @@ static char *menu_pending_title = 0; | |||
| 317 | ns_send_appdefined (-1); \ | 325 | ns_send_appdefined (-1); \ |
| 318 | } | 326 | } |
| 319 | 327 | ||
| 320 | void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object); | ||
| 321 | |||
| 322 | /* TODO: get rid of need for these forward declarations */ | 328 | /* TODO: get rid of need for these forward declarations */ |
| 323 | static void ns_condemn_scroll_bars (struct frame *f); | 329 | static void ns_condemn_scroll_bars (struct frame *f); |
| 324 | static void ns_judge_scroll_bars (struct frame *f); | 330 | static void ns_judge_scroll_bars (struct frame *f); |
| @@ -670,8 +676,6 @@ ns_update_begin (struct frame *f) | |||
| 670 | -------------------------------------------------------------------------- */ | 676 | -------------------------------------------------------------------------- */ |
| 671 | { | 677 | { |
| 672 | NSView *view = FRAME_NS_VIEW (f); | 678 | NSView *view = FRAME_NS_VIEW (f); |
| 673 | NSRect r = [view frame]; | ||
| 674 | NSBezierPath *bp; | ||
| 675 | NSTRACE (ns_update_begin); | 679 | NSTRACE (ns_update_begin); |
| 676 | 680 | ||
| 677 | ns_update_auto_hide_menu_bar (); | 681 | ns_update_auto_hide_menu_bar (); |
| @@ -683,9 +687,15 @@ ns_update_begin (struct frame *f) | |||
| 683 | is for the minibuffer. But the display engine may draw more because | 687 | is for the minibuffer. But the display engine may draw more because |
| 684 | we have set the frame as garbaged. So reset clip path to the whole | 688 | we have set the frame as garbaged. So reset clip path to the whole |
| 685 | view. */ | 689 | view. */ |
| 690 | #ifdef NS_IMPL_COCOA | ||
| 691 | { | ||
| 692 | NSBezierPath *bp; | ||
| 693 | NSRect r = [view frame]; | ||
| 686 | bp = [[NSBezierPath bezierPathWithRect: r] retain]; | 694 | bp = [[NSBezierPath bezierPathWithRect: r] retain]; |
| 687 | [bp setClip]; | 695 | [bp setClip]; |
| 688 | [bp release]; | 696 | [bp release]; |
| 697 | } | ||
| 698 | #endif | ||
| 689 | 699 | ||
| 690 | #ifdef NS_IMPL_GNUSTEP | 700 | #ifdef NS_IMPL_GNUSTEP |
| 691 | uRect = NSMakeRect (0, 0, 0, 0); | 701 | uRect = NSMakeRect (0, 0, 0, 0); |
| @@ -772,20 +782,13 @@ ns_update_end (struct frame *f) | |||
| 772 | external (RIF) call; for whole frame, called after update_window_end | 782 | external (RIF) call; for whole frame, called after update_window_end |
| 773 | -------------------------------------------------------------------------- */ | 783 | -------------------------------------------------------------------------- */ |
| 774 | { | 784 | { |
| 775 | NSView *view = FRAME_NS_VIEW (f); | 785 | EmacsView *view = FRAME_NS_VIEW (f); |
| 776 | 786 | ||
| 777 | /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */ | 787 | /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */ |
| 778 | MOUSE_HL_INFO (f)->mouse_face_defer = 0; | 788 | MOUSE_HL_INFO (f)->mouse_face_defer = 0; |
| 779 | 789 | ||
| 780 | block_input (); | 790 | block_input (); |
| 781 | 791 | ||
| 782 | #ifdef NS_IMPL_GNUSTEP | ||
| 783 | /* trigger flush only in the rectangle we tracked as being drawn */ | ||
| 784 | [view unlockFocusNeedsFlush: NO]; | ||
| 785 | /*fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", uRect.origin.x, uRect.origin.y, uRect.size.width, uRect.size.height); */ | ||
| 786 | [view lockFocusInRect: uRect]; | ||
| 787 | #endif | ||
| 788 | |||
| 789 | [view unlockFocus]; | 792 | [view unlockFocus]; |
| 790 | [[view window] flushWindow]; | 793 | [[view window] flushWindow]; |
| 791 | 794 | ||
| @@ -818,13 +821,6 @@ ns_focus (struct frame *f, NSRect *r, int n) | |||
| 818 | -------------------------------------------------------------------------- */ | 821 | -------------------------------------------------------------------------- */ |
| 819 | { | 822 | { |
| 820 | // NSTRACE (ns_focus); | 823 | // NSTRACE (ns_focus); |
| 821 | #ifdef NS_IMPL_GNUSTEP | ||
| 822 | NSRect u; | ||
| 823 | if (n == 2) | ||
| 824 | u = NSUnionRect (r[0], r[1]); | ||
| 825 | else if (r) | ||
| 826 | u = *r; | ||
| 827 | #endif | ||
| 828 | /* static int c =0; | 824 | /* static int c =0; |
| 829 | fprintf (stderr, "focus: %d", c++); | 825 | fprintf (stderr, "focus: %d", c++); |
| 830 | if (r) fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", r->origin.x, r->origin.y, r->size.width, r->size.height); | 826 | if (r) fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", r->origin.x, r->origin.y, r->size.width, r->size.height); |
| @@ -843,33 +839,11 @@ ns_focus (struct frame *f, NSRect *r, int n) | |||
| 843 | } | 839 | } |
| 844 | 840 | ||
| 845 | if (view) | 841 | if (view) |
| 846 | #ifdef NS_IMPL_GNUSTEP | ||
| 847 | r ? [view lockFocusInRect: u] : [view lockFocus]; | ||
| 848 | #else | ||
| 849 | [view lockFocus]; | 842 | [view lockFocus]; |
| 850 | #endif | ||
| 851 | focus_view = view; | 843 | focus_view = view; |
| 852 | /*if (view) debug_lock++; */ | 844 | /*if (view) debug_lock++; */ |
| 853 | } | 845 | } |
| 854 | #ifdef NS_IMPL_GNUSTEP | ||
| 855 | else | ||
| 856 | { | ||
| 857 | /* more than one rect being drawn into */ | ||
| 858 | if (view && r) | ||
| 859 | { | ||
| 860 | [view unlockFocus]; /* add prev rect to redraw list */ | ||
| 861 | [view lockFocusInRect: u]; /* focus for draw in new rect */ | ||
| 862 | } | ||
| 863 | } | ||
| 864 | #endif | ||
| 865 | } | 846 | } |
| 866 | #ifdef NS_IMPL_GNUSTEP | ||
| 867 | else | ||
| 868 | { | ||
| 869 | /* in batch mode, but in GNUstep must still track rectangles explicitly */ | ||
| 870 | uRect = (r ? NSUnionRect (uRect, u) : [FRAME_NS_VIEW (f) visibleRect]); | ||
| 871 | } | ||
| 872 | #endif | ||
| 873 | 847 | ||
| 874 | /* clipping */ | 848 | /* clipping */ |
| 875 | if (r) | 849 | if (r) |
| @@ -1317,12 +1291,17 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) | |||
| 1317 | 1291 | ||
| 1318 | /* If we have a toolbar, take its height into account. */ | 1292 | /* If we have a toolbar, take its height into account. */ |
| 1319 | if (tb && ! [view isFullscreen]) | 1293 | if (tb && ! [view isFullscreen]) |
| 1294 | { | ||
| 1320 | /* NOTE: previously this would generate wrong result if toolbar not | 1295 | /* NOTE: previously this would generate wrong result if toolbar not |
| 1321 | yet displayed and fixing toolbar_height=32 helped, but | 1296 | yet displayed and fixing toolbar_height=32 helped, but |
| 1322 | now (200903) seems no longer needed */ | 1297 | now (200903) seems no longer needed */ |
| 1323 | FRAME_TOOLBAR_HEIGHT (f) = | 1298 | FRAME_TOOLBAR_HEIGHT (f) = |
| 1324 | NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) | 1299 | NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) |
| 1325 | - FRAME_NS_TITLEBAR_HEIGHT (f); | 1300 | - FRAME_NS_TITLEBAR_HEIGHT (f); |
| 1301 | #ifdef NS_IMPL_GNUSTEP | ||
| 1302 | FRAME_TOOLBAR_HEIGHT (f) -= 3; | ||
| 1303 | #endif | ||
| 1304 | } | ||
| 1326 | else | 1305 | else |
| 1327 | FRAME_TOOLBAR_HEIGHT (f) = 0; | 1306 | FRAME_TOOLBAR_HEIGHT (f) = 0; |
| 1328 | 1307 | ||
| @@ -1548,7 +1527,7 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1548 | } | 1527 | } |
| 1549 | } | 1528 | } |
| 1550 | 1529 | ||
| 1551 | if (r >= 0.0) | 1530 | if (r >= 0.0F) |
| 1552 | { | 1531 | { |
| 1553 | *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0]; | 1532 | *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0]; |
| 1554 | unblock_input (); | 1533 | unblock_input (); |
| @@ -1609,7 +1588,7 @@ ns_color_to_lisp (NSColor *col) | |||
| 1609 | Convert a color to a lisp string with the RGB equivalent | 1588 | Convert a color to a lisp string with the RGB equivalent |
| 1610 | -------------------------------------------------------------------------- */ | 1589 | -------------------------------------------------------------------------- */ |
| 1611 | { | 1590 | { |
| 1612 | CGFloat red, green, blue, alpha, gray; | 1591 | EmacsCGFloat red, green, blue, alpha, gray; |
| 1613 | char buf[1024]; | 1592 | char buf[1024]; |
| 1614 | const char *str; | 1593 | const char *str; |
| 1615 | NSTRACE (ns_color_to_lisp); | 1594 | NSTRACE (ns_color_to_lisp); |
| @@ -1651,7 +1630,7 @@ ns_query_color(void *col, XColor *color_def, int setPixel) | |||
| 1651 | and set color_def pixel to the resulting index. | 1630 | and set color_def pixel to the resulting index. |
| 1652 | -------------------------------------------------------------------------- */ | 1631 | -------------------------------------------------------------------------- */ |
| 1653 | { | 1632 | { |
| 1654 | CGFloat r, g, b, a; | 1633 | EmacsCGFloat r, g, b, a; |
| 1655 | 1634 | ||
| 1656 | [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a]; | 1635 | [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a]; |
| 1657 | color_def->red = r * 65535; | 1636 | color_def->red = r * 65535; |
| @@ -1696,26 +1675,6 @@ ns_defined_color (struct frame *f, | |||
| 1696 | } | 1675 | } |
| 1697 | 1676 | ||
| 1698 | 1677 | ||
| 1699 | unsigned long | ||
| 1700 | ns_get_rgb_color (struct frame *f, float r, float g, float b, float a) | ||
| 1701 | /* -------------------------------------------------------------------------- | ||
| 1702 | return an autoreleased RGB color | ||
| 1703 | -------------------------------------------------------------------------- */ | ||
| 1704 | { | ||
| 1705 | /*static int c = 1; fprintf (stderr, "color request %d\n", c++); */ | ||
| 1706 | if (r < 0.0) r = 0.0; | ||
| 1707 | else if (r > 1.0) r = 1.0; | ||
| 1708 | if (g < 0.0) g = 0.0; | ||
| 1709 | else if (g > 1.0) g = 1.0; | ||
| 1710 | if (b < 0.0) b = 0.0; | ||
| 1711 | else if (b > 1.0) b = 1.0; | ||
| 1712 | if (a < 0.0) a = 0.0; | ||
| 1713 | else if (a > 1.0) a = 1.0; | ||
| 1714 | return (unsigned long) ns_index_color( | ||
| 1715 | [NSColor colorWithCalibratedRed: r green: g blue: b alpha: a], f); | ||
| 1716 | } | ||
| 1717 | |||
| 1718 | |||
| 1719 | void | 1678 | void |
| 1720 | x_set_frame_alpha (struct frame *f) | 1679 | x_set_frame_alpha (struct frame *f) |
| 1721 | /* -------------------------------------------------------------------------- | 1680 | /* -------------------------------------------------------------------------- |
| @@ -1723,7 +1682,6 @@ x_set_frame_alpha (struct frame *f) | |||
| 1723 | -------------------------------------------------------------------------- */ | 1682 | -------------------------------------------------------------------------- */ |
| 1724 | { | 1683 | { |
| 1725 | struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); | 1684 | struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); |
| 1726 | EmacsView *view = FRAME_NS_VIEW (f); | ||
| 1727 | double alpha = 1.0; | 1685 | double alpha = 1.0; |
| 1728 | double alpha_min = 1.0; | 1686 | double alpha_min = 1.0; |
| 1729 | 1687 | ||
| @@ -1745,7 +1703,10 @@ x_set_frame_alpha (struct frame *f) | |||
| 1745 | alpha = alpha_min; | 1703 | alpha = alpha_min; |
| 1746 | 1704 | ||
| 1747 | #ifdef NS_IMPL_COCOA | 1705 | #ifdef NS_IMPL_COCOA |
| 1706 | { | ||
| 1707 | EmacsView *view = FRAME_NS_VIEW (f); | ||
| 1748 | [[view window] setAlphaValue: alpha]; | 1708 | [[view window] setAlphaValue: alpha]; |
| 1709 | } | ||
| 1749 | #endif | 1710 | #endif |
| 1750 | } | 1711 | } |
| 1751 | 1712 | ||
| @@ -1798,7 +1759,7 @@ x_set_mouse_position (struct frame *f, int h, int v) | |||
| 1798 | 1759 | ||
| 1799 | 1760 | ||
| 1800 | static int | 1761 | static int |
| 1801 | note_mouse_movement (struct frame *frame, float x, float y) | 1762 | note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y) |
| 1802 | /* ------------------------------------------------------------------------ | 1763 | /* ------------------------------------------------------------------------ |
| 1803 | Called by EmacsView on mouseMovement events. Passes on | 1764 | Called by EmacsView on mouseMovement events. Passes on |
| 1804 | to emacs mainstream code if we moved off of a rect of interest | 1765 | to emacs mainstream code if we moved off of a rect of interest |
| @@ -2257,7 +2218,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 2257 | { | 2218 | { |
| 2258 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 2219 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 2259 | struct face *face = p->face; | 2220 | struct face *face = p->face; |
| 2260 | int rowY; | ||
| 2261 | static EmacsImage **bimgs = NULL; | 2221 | static EmacsImage **bimgs = NULL; |
| 2262 | static int nBimgs = 0; | 2222 | static int nBimgs = 0; |
| 2263 | 2223 | ||
| @@ -2271,7 +2231,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 2271 | } | 2231 | } |
| 2272 | 2232 | ||
| 2273 | /* Must clip because of partially visible lines. */ | 2233 | /* Must clip because of partially visible lines. */ |
| 2274 | rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); | ||
| 2275 | ns_clip_to_row (w, row, -1, YES); | 2234 | ns_clip_to_row (w, row, -1, YES); |
| 2276 | 2235 | ||
| 2277 | if (!p->overlay_p) | 2236 | if (!p->overlay_p) |
| @@ -2359,7 +2318,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, | |||
| 2359 | [ns_lookup_indexed_color(face->background, f) set]; | 2318 | [ns_lookup_indexed_color(face->background, f) set]; |
| 2360 | NSRectFill (r); | 2319 | NSRectFill (r); |
| 2361 | [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)]; | 2320 | [img setXBMColor: ns_lookup_indexed_color(face->foreground, f)]; |
| 2362 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | 2321 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 |
| 2363 | [img drawInRect: r | 2322 | [img drawInRect: r |
| 2364 | fromRect: NSZeroRect | 2323 | fromRect: NSZeroRect |
| 2365 | operation: NSCompositeSourceOver | 2324 | operation: NSCompositeSourceOver |
| @@ -2391,7 +2350,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, | |||
| 2391 | int fx, fy, h, cursor_height; | 2350 | int fx, fy, h, cursor_height; |
| 2392 | struct frame *f = WINDOW_XFRAME (w); | 2351 | struct frame *f = WINDOW_XFRAME (w); |
| 2393 | struct glyph *phys_cursor_glyph; | 2352 | struct glyph *phys_cursor_glyph; |
| 2394 | int overspill; | ||
| 2395 | struct glyph *cursor_glyph; | 2353 | struct glyph *cursor_glyph; |
| 2396 | struct face *face; | 2354 | struct face *face; |
| 2397 | NSColor *hollow_color = FRAME_BACKGROUND_COLOR (f); | 2355 | NSColor *hollow_color = FRAME_BACKGROUND_COLOR (f); |
| @@ -2598,7 +2556,7 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) | |||
| 2598 | --------------------------------------------------------------------- */ | 2556 | --------------------------------------------------------------------- */ |
| 2599 | 2557 | ||
| 2600 | static void | 2558 | static void |
| 2601 | ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x) | 2559 | ns_draw_underwave (struct glyph_string *s, EmacsCGFloat width, EmacsCGFloat x) |
| 2602 | { | 2560 | { |
| 2603 | int wave_height = 3, wave_length = 2; | 2561 | int wave_height = 3, wave_length = 2; |
| 2604 | int y, dx, dy, odd, xmax; | 2562 | int y, dx, dy, odd, xmax; |
| @@ -2616,7 +2574,7 @@ ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x) | |||
| 2616 | NSRectClip (waveClip); | 2574 | NSRectClip (waveClip); |
| 2617 | 2575 | ||
| 2618 | /* Draw the waves */ | 2576 | /* Draw the waves */ |
| 2619 | a.x = x - ((int)(x) % dx) + 0.5; | 2577 | a.x = x - ((int)(x) % dx) + (EmacsCGFloat) 0.5; |
| 2620 | b.x = a.x + dx; | 2578 | b.x = a.x + dx; |
| 2621 | odd = (int)(a.x/dx) % 2; | 2579 | odd = (int)(a.x/dx) % 2; |
| 2622 | a.y = b.y = y + 0.5; | 2580 | a.y = b.y = y + 0.5; |
| @@ -2756,7 +2714,8 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face, | |||
| 2756 | } | 2714 | } |
| 2757 | 2715 | ||
| 2758 | static void | 2716 | static void |
| 2759 | ns_draw_box (NSRect r, float thickness, NSColor *col, char left_p, char right_p) | 2717 | ns_draw_box (NSRect r, CGFloat thickness, NSColor *col, |
| 2718 | char left_p, char right_p) | ||
| 2760 | /* -------------------------------------------------------------------------- | 2719 | /* -------------------------------------------------------------------------- |
| 2761 | Draw an unfilled rect inside r, optionally leaving left and/or right open. | 2720 | Draw an unfilled rect inside r, optionally leaving left and/or right open. |
| 2762 | Note we can't just use an NSDrawRect command, because of the possibility | 2721 | Note we can't just use an NSDrawRect command, because of the possibility |
| @@ -3033,7 +2992,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r) | |||
| 3033 | /* Draw the image.. do we need to draw placeholder if img ==nil? */ | 2992 | /* Draw the image.. do we need to draw placeholder if img ==nil? */ |
| 3034 | if (img != nil) | 2993 | if (img != nil) |
| 3035 | { | 2994 | { |
| 3036 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | 2995 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 |
| 3037 | NSRect dr = NSMakeRect (x, y, s->slice.width, s->slice.height); | 2996 | NSRect dr = NSMakeRect (x, y, s->slice.width, s->slice.height); |
| 3038 | NSRect ir = NSMakeRect (s->slice.x, s->slice.y, | 2997 | NSRect ir = NSMakeRect (s->slice.x, s->slice.y, |
| 3039 | s->slice.width, s->slice.height); | 2998 | s->slice.width, s->slice.height); |
| @@ -3358,6 +3317,19 @@ ns_send_appdefined (int value) | |||
| 3358 | { | 3317 | { |
| 3359 | /*NSTRACE (ns_send_appdefined); */ | 3318 | /*NSTRACE (ns_send_appdefined); */ |
| 3360 | 3319 | ||
| 3320 | #ifdef NS_IMPL_GNUSTEP | ||
| 3321 | // GNUStep needs postEvent to happen on the main thread. | ||
| 3322 | if (! [[NSThread currentThread] isMainThread]) | ||
| 3323 | { | ||
| 3324 | EmacsApp *app = (EmacsApp *)NSApp; | ||
| 3325 | app->nextappdefined = value; | ||
| 3326 | [app performSelectorOnMainThread:@selector (sendFromMainThread:) | ||
| 3327 | withObject:nil | ||
| 3328 | waitUntilDone:YES]; | ||
| 3329 | return; | ||
| 3330 | } | ||
| 3331 | #endif | ||
| 3332 | |||
| 3361 | /* Only post this event if we haven't already posted one. This will end | 3333 | /* Only post this event if we haven't already posted one. This will end |
| 3362 | the [NXApp run] main loop after having processed all events queued at | 3334 | the [NXApp run] main loop after having processed all events queued at |
| 3363 | this moment. */ | 3335 | this moment. */ |
| @@ -3417,6 +3389,9 @@ check_native_fs () | |||
| 3417 | } | 3389 | } |
| 3418 | #endif | 3390 | #endif |
| 3419 | 3391 | ||
| 3392 | /* GNUStep and OSX <= 10.4 does not have cancelTracking. */ | ||
| 3393 | #if defined (NS_IMPL_COCOA) && \ | ||
| 3394 | MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | ||
| 3420 | const char * | 3395 | const char * |
| 3421 | ns_get_pending_menu_title () | 3396 | ns_get_pending_menu_title () |
| 3422 | { | 3397 | { |
| @@ -3427,10 +3402,6 @@ ns_get_pending_menu_title () | |||
| 3427 | void | 3402 | void |
| 3428 | ns_check_menu_open (NSMenu *menu) | 3403 | ns_check_menu_open (NSMenu *menu) |
| 3429 | { | 3404 | { |
| 3430 | /* GNUStep and OSX <= 10.4 does not have cancelTracking. */ | ||
| 3431 | #if defined(NS_IMPL_COCOA) && \ | ||
| 3432 | MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | ||
| 3433 | |||
| 3434 | /* Click in menu bar? */ | 3405 | /* Click in menu bar? */ |
| 3435 | NSArray *a = [[NSApp mainMenu] itemArray]; | 3406 | NSArray *a = [[NSApp mainMenu] itemArray]; |
| 3436 | int i; | 3407 | int i; |
| @@ -3460,14 +3431,12 @@ ns_check_menu_open (NSMenu *menu) | |||
| 3460 | menu_will_open_state = MENU_NONE; | 3431 | menu_will_open_state = MENU_NONE; |
| 3461 | } | 3432 | } |
| 3462 | } | 3433 | } |
| 3463 | #endif | ||
| 3464 | } | 3434 | } |
| 3465 | 3435 | ||
| 3466 | /* Redo saved menu click if state is MENU_PENDING. */ | 3436 | /* Redo saved menu click if state is MENU_PENDING. */ |
| 3467 | void | 3437 | void |
| 3468 | ns_check_pending_open_menu () | 3438 | ns_check_pending_open_menu () |
| 3469 | { | 3439 | { |
| 3470 | #ifdef NS_IMPL_COCOA | ||
| 3471 | if (menu_will_open_state == MENU_PENDING) | 3440 | if (menu_will_open_state == MENU_PENDING) |
| 3472 | { | 3441 | { |
| 3473 | CGEventSourceRef source | 3442 | CGEventSourceRef source |
| @@ -3484,9 +3453,8 @@ ns_check_pending_open_menu () | |||
| 3484 | 3453 | ||
| 3485 | menu_will_open_state = MENU_OPENING; | 3454 | menu_will_open_state = MENU_OPENING; |
| 3486 | } | 3455 | } |
| 3487 | #endif | ||
| 3488 | } | 3456 | } |
| 3489 | 3457 | #endif /* NS_IMPL_COCOA) && >= MAC_OS_X_VERSION_10_5 */ | |
| 3490 | 3458 | ||
| 3491 | static int | 3459 | static int |
| 3492 | ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) | 3460 | ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) |
| @@ -4392,6 +4360,12 @@ ns_term_init (Lisp_Object display_name) | |||
| 4392 | 4360 | ||
| 4393 | [NSApp run]; | 4361 | [NSApp run]; |
| 4394 | ns_do_open_file = YES; | 4362 | ns_do_open_file = YES; |
| 4363 | |||
| 4364 | #ifdef NS_IMPL_GNUSTEP | ||
| 4365 | /* GNUstep steals SIGCHLD for use in NSTask, but we don't use NSTask. | ||
| 4366 | We must re-catch it so subprocess works. */ | ||
| 4367 | catch_child_signal (); | ||
| 4368 | #endif | ||
| 4395 | return dpyinfo; | 4369 | return dpyinfo; |
| 4396 | } | 4370 | } |
| 4397 | 4371 | ||
| @@ -4699,6 +4673,13 @@ not_in_argv (NSString *arg) | |||
| 4699 | ns_send_appdefined (-2); | 4673 | ns_send_appdefined (-2); |
| 4700 | } | 4674 | } |
| 4701 | 4675 | ||
| 4676 | #ifdef NS_IMPL_GNUSTEP | ||
| 4677 | - (void)sendFromMainThread:(id)unused | ||
| 4678 | { | ||
| 4679 | ns_send_appdefined (nextappdefined); | ||
| 4680 | } | ||
| 4681 | #endif | ||
| 4682 | |||
| 4702 | - (void)fd_handler:(id)unused | 4683 | - (void)fd_handler:(id)unused |
| 4703 | /* -------------------------------------------------------------------------- | 4684 | /* -------------------------------------------------------------------------- |
| 4704 | Check data waiting on file descriptors and terminate if so | 4685 | Check data waiting on file descriptors and terminate if so |
| @@ -4863,7 +4844,7 @@ not_in_argv (NSString *arg) | |||
| 4863 | NSEvent *e =[[self window] currentEvent]; | 4844 | NSEvent *e =[[self window] currentEvent]; |
| 4864 | struct face *face =FRAME_DEFAULT_FACE (emacsframe); | 4845 | struct face *face =FRAME_DEFAULT_FACE (emacsframe); |
| 4865 | id newFont; | 4846 | id newFont; |
| 4866 | float size; | 4847 | CGFloat size; |
| 4867 | 4848 | ||
| 4868 | NSTRACE (changeFont); | 4849 | NSTRACE (changeFont); |
| 4869 | if (!emacs_event) | 4850 | if (!emacs_event) |
| @@ -4982,7 +4963,16 @@ not_in_argv (NSString *arg) | |||
| 4982 | { | 4963 | { |
| 4983 | /* COUNTERHACK: map 'Delete' on upper-right main KB to 'Backspace', | 4964 | /* COUNTERHACK: map 'Delete' on upper-right main KB to 'Backspace', |
| 4984 | because Emacs treats Delete and KP-Delete same (in simple.el). */ | 4965 | because Emacs treats Delete and KP-Delete same (in simple.el). */ |
| 4985 | if (fnKeysym == 0xFFFF && [theEvent keyCode] == 0x33) | 4966 | if ((fnKeysym == 0xFFFF && [theEvent keyCode] == 0x33) |
| 4967 | #ifdef NS_IMPL_GNUSTEP | ||
| 4968 | /* GNUstep uses incompatible keycodes, even for those that are | ||
| 4969 | supposed to be hardware independent. Just check for delete. | ||
| 4970 | Keypad delete does not have keysym 0xFFFF. | ||
| 4971 | See http://savannah.gnu.org/bugs/?25395 | ||
| 4972 | */ | ||
| 4973 | || (fnKeysym == 0xFFFF && code == 127) | ||
| 4974 | #endif | ||
| 4975 | ) | ||
| 4986 | code = 0xFF08; /* backspace */ | 4976 | code = 0xFF08; /* backspace */ |
| 4987 | else | 4977 | else |
| 4988 | code = fnKeysym; | 4978 | code = fnKeysym; |
| @@ -5135,10 +5125,14 @@ not_in_argv (NSString *arg) | |||
| 5135 | 5125 | ||
| 5136 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | 5126 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
| 5137 | /* if we get here we should send the key for input manager processing */ | 5127 | /* if we get here we should send the key for input manager processing */ |
| 5128 | /* Disable warning, there is nothing a user can do about it anyway, and | ||
| 5129 | it does not seem to matter. */ | ||
| 5130 | #if 0 | ||
| 5138 | if (firstTime && [[NSInputManager currentInputManager] | 5131 | if (firstTime && [[NSInputManager currentInputManager] |
| 5139 | wantsToDelayTextChangeNotifications] == NO) | 5132 | wantsToDelayTextChangeNotifications] == NO) |
| 5140 | fprintf (stderr, | 5133 | fprintf (stderr, |
| 5141 | "Emacs: WARNING: TextInput mgr wants marked text to be permanent!\n"); | 5134 | "Emacs: WARNING: TextInput mgr wants marked text to be permanent!\n"); |
| 5135 | #endif | ||
| 5142 | firstTime = NO; | 5136 | firstTime = NO; |
| 5143 | #endif | 5137 | #endif |
| 5144 | if (NS_KEYLOG && !processingCompose) | 5138 | if (NS_KEYLOG && !processingCompose) |
| @@ -5346,7 +5340,12 @@ not_in_argv (NSString *arg) | |||
| 5346 | return NSMakeRange (NSNotFound, 0); | 5340 | return NSMakeRange (NSNotFound, 0); |
| 5347 | } | 5341 | } |
| 5348 | 5342 | ||
| 5343 | #if defined (NS_IMPL_COCOA) || GNUSTEP_GUI_MAJOR_VERSION > 0 || \ | ||
| 5344 | GNUSTEP_GUI_MINOR_VERSION > 22 | ||
| 5349 | - (NSUInteger)characterIndexForPoint: (NSPoint)thePoint | 5345 | - (NSUInteger)characterIndexForPoint: (NSPoint)thePoint |
| 5346 | #else | ||
| 5347 | - (unsigned int)characterIndexForPoint: (NSPoint)thePoint | ||
| 5348 | #endif | ||
| 5350 | { | 5349 | { |
| 5351 | if (NS_KEYLOG) | 5350 | if (NS_KEYLOG) |
| 5352 | NSLog (@"characterIndexForPoint request"); | 5351 | NSLog (@"characterIndexForPoint request"); |
| @@ -5385,7 +5384,7 @@ not_in_argv (NSString *arg) | |||
| 5385 | 5384 | ||
| 5386 | if ([theEvent type] == NSScrollWheel) | 5385 | if ([theEvent type] == NSScrollWheel) |
| 5387 | { | 5386 | { |
| 5388 | float delta = [theEvent deltaY]; | 5387 | CGFloat delta = [theEvent deltaY]; |
| 5389 | /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */ | 5388 | /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */ |
| 5390 | if (delta == 0) | 5389 | if (delta == 0) |
| 5391 | return; | 5390 | return; |
| @@ -5569,7 +5568,6 @@ not_in_argv (NSString *arg) | |||
| 5569 | 5568 | ||
| 5570 | if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) | 5569 | if (oldr != rows || oldc != cols || neww != oldw || newh != oldh) |
| 5571 | { | 5570 | { |
| 5572 | struct frame *f = emacsframe; | ||
| 5573 | NSView *view = FRAME_NS_VIEW (emacsframe); | 5571 | NSView *view = FRAME_NS_VIEW (emacsframe); |
| 5574 | NSWindow *win = [view window]; | 5572 | NSWindow *win = [view window]; |
| 5575 | NSSize sz = [win resizeIncrements]; | 5573 | NSSize sz = [win resizeIncrements]; |
| @@ -5602,7 +5600,7 @@ not_in_argv (NSString *arg) | |||
| 5602 | #ifdef NS_IMPL_GNUSTEP | 5600 | #ifdef NS_IMPL_GNUSTEP |
| 5603 | gsextra = 3; | 5601 | gsextra = 3; |
| 5604 | #endif | 5602 | #endif |
| 5605 | 5603 | ||
| 5606 | NSTRACE (windowWillResize); | 5604 | NSTRACE (windowWillResize); |
| 5607 | /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ | 5605 | /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ |
| 5608 | 5606 | ||
| @@ -5668,7 +5666,7 @@ not_in_argv (NSString *arg) | |||
| 5668 | 5666 | ||
| 5669 | - (void)windowDidResize: (NSNotification *)notification | 5667 | - (void)windowDidResize: (NSNotification *)notification |
| 5670 | { | 5668 | { |
| 5671 | if (! [self fsIsNative]) | 5669 | if (! [self fsIsNative]) |
| 5672 | { | 5670 | { |
| 5673 | NSWindow *theWindow = [notification object]; | 5671 | NSWindow *theWindow = [notification object]; |
| 5674 | /* We can get notification on the non-FS window when in | 5672 | /* We can get notification on the non-FS window when in |
| @@ -5778,7 +5776,6 @@ not_in_argv (NSString *arg) | |||
| 5778 | NSRect r, wr; | 5776 | NSRect r, wr; |
| 5779 | Lisp_Object tem; | 5777 | Lisp_Object tem; |
| 5780 | NSWindow *win; | 5778 | NSWindow *win; |
| 5781 | NSButton *toggleButton; | ||
| 5782 | NSSize sz; | 5779 | NSSize sz; |
| 5783 | NSColor *col; | 5780 | NSColor *col; |
| 5784 | NSString *name; | 5781 | NSString *name; |
| @@ -5854,9 +5851,12 @@ not_in_argv (NSString *arg) | |||
| 5854 | [win setToolbar: toolbar]; | 5851 | [win setToolbar: toolbar]; |
| 5855 | [toolbar setVisible: NO]; | 5852 | [toolbar setVisible: NO]; |
| 5856 | #ifdef NS_IMPL_COCOA | 5853 | #ifdef NS_IMPL_COCOA |
| 5854 | { | ||
| 5855 | NSButton *toggleButton; | ||
| 5857 | toggleButton = [win standardWindowButton: NSWindowToolbarButton]; | 5856 | toggleButton = [win standardWindowButton: NSWindowToolbarButton]; |
| 5858 | [toggleButton setTarget: self]; | 5857 | [toggleButton setTarget: self]; |
| 5859 | [toggleButton setAction: @selector (toggleToolbar: )]; | 5858 | [toggleButton setAction: @selector (toggleToolbar: )]; |
| 5859 | } | ||
| 5860 | #endif | 5860 | #endif |
| 5861 | FRAME_TOOLBAR_HEIGHT (f) = 0; | 5861 | FRAME_TOOLBAR_HEIGHT (f) = 0; |
| 5862 | 5862 | ||
| @@ -5880,7 +5880,7 @@ not_in_argv (NSString *arg) | |||
| 5880 | col = ns_lookup_indexed_color (NS_FACE_BACKGROUND | 5880 | col = ns_lookup_indexed_color (NS_FACE_BACKGROUND |
| 5881 | (FRAME_DEFAULT_FACE (emacsframe)), emacsframe); | 5881 | (FRAME_DEFAULT_FACE (emacsframe)), emacsframe); |
| 5882 | [win setBackgroundColor: col]; | 5882 | [win setBackgroundColor: col]; |
| 5883 | if ([col alphaComponent] != 1.0) | 5883 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) |
| 5884 | [win setOpaque: NO]; | 5884 | [win setOpaque: NO]; |
| 5885 | 5885 | ||
| 5886 | [self allocateGState]; | 5886 | [self allocateGState]; |
| @@ -5973,7 +5973,7 @@ not_in_argv (NSString *arg) | |||
| 5973 | result = ns_userRect.size.height ? ns_userRect : result; | 5973 | result = ns_userRect.size.height ? ns_userRect : result; |
| 5974 | ns_userRect = NSMakeRect (0, 0, 0, 0); | 5974 | ns_userRect = NSMakeRect (0, 0, 0, 0); |
| 5975 | [self setFSValue: FULLSCREEN_NONE]; | 5975 | [self setFSValue: FULLSCREEN_NONE]; |
| 5976 | maximized_width = maximized_width = -1; | 5976 | maximized_width = maximized_height = -1; |
| 5977 | } | 5977 | } |
| 5978 | 5978 | ||
| 5979 | if (fs_before_fs == -1) next_maximized = -1; | 5979 | if (fs_before_fs == -1) next_maximized = -1; |
| @@ -6066,7 +6066,9 @@ not_in_argv (NSString *arg) | |||
| 6066 | { | 6066 | { |
| 6067 | [self setFSValue: fs_before_fs]; | 6067 | [self setFSValue: fs_before_fs]; |
| 6068 | fs_before_fs = -1; | 6068 | fs_before_fs = -1; |
| 6069 | #ifdef NS_IMPL_COCOA | ||
| 6069 | [self updateCollectionBehaviour]; | 6070 | [self updateCollectionBehaviour]; |
| 6071 | #endif | ||
| 6070 | if (FRAME_EXTERNAL_TOOL_BAR (emacsframe)) | 6072 | if (FRAME_EXTERNAL_TOOL_BAR (emacsframe)) |
| 6071 | { | 6073 | { |
| 6072 | [toolbar setVisible:YES]; | 6074 | [toolbar setVisible:YES]; |
| @@ -6113,7 +6115,7 @@ not_in_argv (NSString *arg) | |||
| 6113 | } | 6115 | } |
| 6114 | } | 6116 | } |
| 6115 | #endif | 6117 | #endif |
| 6116 | 6118 | ||
| 6117 | - (void)toggleFullScreen: (id)sender | 6119 | - (void)toggleFullScreen: (id)sender |
| 6118 | { | 6120 | { |
| 6119 | NSWindow *w, *fw; | 6121 | NSWindow *w, *fw; |
| @@ -6125,7 +6127,9 @@ not_in_argv (NSString *arg) | |||
| 6125 | 6127 | ||
| 6126 | if (fs_is_native) | 6128 | if (fs_is_native) |
| 6127 | { | 6129 | { |
| 6130 | #ifdef NS_IMPL_COCOA | ||
| 6128 | [[self window] toggleFullScreen:sender]; | 6131 | [[self window] toggleFullScreen:sender]; |
| 6132 | #endif | ||
| 6129 | return; | 6133 | return; |
| 6130 | } | 6134 | } |
| 6131 | 6135 | ||
| @@ -6171,7 +6175,7 @@ not_in_argv (NSString *arg) | |||
| 6171 | [fw useOptimizedDrawing: YES]; | 6175 | [fw useOptimizedDrawing: YES]; |
| 6172 | [fw setResizeIncrements: sz]; | 6176 | [fw setResizeIncrements: sz]; |
| 6173 | [fw setBackgroundColor: col]; | 6177 | [fw setBackgroundColor: col]; |
| 6174 | if ([col alphaComponent] != 1.0) | 6178 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) |
| 6175 | [fw setOpaque: NO]; | 6179 | [fw setOpaque: NO]; |
| 6176 | 6180 | ||
| 6177 | f->border_width = 0; | 6181 | f->border_width = 0; |
| @@ -6209,7 +6213,7 @@ not_in_argv (NSString *arg) | |||
| 6209 | [w setContentView:[fw contentView]]; | 6213 | [w setContentView:[fw contentView]]; |
| 6210 | [w setResizeIncrements: sz]; | 6214 | [w setResizeIncrements: sz]; |
| 6211 | [w setBackgroundColor: col]; | 6215 | [w setBackgroundColor: col]; |
| 6212 | if ([col alphaComponent] != 1.0) | 6216 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) |
| 6213 | [w setOpaque: NO]; | 6217 | [w setOpaque: NO]; |
| 6214 | 6218 | ||
| 6215 | f->border_width = bwidth; | 6219 | f->border_width = bwidth; |
| @@ -6903,10 +6907,11 @@ not_in_argv (NSString *arg) | |||
| 6903 | } | 6907 | } |
| 6904 | else | 6908 | else |
| 6905 | { | 6909 | { |
| 6906 | float pos, por; | 6910 | float pos; |
| 6911 | CGFloat por; | ||
| 6907 | portion = max ((float)whole*min_portion/pixel_height, portion); | 6912 | portion = max ((float)whole*min_portion/pixel_height, portion); |
| 6908 | pos = (float)position / (whole - portion); | 6913 | pos = (float)position / (whole - portion); |
| 6909 | por = (float)portion/whole; | 6914 | por = (CGFloat)portion/whole; |
| 6910 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 | 6915 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 |
| 6911 | [self setKnobProportion: por]; | 6916 | [self setKnobProportion: por]; |
| 6912 | [self setDoubleValue: pos]; | 6917 | [self setDoubleValue: pos]; |
| @@ -6931,7 +6936,7 @@ not_in_argv (NSString *arg) | |||
| 6931 | *part = last_hit_part; | 6936 | *part = last_hit_part; |
| 6932 | *window = win; | 6937 | *window = win; |
| 6933 | XSETINT (*y, pixel_height); | 6938 | XSETINT (*y, pixel_height); |
| 6934 | if ([self floatValue] > 0.999) | 6939 | if ([self floatValue] > 0.999F) |
| 6935 | XSETINT (*x, pixel_height); | 6940 | XSETINT (*x, pixel_height); |
| 6936 | else | 6941 | else |
| 6937 | XSETINT (*x, pixel_height * [self floatValue]); | 6942 | XSETINT (*x, pixel_height * [self floatValue]); |
| @@ -7005,7 +7010,7 @@ not_in_argv (NSString *arg) | |||
| 7005 | NSRect sr, kr; | 7010 | NSRect sr, kr; |
| 7006 | /* hitPart is only updated AFTER event is passed on */ | 7011 | /* hitPart is only updated AFTER event is passed on */ |
| 7007 | NSScrollerPart part = [self testPart: [e locationInWindow]]; | 7012 | NSScrollerPart part = [self testPart: [e locationInWindow]]; |
| 7008 | double inc = 0.0, loc, kloc, pos; | 7013 | CGFloat inc = 0.0, loc, kloc, pos; |
| 7009 | int edge = 0; | 7014 | int edge = 0; |
| 7010 | 7015 | ||
| 7011 | NSTRACE (EmacsScroller_mouseDown); | 7016 | NSTRACE (EmacsScroller_mouseDown); |
| @@ -7104,7 +7109,6 @@ not_in_argv (NSString *arg) | |||
| 7104 | { | 7109 | { |
| 7105 | NSRect sr; | 7110 | NSRect sr; |
| 7106 | double loc, pos; | 7111 | double loc, pos; |
| 7107 | int edge = 0; | ||
| 7108 | 7112 | ||
| 7109 | NSTRACE (EmacsScroller_mouseDragged); | 7113 | NSTRACE (EmacsScroller_mouseDragged); |
| 7110 | 7114 | ||
| @@ -7115,15 +7119,13 @@ not_in_argv (NSString *arg) | |||
| 7115 | if (loc <= 0.0) | 7119 | if (loc <= 0.0) |
| 7116 | { | 7120 | { |
| 7117 | loc = 0.0; | 7121 | loc = 0.0; |
| 7118 | edge = -1; | ||
| 7119 | } | 7122 | } |
| 7120 | else if (loc >= NSHeight (sr) + last_mouse_offset) | 7123 | else if (loc >= NSHeight (sr) + last_mouse_offset) |
| 7121 | { | 7124 | { |
| 7122 | loc = NSHeight (sr) + last_mouse_offset; | 7125 | loc = NSHeight (sr) + last_mouse_offset; |
| 7123 | edge = 1; | ||
| 7124 | } | 7126 | } |
| 7125 | 7127 | ||
| 7126 | pos = /*(edge ? loc :*/ (loc - last_mouse_offset) / NSHeight (sr); | 7128 | pos = (loc - last_mouse_offset) / NSHeight (sr); |
| 7127 | [self sendScrollEventAtLoc: pos fromEvent: e]; | 7129 | [self sendScrollEventAtLoc: pos fromEvent: e]; |
| 7128 | } | 7130 | } |
| 7129 | 7131 | ||
| @@ -7150,6 +7152,12 @@ not_in_argv (NSString *arg) | |||
| 7150 | @end /* EmacsScroller */ | 7152 | @end /* EmacsScroller */ |
| 7151 | 7153 | ||
| 7152 | 7154 | ||
| 7155 | #ifdef NS_IMPL_GNUSTEP | ||
| 7156 | /* Dummy class to get rid of startup warnings. */ | ||
| 7157 | @implementation EmacsDocument | ||
| 7158 | |||
| 7159 | @end | ||
| 7160 | #endif | ||
| 7153 | 7161 | ||
| 7154 | 7162 | ||
| 7155 | /* ========================================================================== | 7163 | /* ========================================================================== |
diff --git a/src/process.c b/src/process.c index 45e8afdd22c..33035078df9 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -4528,7 +4528,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4528 | } | 4528 | } |
| 4529 | #endif | 4529 | #endif |
| 4530 | 4530 | ||
| 4531 | #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) | 4531 | #if defined (HAVE_GLIB) |
| 4532 | nfds = xg_select | 4532 | nfds = xg_select |
| 4533 | #elif defined (HAVE_NS) | 4533 | #elif defined (HAVE_NS) |
| 4534 | nfds = ns_select | 4534 | nfds = ns_select |
| @@ -7029,6 +7029,17 @@ integer or floating point values. | |||
| 7029 | return system_process_attributes (pid); | 7029 | return system_process_attributes (pid); |
| 7030 | } | 7030 | } |
| 7031 | 7031 | ||
| 7032 | #ifndef NS_IMPL_GNUSTEP | ||
| 7033 | static | ||
| 7034 | #endif | ||
| 7035 | void | ||
| 7036 | catch_child_signal (void) | ||
| 7037 | { | ||
| 7038 | struct sigaction action; | ||
| 7039 | emacs_sigaction_init (&action, deliver_child_signal); | ||
| 7040 | sigaction (SIGCHLD, &action, 0); | ||
| 7041 | } | ||
| 7042 | |||
| 7032 | 7043 | ||
| 7033 | /* This is not called "init_process" because that is the name of a | 7044 | /* This is not called "init_process" because that is the name of a |
| 7034 | Mach system call, so it would cause problems on Darwin systems. */ | 7045 | Mach system call, so it would cause problems on Darwin systems. */ |
| @@ -7044,9 +7055,7 @@ init_process_emacs (void) | |||
| 7044 | if (! noninteractive || initialized) | 7055 | if (! noninteractive || initialized) |
| 7045 | #endif | 7056 | #endif |
| 7046 | { | 7057 | { |
| 7047 | struct sigaction action; | 7058 | catch_child_signal (); |
| 7048 | emacs_sigaction_init (&action, deliver_child_signal); | ||
| 7049 | sigaction (SIGCHLD, &action, 0); | ||
| 7050 | } | 7059 | } |
| 7051 | 7060 | ||
| 7052 | FD_ZERO (&input_wait_mask); | 7061 | FD_ZERO (&input_wait_mask); |
diff --git a/src/process.h b/src/process.h index 765e5d82567..0c4e17e68cf 100644 --- a/src/process.h +++ b/src/process.h | |||
| @@ -217,5 +217,8 @@ extern void add_read_fd (int fd, fd_callback func, void *data); | |||
| 217 | extern void delete_read_fd (int fd); | 217 | extern void delete_read_fd (int fd); |
| 218 | extern void add_write_fd (int fd, fd_callback func, void *data); | 218 | extern void add_write_fd (int fd, fd_callback func, void *data); |
| 219 | extern void delete_write_fd (int fd); | 219 | extern void delete_write_fd (int fd); |
| 220 | #ifdef NS_IMPL_GNUSTEP | ||
| 221 | extern void catch_child_signal (void); | ||
| 222 | #endif | ||
| 220 | 223 | ||
| 221 | INLINE_HEADER_END | 224 | INLINE_HEADER_END |
diff --git a/src/profiler.c b/src/profiler.c index 0a0a4d0bc57..aba81344c68 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -138,10 +138,8 @@ static void evict_lower_half (log_t *log) | |||
| 138 | static void | 138 | static void |
| 139 | record_backtrace (log_t *log, EMACS_INT count) | 139 | record_backtrace (log_t *log, EMACS_INT count) |
| 140 | { | 140 | { |
| 141 | struct backtrace *backlist = backtrace_list; | ||
| 142 | Lisp_Object backtrace; | 141 | Lisp_Object backtrace; |
| 143 | ptrdiff_t index, i = 0; | 142 | ptrdiff_t index; |
| 144 | ptrdiff_t asize; | ||
| 145 | 143 | ||
| 146 | if (!INTEGERP (log->next_free)) | 144 | if (!INTEGERP (log->next_free)) |
| 147 | /* FIXME: transfer the evicted counts to a special entry rather | 145 | /* FIXME: transfer the evicted counts to a special entry rather |
| @@ -151,16 +149,7 @@ record_backtrace (log_t *log, EMACS_INT count) | |||
| 151 | 149 | ||
| 152 | /* Get a "working memory" vector. */ | 150 | /* Get a "working memory" vector. */ |
| 153 | backtrace = HASH_KEY (log, index); | 151 | backtrace = HASH_KEY (log, index); |
| 154 | asize = ASIZE (backtrace); | 152 | get_backtrace (backtrace); |
| 155 | |||
| 156 | /* Copy the backtrace contents into working memory. */ | ||
| 157 | for (; i < asize && backlist; i++, backlist = backlist->next) | ||
| 158 | /* FIXME: For closures we should ignore the environment. */ | ||
| 159 | ASET (backtrace, i, backlist->function); | ||
| 160 | |||
| 161 | /* Make sure that unused space of working memory is filled with nil. */ | ||
| 162 | for (; i < asize; i++) | ||
| 163 | ASET (backtrace, i, Qnil); | ||
| 164 | 153 | ||
| 165 | { /* We basically do a `gethash+puthash' here, except that we have to be | 154 | { /* We basically do a `gethash+puthash' here, except that we have to be |
| 166 | careful to avoid memory allocation since we're in a signal | 155 | careful to avoid memory allocation since we're in a signal |
| @@ -232,7 +221,7 @@ static EMACS_INT current_sampling_interval; | |||
| 232 | static void | 221 | static void |
| 233 | handle_profiler_signal (int signal) | 222 | handle_profiler_signal (int signal) |
| 234 | { | 223 | { |
| 235 | if (backtrace_list && EQ (backtrace_list->function, Qautomatic_gc)) | 224 | if (EQ (backtrace_top_function (), Qautomatic_gc)) |
| 236 | /* Special case the time-count inside GC because the hash-table | 225 | /* Special case the time-count inside GC because the hash-table |
| 237 | code is not prepared to be used while the GC is running. | 226 | code is not prepared to be used while the GC is running. |
| 238 | More specifically it uses ASIZE at many places where it does | 227 | More specifically it uses ASIZE at many places where it does |
diff --git a/src/puresize.h b/src/puresize.h index 2f717571c7c..25a11aafbcc 100644 --- a/src/puresize.h +++ b/src/puresize.h | |||
| @@ -73,9 +73,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 73 | /* Signal an error if OBJ is pure. */ | 73 | /* Signal an error if OBJ is pure. */ |
| 74 | #define CHECK_IMPURE(obj) \ | 74 | #define CHECK_IMPURE(obj) \ |
| 75 | { if (PURE_P (obj)) \ | 75 | { if (PURE_P (obj)) \ |
| 76 | pure_write_error (); } | 76 | pure_write_error (obj); } |
| 77 | 77 | ||
| 78 | extern _Noreturn void pure_write_error (void); | 78 | extern _Noreturn void pure_write_error (Lisp_Object); |
| 79 | 79 | ||
| 80 | /* Define PURE_P. */ | 80 | /* Define PURE_P. */ |
| 81 | 81 | ||
diff --git a/src/term.c b/src/term.c index 28b944c6436..0bcef55947a 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -3189,12 +3189,13 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3189 | #ifdef WINDOWSNT | 3189 | #ifdef WINDOWSNT |
| 3190 | { | 3190 | { |
| 3191 | struct frame *f = XFRAME (selected_frame); | 3191 | struct frame *f = XFRAME (selected_frame); |
| 3192 | int height, width; | ||
| 3192 | 3193 | ||
| 3193 | initialize_w32_display (terminal); | 3194 | initialize_w32_display (terminal, &width, &height); |
| 3194 | 3195 | ||
| 3195 | FrameRows (tty) = FRAME_LINES (f); | 3196 | FrameRows (tty) = height; |
| 3196 | FrameCols (tty) = FRAME_COLS (f); | 3197 | FrameCols (tty) = width; |
| 3197 | tty->specified_window = FRAME_LINES (f); | 3198 | tty->specified_window = height; |
| 3198 | 3199 | ||
| 3199 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; | 3200 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
| 3200 | terminal->char_ins_del_ok = 1; | 3201 | terminal->char_ins_del_ok = 1; |
diff --git a/src/termhooks.h b/src/termhooks.h index 252dbabb6f9..4f3fa9cb47f 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -212,7 +212,7 @@ enum event_kind | |||
| 212 | , NS_NONKEY_EVENT | 212 | , NS_NONKEY_EVENT |
| 213 | #endif | 213 | #endif |
| 214 | 214 | ||
| 215 | #if defined (HAVE_INOTIFY) || defined (HAVE_NTGUI) | 215 | #ifdef USE_FILE_NOTIFY |
| 216 | /* File or directory was changed. */ | 216 | /* File or directory was changed. */ |
| 217 | , FILE_NOTIFY_EVENT | 217 | , FILE_NOTIFY_EVENT |
| 218 | #endif | 218 | #endif |
| @@ -2452,7 +2452,7 @@ get_emacs_configuration_options (void) | |||
| 2452 | 2452 | ||
| 2453 | /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ | 2453 | /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ |
| 2454 | int | 2454 | int |
| 2455 | gettimeofday (struct timeval *restrict tv, struct timezone *restrict tz) | 2455 | gettimeofday (struct timeval *__restrict tv, struct timezone *__restrict tz) |
| 2456 | { | 2456 | { |
| 2457 | struct _timeb tb; | 2457 | struct _timeb tb; |
| 2458 | _ftime (&tb); | 2458 | _ftime (&tb); |
diff --git a/src/w32console.c b/src/w32console.c index 06b2c7aa24e..ee92a593301 100644 --- a/src/w32console.c +++ b/src/w32console.c | |||
| @@ -601,7 +601,7 @@ w32_face_attributes (struct frame *f, int face_id) | |||
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | void | 603 | void |
| 604 | initialize_w32_display (struct terminal *term) | 604 | initialize_w32_display (struct terminal *term, int *width, int *height) |
| 605 | { | 605 | { |
| 606 | CONSOLE_SCREEN_BUFFER_INFO info; | 606 | CONSOLE_SCREEN_BUFFER_INFO info; |
| 607 | Mouse_HLInfo *hlinfo; | 607 | Mouse_HLInfo *hlinfo; |
| @@ -722,23 +722,21 @@ initialize_w32_display (struct terminal *term) | |||
| 722 | || info.srWindow.Right - info.srWindow.Left < 40 | 722 | || info.srWindow.Right - info.srWindow.Left < 40 |
| 723 | || info.srWindow.Right - info.srWindow.Left > 100))) | 723 | || info.srWindow.Right - info.srWindow.Left > 100))) |
| 724 | { | 724 | { |
| 725 | FRAME_LINES (SELECTED_FRAME ()) = 25; | 725 | *height = 25; |
| 726 | SET_FRAME_COLS (SELECTED_FRAME (), 80); | 726 | *width = 80; |
| 727 | } | 727 | } |
| 728 | 728 | ||
| 729 | else if (w32_use_full_screen_buffer) | 729 | else if (w32_use_full_screen_buffer) |
| 730 | { | 730 | { |
| 731 | FRAME_LINES (SELECTED_FRAME ()) = info.dwSize.Y; /* lines per page */ | 731 | *height = info.dwSize.Y; /* lines per page */ |
| 732 | SET_FRAME_COLS (SELECTED_FRAME (), info.dwSize.X); /* characters per line */ | 732 | *width = info.dwSize.X; /* characters per line */ |
| 733 | } | 733 | } |
| 734 | else | 734 | else |
| 735 | { | 735 | { |
| 736 | /* Lines per page. Use buffer coords instead of buffer size. */ | 736 | /* Lines per page. Use buffer coords instead of buffer size. */ |
| 737 | FRAME_LINES (SELECTED_FRAME ()) = 1 + info.srWindow.Bottom - | 737 | *height = 1 + info.srWindow.Bottom - info.srWindow.Top; |
| 738 | info.srWindow.Top; | ||
| 739 | /* Characters per line. Use buffer coords instead of buffer size. */ | 738 | /* Characters per line. Use buffer coords instead of buffer size. */ |
| 740 | SET_FRAME_COLS (SELECTED_FRAME (), 1 + info.srWindow.Right - | 739 | *width = 1 + info.srWindow.Right - info.srWindow.Left; |
| 741 | info.srWindow.Left); | ||
| 742 | } | 740 | } |
| 743 | 741 | ||
| 744 | if (os_subtype == OS_NT) | 742 | if (os_subtype == OS_NT) |
diff --git a/src/w32inevt.c b/src/w32inevt.c index 3c38cf806e8..88a3f9739cd 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -577,6 +577,7 @@ maybe_generate_resize_event (void) | |||
| 577 | 0, 0, 0); | 577 | 0, 0, 0); |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | #if HAVE_W32NOTIFY | ||
| 580 | static int | 581 | static int |
| 581 | handle_file_notifications (struct input_event *hold_quit) | 582 | handle_file_notifications (struct input_event *hold_quit) |
| 582 | { | 583 | { |
| @@ -644,6 +645,13 @@ handle_file_notifications (struct input_event *hold_quit) | |||
| 644 | leave_crit (); | 645 | leave_crit (); |
| 645 | return nevents; | 646 | return nevents; |
| 646 | } | 647 | } |
| 648 | #else /* !HAVE_W32NOTIFY */ | ||
| 649 | static int | ||
| 650 | handle_file_notifications (struct input_event *hold_quit) | ||
| 651 | { | ||
| 652 | return 0; | ||
| 653 | } | ||
| 654 | #endif /* !HAVE_W32NOTIFY */ | ||
| 647 | 655 | ||
| 648 | /* Here's an overview of how Emacs input works in non-GUI sessions on | 656 | /* Here's an overview of how Emacs input works in non-GUI sessions on |
| 649 | MS-Windows. (For description of the GUI input, see the commentary | 657 | MS-Windows. (For description of the GUI input, see the commentary |
diff --git a/src/w32term.c b/src/w32term.c index 58b1d3ca308..617492e189f 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -3210,6 +3210,8 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f) | |||
| 3210 | } | 3210 | } |
| 3211 | 3211 | ||
| 3212 | 3212 | ||
| 3213 | #if HAVE_W32NOTIFY | ||
| 3214 | |||
| 3213 | /* File event notifications (see w32notify.c). */ | 3215 | /* File event notifications (see w32notify.c). */ |
| 3214 | 3216 | ||
| 3215 | Lisp_Object | 3217 | Lisp_Object |
| @@ -3325,7 +3327,8 @@ queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f, | |||
| 3325 | /* We've stuffed all the events ourselves, so w32_read_socket shouldn't. */ | 3327 | /* We've stuffed all the events ourselves, so w32_read_socket shouldn't. */ |
| 3326 | event->kind = NO_EVENT; | 3328 | event->kind = NO_EVENT; |
| 3327 | } | 3329 | } |
| 3328 | #endif | 3330 | #endif /* WINDOWSNT */ |
| 3331 | #endif /* HAVE_W32NOTIFY */ | ||
| 3329 | 3332 | ||
| 3330 | 3333 | ||
| 3331 | /* Function to report a mouse movement to the mainstream Emacs code. | 3334 | /* Function to report a mouse movement to the mainstream Emacs code. |
| @@ -4968,7 +4971,7 @@ w32_read_socket (struct terminal *terminal, | |||
| 4968 | check_visibility = 1; | 4971 | check_visibility = 1; |
| 4969 | break; | 4972 | break; |
| 4970 | 4973 | ||
| 4971 | #ifdef WINDOWSNT | 4974 | #if HAVE_W32NOTIFY |
| 4972 | case WM_EMACS_FILENOTIFY: | 4975 | case WM_EMACS_FILENOTIFY: |
| 4973 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); | 4976 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); |
| 4974 | if (f) | 4977 | if (f) |
diff --git a/src/w32term.h b/src/w32term.h index 9c27c09d03d..be0b4a6f350 100644 --- a/src/w32term.h +++ b/src/w32term.h | |||
| @@ -683,7 +683,7 @@ extern Lisp_Object w32_get_watch_object (void *); | |||
| 683 | extern Lisp_Object lispy_file_action (DWORD); | 683 | extern Lisp_Object lispy_file_action (DWORD); |
| 684 | 684 | ||
| 685 | extern void w32_initialize_display_info (Lisp_Object); | 685 | extern void w32_initialize_display_info (Lisp_Object); |
| 686 | extern void initialize_w32_display (struct terminal *); | 686 | extern void initialize_w32_display (struct terminal *, int *, int *); |
| 687 | 687 | ||
| 688 | /* Keypad command key support. W32 doesn't have virtual keys defined | 688 | /* Keypad command key support. W32 doesn't have virtual keys defined |
| 689 | for the function keys on the keypad (they are mapped to the standard | 689 | for the function keys on the keypad (they are mapped to the standard |
diff --git a/src/xdisp.c b/src/xdisp.c index 9f3be44ecfd..5ae15cbd0b3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -12846,7 +12846,6 @@ redisplay_internal (void) | |||
| 12846 | struct frame *sf; | 12846 | struct frame *sf; |
| 12847 | int polling_stopped_here = 0; | 12847 | int polling_stopped_here = 0; |
| 12848 | Lisp_Object tail, frame; | 12848 | Lisp_Object tail, frame; |
| 12849 | struct backtrace backtrace; | ||
| 12850 | 12849 | ||
| 12851 | /* Non-zero means redisplay has to consider all windows on all | 12850 | /* Non-zero means redisplay has to consider all windows on all |
| 12852 | frames. Zero means, only selected_window is considered. */ | 12851 | frames. Zero means, only selected_window is considered. */ |
| @@ -12890,12 +12889,7 @@ redisplay_internal (void) | |||
| 12890 | specbind (Qinhibit_free_realized_faces, Qnil); | 12889 | specbind (Qinhibit_free_realized_faces, Qnil); |
| 12891 | 12890 | ||
| 12892 | /* Record this function, so it appears on the profiler's backtraces. */ | 12891 | /* Record this function, so it appears on the profiler's backtraces. */ |
| 12893 | backtrace.next = backtrace_list; | 12892 | record_in_backtrace (Qredisplay_internal, &Qnil, 0); |
| 12894 | backtrace.function = Qredisplay_internal; | ||
| 12895 | backtrace.args = &Qnil; | ||
| 12896 | backtrace.nargs = 0; | ||
| 12897 | backtrace.debug_on_exit = 0; | ||
| 12898 | backtrace_list = &backtrace; | ||
| 12899 | 12893 | ||
| 12900 | FOR_EACH_FRAME (tail, frame) | 12894 | FOR_EACH_FRAME (tail, frame) |
| 12901 | XFRAME (frame)->already_hscrolled_p = 0; | 12895 | XFRAME (frame)->already_hscrolled_p = 0; |
| @@ -13532,7 +13526,6 @@ redisplay_internal (void) | |||
| 13532 | #endif /* HAVE_WINDOW_SYSTEM */ | 13526 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 13533 | 13527 | ||
| 13534 | end_of_redisplay: | 13528 | end_of_redisplay: |
| 13535 | backtrace_list = backtrace.next; | ||
| 13536 | unbind_to (count, Qnil); | 13529 | unbind_to (count, Qnil); |
| 13537 | RESUME_POLLING; | 13530 | RESUME_POLLING; |
| 13538 | } | 13531 | } |
diff --git a/src/xgselect.c b/src/xgselect.c index 0b5ad6ae70d..38b9705e976 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 21 | 21 | ||
| 22 | #include "xgselect.h" | 22 | #include "xgselect.h" |
| 23 | 23 | ||
| 24 | #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) | 24 | #ifdef HAVE_GLIB |
| 25 | 25 | ||
| 26 | #include <glib.h> | 26 | #include <glib.h> |
| 27 | #include <errno.h> | 27 | #include <errno.h> |
| @@ -140,4 +140,4 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | |||
| 140 | 140 | ||
| 141 | return retval; | 141 | return retval; |
| 142 | } | 142 | } |
| 143 | #endif /* USE_GTK || HAVE_GCONF || HAVE_GSETTINGS */ | 143 | #endif /* HAVE_GLIB */ |