view nextstep/DEV-NOTES @ 107474:f7e5232d459a

Synch with Gnus trunk ===================== 2010-03-23 Katsumi Yamaoka <yamaoka@jpl.org> * gnus-art.el (canlock-verify): Autoload it for Emacs 21. * message.el (ecomplete-setup): Autoload it for Emacs <23. * mml-sec.el (mml-secure-cache-passphrase): Default to t that is password-cache's default if it is not bound. (mml-secure-passphrase-cache-expiry): Default to 16 that is password-cache-expiry's default if it is not bound. * pop3.el (pop3-list): Don't use 3rd arg of `split-string' which is not available in Emacs 21. 2010-03-23 Teodor Zlatanov <tzz@lifelogs.com> * auth-source.el (auth-sources): Fix up definition so extra parameters are always inline. 2010-03-22 Martin Stjernholm <mast@lysator.liu.se> * nnimap.el (nnimap-verify-uidvalidity): Fixed bug where uidvalidity wasn't updated after mismatch. Clear cached mailbox info correctly when uidvalidity changes. (nnimap-group-prefixed-name): New function to avoid some code duplication. (nnimap-verify-uidvalidity, nnimap-group-overview-filename) (nnimap-request-group): Use it. (nnimap-retrieve-groups, nnimap-verify-uidvalidity) (nnimap-update-unseen): Significantly improved speed of Gnus startup with many imap folders. This is done by caching the group status from the imap server persistently in a group parameter `imap-status'. (This was cached before too if `nnimap-retrieve-groups-asynchronous' was set, but not persistently, so every Gnus startup was still very slow.) 2010-03-20 Teodor Zlatanov <tzz@lifelogs.com> * auth-source.el: Set up autoloads. Bump to 23.2 because of the secrets.el dependency. (auth-sources): Add optional user name. Add secrets.el configuration choice (unused right now). 2010-03-20 Teodor Zlatanov <tzz@lifelogs.com> * gnus-sum.el (gnus-summary-make-menu-bar): Let `gnus-registry-install-shortcuts' fill in the functions. * gnus-registry.el (gnus-summary-misc-menu): Declare to avoid warnings. (gnus-registry-misc-menus): Variable to hold registry mark menus. (gnus-registry-install-shortcuts): Populate and use it in a `gnus-summary-menu-hook' lambda, under "Gnus"->"Registry Marks". 2010-03-20 Martin Stjernholm <mast@lysator.liu.se> * nnimap.el (nnimap-decode-group-name, nnimap-encode-group-name): In-place substitutions for the group name encoding/decoding. (nnimap-find-minmax-uid, nnimap-possibly-change-group) (nnimap-retrieve-headers-progress, nnimap-possibly-change-group) (nnimap-retrieve-headers-progress, nnimap-request-article-part) (nnimap-update-unseen, nnimap-request-list) (nnimap-retrieve-groups, nnimap-request-update-info-internal) (nnimap-request-set-mark, nnimap-split-to-groups) (nnimap-split-articles, nnimap-request-newgroups) (nnimap-request-create-group, nnimap-request-accept-article) (nnimap-request-delete-group, nnimap-request-rename-group) (nnimap-acl-get, nnimap-acl-edit): Use them. Replace `mbx' with `encoded-mbx' for consistency. (nnimap-close-group): Call `imap-current-mailbox' instead of using the variable `imap-current-mailbox'. * gnus-agent.el (gnus-agent-fetch-articles, gnus-agent-fetch-headers) (gnus-agent-regenerate-group): Use `gnus-agent-decoded-group-name'. 2010-03-20 Bojan Petrovic <bpetrovi@f.bg.ac.rs> * pop3.el (pop3-display-message-size-flag): Display message size byte counts during POP3 download. (pop3-movemail): Use it. (pop3-list): Implement listing of available messages. 2010-03-20 Mark Triggs <mst@dishevelled.net> (tiny change) * nnir.el (nnir-get-article-nov-override-function): New function to override the normal NOV retrieval. (nnir-retrieve-headers): Use it.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 23 Mar 2010 07:38:13 +0000
parents 3d0115eb5d66
children d268237e3481
line wrap: on
line source

This file summarizes primary aspects of the NS port architecture.  If
possible, it should be updated for changes.

Currently it summarizes the state as of:

  summer 2008 shortly after merging to trunk



Startup
-------

Init sequence:
  emacs.c: ns_alloc_autorelease_pool()		nsterm.m
  emacs.c: ns_init_paths()			nsterm.m
    - override EMACSLOADPATH, etc. so resources can be found in-bundle
  emacs.c: init_display()			dispnew.c
    - sets Vwindow_system (window-system) to 'ns
  emacs.c: loadup.el -> startup.el -> ns-initialize-window-system
    -> x-open-connection (nsfns.m)
      - ns-list-services
      -> nsterm.m: ns_term_init()
	- EmacsApp sharedApplication
	- read NS defaults (org.gnu.Emacs.plist)
	- init X-style color list
	- ns_create_terminal()
	- NSApp run (goes to applicationDidFinishLaunching which terminates
	  	     event loop -- see below)



Event Loop
----------

In an NS application, the event loop is normally managed by system and all
user code is event-driven.  [NSApp run] is called by user and never returns.

In Emacs, the event loop is managed by emacs itself.

The NS port mediates between these two styles by intercepting the NS event
dispatch at [NSApp sendEvent].  If a special event is detected, the event loop
is broken, and control returned to Emacs.  This special event is sent by
ns_send_appdefined, which is called under these circumstances:

 - if a user input event is received
 - when a timeout fires

NS event processing is instigated from Emacs through ns_select() and
ns_read_socket() in nsterm.m.  Parts of the codepaths leading to these
functions are:


 keyboard.c:read_avail_input()
     -> ns_read_socket (ns_send_appdefined) -> [NSApp run]

 process.c:wait_reading_process_output()
     -> ns_select -> gobble_input (global inNsSelect=1)
       -> ns_read_socket (ns_send_appdefined if !expected) -> [NSApp run]

 sysdep.c:sys_select() -> read_input_waiting()
     -> ns_read_socket (send_appdefined) -> [NSApp run]
 [this codepath may not be used]


Currently ctrl-g is not detected in as many circumstances as other emacsen.
It is not certain whether this is due to the means of event loop integration,
or errors of omission in the NS code.  One area for exploration is the
NO_SOCK_SIGIO define.  When it is defined, ctrl-g seems to be picked up more
often, but there are some annoying side effects.  Currently it is left off by
default, unless the --enable-cocoa-experimental-ctrl-g option is passed to
configure [option removed Feb 2009].  (Has no effect under GNUstep.)
This is an area for improvement.  Also, see the article here and its
containing thread:

http://article.gmane.org/gmane.emacs.devel/92021/match=handling%5fsignal




Text Rendering and Font Handling
--------------------------------

nsfont.m implements the font driver, responsible for managing fonts and
rendering text.  Fonts are obtained through NSFontManager.  Rendering must be
done at a low level due to emacs' fine control over this process, therefore
there are different approachs under Cocoa and GNUstep.  Under GNUstep, the
original NeXT Display PostScript (DPS) APIs are available and used.  Under
Cocoa, these were removed and Quartz drawing functions replaced them.

In both cases, font glyphs are accessed through UTF8 character
representations.  It would be preferable to use unicode indices, but prior
attempts at this have failed.

Multi-script fontsets are auto-created in nsfont_make_fontset_for_font() using
the facilities of NSTextStorage and NSLayoutManager.


Object Architecture
-------------------

Unlike the other GUIs, the NS interface is based on a high-level and
object-oriented API.  This creates some tension in the code because emacs
itself has been architected around the low-level Xlib and Xt APIs.  The NS
port tries to strike a balance between simplifying code on its side using OO
features, and keeping code as similar as possible to other ports to ease
maintenance.  The following are the main classes (see nsterm.h):

EmacsApp : NSApplication
  - event loop integration, interapp comms point for Finder (NSWorkspace) msgs,
    Services
  - one global instance (NSApp)
  - nsterm.m

EmacsView : NSView <TextInput>
  - handles rendering of text and fringe, interapp comms for drag/drop
  - instance for each frame
  - child of window's content view
  - nsterm.m

EmacsWindow : NSWindow
  - utility override for resize handling

EmacsScroller : NSScroller
  - instance for each emacs window, renders scrollbar
  - child of window's content view
  - nsterm.m

EmacsImage : NSImage
  - image rendering, toolbar icons, stippling, fringe bitmaps
  - instance for each image
  - nsimage.m

EmacsMenu : NSMenu
  - menu management
  - one tree of instances for menubar, one instance for each popup menu
  - nsmenu.m

EmacsToolbar : NSToolbar
  - toolbar management, one instance for each frame
  - nsmenu.m


EmacsDialogPanel : NSPanel
  - popup dialogs, one instance for each
  - nsmenu.m

EmacsTooltip : NSObject
  - tooltip popups, one instance for each
  - nsmenu.m

EmacsGlyphStorage : NSObject <NSGlyphStorage>
  - utility for text rendering
  - nsfont.m

EmacsPrefsController : NSObject
  - utility for preferences panel management, one global instance
  - nsterm.m
  - nextstep/Cocoa/Emacs.base/Contents/Resources/preferences.nib
  - nextstep/GNUstep/Emacs.base/Resources/preferences.gorm

EmacsSavePanel : NSSavePanel
EmacsOpenPanel : NSOpenPanel
  - utility override for panel notifications