diff options
author | Alan Third <alan@idiocy.org> | 2018-03-30 12:25:15 +0100 |
---|---|---|
committer | Alan Third <alan@idiocy.org> | 2018-03-30 12:33:42 +0100 |
commit | 733279abedc598a927e66c6f6ac10d1bd9271e79 (patch) | |
tree | 909ed5dfa6e2bedbc03ab73164590f1ddbb3d3f0 /src/nsfns.m | |
parent | ef0617888c452d1a62d354b3d866f17eea2e1ced (diff) | |
download | emacs-733279abedc598a927e66c6f6ac10d1bd9271e79.tar.gz emacs-733279abedc598a927e66c6f6ac10d1bd9271e79.tar.bz2 emacs-733279abedc598a927e66c6f6ac10d1bd9271e79.zip |
Simplify represented filename handling (bug#30800)
* src/nsfns.m (ns_set_represented_filename): Move function from
nsterm.m and set represented filename directly.
* src/nsterm.h (ns_set_represented_filename): Remove definition.
* src/nsterm.m (ns_set_represented_filename): Move function to
nsfns.m.
(x_free_frame_resources): Remove references to represented_frame.
(sendEvent): Don't set represented filename.
Diffstat (limited to 'src/nsfns.m')
-rw-r--r-- | src/nsfns.m | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/nsfns.m b/src/nsfns.m index 6df54b4eb50..7cf45a54f90 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -463,6 +463,47 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) ns_set_name_internal (f, name); } +static void +ns_set_represented_filename (struct frame *f) +{ + Lisp_Object filename, encoded_filename; + Lisp_Object buf = XWINDOW (f->selected_window)->contents; + NSAutoreleasePool *pool; + NSString *fstr; + NSView *view = FRAME_NS_VIEW (f); + + NSTRACE ("ns_set_represented_filename"); + + if (f->explicit_name || ! NILP (f->title)) + return; + + block_input (); + pool = [[NSAutoreleasePool alloc] init]; + filename = BVAR (XBUFFER (buf), filename); + + if (! NILP (filename)) + { + encoded_filename = ENCODE_UTF_8 (filename); + + fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)]; + if (fstr == nil) fstr = @""; + } + else + fstr = @""; + +#ifdef NS_IMPL_COCOA + /* Work around a bug observed on 10.3 and later where + setTitleWithRepresentedFilename does not clear out previous state + if given filename does not exist. */ + if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr]) + [[view window] setRepresentedFilename: @""]; +#endif + [[view window] setRepresentedFilename: fstr]; + + [pool release]; + unblock_input (); +} + /* This function should be called when the user's lisp code has specified a name for the frame; the name will override any set by the |