Commits

Ronny Pfannschmidt  committed 4b9ab06

kill the emacs editor support

  • Participants
  • Parent commits 5c7ba89

Comments (0)

Files changed (14)

File pida/editors/emacs/__init__.py

-from .emacs import Emacs as Service

File pida/editors/emacs/emacs.py

-# -*- coding: utf-8 -*- 
-
-"""
-    The Emacs editor core classes for Pida
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    This module and other Pida Emacs related classes
-    are based on preliminary worksby Ali Afshar
-    (see Emacs module in Pida 0.2.2).
-
-    The Emacs editor for Pida is also,
-    heavily based on the Vim editor.
-
-    :copyright: 2007-2008 by The PIDA Project
-    :license: GPL 2 or later (see README/COPYING/LICENSE)
- 
-""" 
-
-
-import os
-
-# PIDA Imports
-import pida.core.environment as env
-
-from pida.ui.views import PidaView
-
-from pida.core.editors import EditorService 
-
-# Emacs specific
-from .emacsembed import EmacsEmbedWidget
-from .emacscom import EmacsClient
-
-from pida.core.pdbus import DbusConfig
-from pida.utils.pdbus import EXPORT
-
-EEXPORT = EXPORT(suffix='emacs')
-
-class EmacsView(PidaView):
-    """
-    UI class for emacs editor 
-    uses EmacsEmbedWidget to integrate into a PidaView widget
-    """
-    def create_ui(self):
-        self._emacs = EmacsEmbedWidget(
-            'emacs',
-            self.svc.initscript,
-             ['-eval', '(pida-connect 1001)']
-        )
-        self.add_main_widget(self._emacs)
-
-    def run(self):
-        self._emacs.run()
-
-    def grab_input_focus(self):
-        self._emacs.grab_input_focus()
-
-
-class EmacsCallback(object):
-    """Emacs editor callback behaviours.
-
-    Communication is done over dbus 
-    """
-
-    def __init__(self, svc):
-        """Constructor."""
-        self._log = svc.log
-        self._svc = svc
-
-    def em_BufferOpen(self, filename):
-        """File opened event."""
-        if filename:
-            self._log.debug('emacs buffer opened "%s"' % filename)
-            self._svc.boss.cmd('buffer', 'open_file', file_name=filename)
-        return True
-
-    def em_BufferChange(self, filename):
-        """Buffer changed event.
-        Actually, this hook is called whenever the window containing the
-        buffer changes. So notification can occur only when window is resized
-        or split for example.
-        """
-        self._svc.top_buffer = filename
-        current = self._svc.current_document
-        try:
-            if filename and (not current or current.filename != filename):
-                self._log.debug('emacs buffer changed "%s"' % filename)
-                if os.path.isdir(filename):
-                    self._svc.boss.cmd('filemanager', 'browse', 
-                                       new_path=filename)
-                    self._svc.boss.cmd('filemanager', 'present_view')
-                else:
-                    self._svc.boss.cmd('buffer', 'open_file', 
-                                       file_name=filename)
-        except IOError:
-            pass
-        return True
-
-
-    def em_BufferClose(self, filename):
-        """Buffer closed event."""
-        if filename:
-            self._log.debug('emacs buffer killed "%s"' % filename)
-            self._svc.remove_file(filename)
-            self._svc.boss.cmd('buffer', 'close_file', file_name=filename)
-        return True
-
-    def em_BufferSave(self, filename):
-        """Buffer saved event."""
-        self._log.debug('emacs buffer saved "%s"' % filename)
-        self._svc.boss.cmd('buffer', 'current_file_saved')
-        return True
-
-    def em_EmacsKill(self):
-        """Emacs killed event."""
-        self._log.debug('emacs killed')
-        self._svc.inactivate_client()
-        self._svc.boss.stop(force=True)
-        return False
-
-class EmacsDbusConfig(DbusConfig):
-    
-
-    @EEXPORT(out_signature = '', in_signature = '')
-    def EmacsEnter(self):
-        """
-        This method is called by emacs to notify emacs is started.
-        """
-        self.svc.emit_editor_started()
-
-class Emacs(EditorService):
-    """The Emacs service.
-    This service is the Emacs editor driver. 
-    """ 
-    dbus_config = EmacsDbusConfig
-
-    def _create_initscript(self):
-        return env.get_data_path('pida_emacs_dbus.el')
-
-    def emit_editor_started(self):
-        """called when emacs started: Let notify the other services 
-        and connect to dbus signals
-        """
-        self._cb = EmacsCallback(self)
-        self._client = EmacsClient(self._cb, self)
-        self._client.connect_signals()
-        self.boss.get_service('editor').emit('started')
-        
-    def pre_start(self):
-        """Start the editor"""
-        self._documents = {}
-
-        # The current document. Its value is set by Pida and used to drop
-        # useless messages to emacs.
-        self._current = None
-
-        # The current buffer displayed. Its value is set by the EmacsCallback
-        # instance and is used as well to prevent sending useless messages.
-        self._top_buffer = ''
-
-        self._current_line = 1
-
-        #Start Emacs view
-        self.initscript = self._create_initscript()
-        self._view = EmacsView(self)
-        self.boss.window.add_view(paned='Editor', view=self._view)
-        self._view.run()
-
-
-    def stop(self):
-        try:
-            self._client.quit()
-        except AttributeError:
-            # gets stopped before the client can register
-            pass
-
-    def _get_current_document(self):
-        return self._current
-
-    def _set_current_document(self, document):
-        self._current = document
-
-    current_document = property(fget=_get_current_document,
-                                fset=_set_current_document,
-                                fdel=None,
-                                doc="The document currently edited")
-
-    def _get_top_buffer(self):
-        return self._top_buffer
-
-    def _set_top_buffer(self, filename):
-        self._top_buffer = filename
-
-    top_buffer = property(fget=_get_top_buffer,
-                          fset=_set_top_buffer,
-                          fdel=None,
-                          doc="Last buffer reported as being viewed by emacs")
-
-    def inactivate_client(self):
-        pass
-
-    def open(self, document):
-        """Open a document"""
-        if document is not self._current:
-            if self.top_buffer != document.filename:
-                if document.unique_id in self._documents:
-                    self._client.change_buffer(document.filename)
-                else:
-                    self._client.open_file(document.filename)
-                    self._documents[document.unique_id] = document
-            self.current_document = document
-
-    def close(self, document):
-        if document.unique_id in self._documents:
-            self._remove_document(document)
-            self._client.close_buffer(document.filename)
-        return True
-
-    def remove_file(self, filename):
-        document = self._get_document_for_filename(filename)
-        if document is not None:
-            self._remove_document(document)
-
-    def _remove_document(self, document):
-        del self._documents[document.unique_id]
-
-    def _get_document_for_filename(self, filename):
-        for uid, doc in self._documents.iteritems():
-            if doc.filename == filename:
-                return doc
-            
-    def close_all(self):
-        """Close all the documents"""
-
-    def save(self):
-        """Save the current document"""
-        self._client.save_buffer()
-
-    def save_as(self, filename):
-        """Save the current document as another filename"""
-        pass # TODO
-
-    def goto_line(self, line):
-        """Goto a line"""
-        self._client.goto_line(line)
-        self.grab_focus()
-
-    def cut(self):
-        """Cut to the clipboard"""
-        self._client.cut()
-
-    def copy(self):
-        """Copy to the clipboard"""
-        self._client.copy()
-
-    def paste(self):
-        """Paste from the clipboard"""
-        self._client.paste()
-
-    def undo(self):
-        self._client.undo()
-
-    def redo(self):
-        self._client.redo()
-
-    def grab_focus(self):
-        """Grab the focus"""
-        self._view.grab_input_focus()
-
-    def define_sign_type(self, name, icon, linehl, text, texthl):
-        # TODO
-        pass
-    
-    def undefine_sign_type(self, name):
-        # TODO
-        pass
-    
-    def show_sign(self, sign_type, filename, line):
-        # TODO
-        pass
-    
-    def hide_sign(self, sign_type, filename, line):
-        # TODO
-        pass
-    
-    def set_current_line(self, line_number):
-        self._current_line = line_number
-
-    def get_current_line(self):
-        return self._current_line
-
-    def set_path(self, path):
-        return self._client.set_directory(path)
-
-    @classmethod
-    def get_sanity_errors(cls):
-        errors = []
-        from pida.core.pdbus import has_dbus
-        if not has_dbus:
-            errors = [
-                'dbus python disfunctional',
-                'please repair the python dbus bindings',
-                '(note that it won\'t work for root)'
-            ]
-
-        try:
-            import subprocess
-            p = subprocess.Popen(
-                    ['emacs', '--version'],
-                    stdout=subprocess.PIPE,
-                    )
-            data, _ = p.communicate()
-        except OSError:
-            errors.extend([
-                'emacs not found',
-                'please install emacs23 with python support'
-            ])
-        return errors
-
-# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

File pida/editors/emacs/emacscom.py

-# -*- coding: utf-8 -*-
-"""
-    communication with emacs using dbus
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    :copyright: 2005-2009 by The PIDA Project
-    :license: GPL 2 or later (see README/COPYING/LICENSE)
-"""
-
-import os
-import time
-
-try:
-    import dbus
-    from dbus.mainloop.glib import DBusGMainLoop
-    mainloop = DBusGMainLoop(set_as_default=True)
-except ImportError:
-    pass
-
-class EmacsClient(object):
-    
-    def __init__(self, callback, svc):
-        self._log = svc.log
-        self._callback = callback
-        self._svc = svc
-        session = dbus.SessionBus()
-        proxy = None
-        namespace = '.'.join(['uk.co.pida.Emacs', 
-                       os.environ["PIDA_DBUS_UUID"]])
-        try:
-            proxy = dbus.Interface(
-                session.get_object(namespace, '/uk/co/pida/Emacs'),'uk.co.pida.Emacs')
-        except dbus.DBusException:
-            log.debug('emacs connect failed')
-            raise SystemExit('emacs failed')
-        self.proxy = proxy
-
-    def connect_signals(self):
-        """
-        Register dbus signals from emacs
-        """
-        for evt in ['BufferOpen', 'BufferClose', 'BufferSave', 
-                    'BufferChange', 'EmacsKill']:
-            self.proxy.connect_to_signal(evt, 
-                                         getattr(self._callback, 
-                                                 'em_%s' % evt),
-                                         dbus_interface=
-                                         "uk.co.pida.Emacs")
-        self.frame_setup()
-
-    def quit(self):
-        """
-        Quit pida - notify emacs
-        """
-        self._log.debug('Stop Emacs')
-        self.proxy.StopEmacs(reply_handler=lambda *a: None,
-                             error_handler=lambda *a: None,
-                             dbus_interface="uk.co.pida.Emacs")
-
-    def open_file(self, file_name):
-        self._log.debug('Open File %s'% file_name)
-        self.proxy.OpenFile(file_name, dbus_interface="uk.co.pida.Emacs")
-
-    def change_buffer(self, file_name):
-        self._log.debug('Change Buffer to %s' % file_name)
-        self.proxy.ChangeBuffer(file_name, dbus_interface="uk.co.pida.Emacs")
-
-    def close_buffer(self, file_name):
-        self._log.debug('Close Buffer for %s' % file_name)
-        self.proxy.CloseBuffer(file_name, dbus_interface="uk.co.pida.Emacs")
-
-    def save_buffer(self):
-        self._log.debug('Save Buffer %s' % self._svc.current_document.filename)
-        self.proxy.SaveBuffer(self._svc.current_document.filename, 
-                              dbus_interface="uk.co.pida.Emacs")
-
-    def cut(self):
-        self._log.debug('Cut')
-        self.proxy.Cut(self._svc.current_document.filename, 
-                       dbus_interface="uk.co.pida.Emacs")
-
-    def copy(self):
-        self._log.debug('Copy')
-        self.proxy.Copy(self._svc.current_document.filename, 
-                        dbus_interface="uk.co.pida.Emacs")
-
-    def undo(self):
-        self._log.debug('Undo')
-        self.proxy.Undo(dbus_interface="uk.co.pida.Emacs")
-        
-    def redo(self):
-        self._log.debug('No Redo - only reverse undo')
-
-    def paste(self):
-        self._log.debug('Paste')
-        self.proxy.Paste(self._svc.current_document.filename, 
-                         dbus_interface="uk.co.pida.Emacs")
-
-    def goto_line(self, line):
-        self._log.debug('Goto Line %s'% line)
-        self.proxy.GotoLine(self._svc.current_document.filename, 
-                            line, 
-                            dbus_interface="uk.co.pida.Emacs")
-
-    def frame_setup(self):
-        self._log.debug('Setup the menu Bars')
-        self.proxy.FrameSetup(None, dbus_interface="uk.co.pida.Emacs",
-                              reply_handler=lambda *a: None,
-                              error_handler=lambda *a: None)
-    
-    def set_directory(self, path):
-        self._log.debug('Set Directory to %s' % path)
-        self.proxy.SetDirectory(path, 
-                                reply_handler=lambda *a: None,
-                                error_handler=lambda *a: None, 
-                                dbus_interface="uk.co.pida.Emacs")
-        return None
-        
-
-# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

File pida/editors/emacs/emacsembed.py

-# -*- coding: utf-8 -*-
-"""
-    This module provides the widget 
-    which is responsible to embed Emacs for Pida.
-
-    :copyright: 2005-2008 by The PIDA Project
-    :license: GPL 2 or later (see README/COPYING/LICENSE)
-
-
-This work was made possible thanks to the Emacs patches written by Timo Savola
-for his own embedding of Emacs with his Encode project
-(http://encode.sourceforge.net/).
-"""
-
-import subprocess
-import gtk
-
-class EmacsEmbedWidget(gtk.EventBox):
-    """A widget embedding Emacs.
-    
-    The EmacsEmbedWidget makes use of a GTK socket to embed an Emacs frame inside
-    a GTK application. The widget is also a GTK Event Box, so key events are
-    available.
-    """
-
-    def __init__(self, command, script_path, args=[]):
-        """Constructor."""
-        gtk.EventBox.__init__(self)
-        self._command = command
-        self._init_script = script_path
-        self._pid = None
-        self._args = args
-
-    def run(self):
-        """Start the editor using Popen"""
-        if not self._pid:
-            xid = self._create_ui()
-            if xid:
-                args = ['--parent-id', '%s' % xid,
-                        '-l', '%s' % self._init_script]
-                args.extend(self._args)
-                popen = subprocess.Popen([self._command] + args, 
-                                         close_fds=True)
-                self._pid = popen.pid
-        self.show_all()
-
-    def grab_input_focus(self):
-        """Give focus to editor"""
-        self.child_focus(gtk.DIR_TAB_FORWARD)
-
-    def _create_ui(self):
-        """Instantiate the GTK socket.
-
-        Called by the run method before the widget is realized.
-        """
-        socket = gtk.Socket()
-        self.add_events(gtk.gdk.KEY_PRESS_MASK)
-        self.add(socket)
-        self.show_all()
-        return socket.get_id()
-# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

File pida/editors/emacs/share/completion/auto-overlay-common.el

-
-;;; auto-overlay-common.el --- general overlay functions
-
-
-;; Copyright (C) 2006 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.1.1
-;; Keywords: automatic, overlays
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is part of the Emacs Automatic Overlays package.
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Change Log:
-;;
-;; Version 0.1.1
-;; * bugfix in `auto-overlay-local-binding'
-;;
-;; Version 0.1
-;; * initial version split from auto-overlays
-
-
-
-;;; Code:
-
-
-(provide 'auto-overlay-common)
-
-
-(defun auto-overlays-at-point (&optional point prop-test inactive)
-  "Return overlays overlapping POINT (or the point, if POINT is
-null). If PROP-TEST is supplied, it should be a list which
-specifies a property test with one of the following forms (or a
-list of such lists if more than one property test is required):
-
-  (FUNCTION PROPERTY)
-
-  (FUNCTION PROPERTY VALUE)
-
-  (FUNCTION (PROPERTY1 PROPERTY2 ...) (VALUE1 VALUE2 ...))
-
-where PROPERTY indicates an overlay property name (a symbol), and
-VALUE indicates an arbitrary value or lisp expression.
-
-For each overlay between START and END, first the values
-corresponding to the property names are retrieved from the
-overlay, then FUNCTION is called with the properties values
-followed by the other values as its arguments. The test is
-satisfied if the result is non-nil, otherwise it fails. Tests are
-evaluated in order, but only up to the first failure. Only
-overlays that satisfy all property tests are returned.
-
-If INACTIVE is non-nil, both active and inactive overlays are
-returned (usually inactive ones are ignored).
-
-Note that this function returns any overlay. If you want to
-restrict it to auto overlays, include '(identity auto-overlay) in
-PROP-TEST."
-  (when (null point) (setq point (point)))
-  
-  (let (overlay-list)
-    ;; get overlays overlapping POINT and zero-length overlays at POINT
-    (setq overlay-list
-	  (auto-overlays-in point point prop-test nil inactive))
-    ;; get overlays that end at POINT
-    (dolist (o (auto-overlays-in (1- point) point prop-test nil inactive))
-      (when (and (< (overlay-start o) point)
-		 (= (overlay-end o) point))
-	(push o overlay-list)))
-    ;; get overlays that start at POINT
-    (dolist (o (auto-overlays-in point (1+ point) prop-test nil inactive))
-      (when (and (> (overlay-end o) point)
-		 (= (overlay-start o) point))
-	(push o overlay-list)))
-    
-    overlay-list)
-)
-
-
-
-;; FIXME: get rid of INACTIVE argument
-(defun auto-overlays-in (start end &optional prop-test within inactive)
-  "Return auto overlays overlapping region between START and END.
-
-If PROP-TEST is supplied, it should be a list which specifies a
-property test with one of the following forms (or a list of such
-lists if more than one property test is required):
-
-  (FUNCTION PROPERTY)
-
-  (FUNCTION PROPERTY VALUE)
-
-  (FUNCTION (PROPERTY1 PROPERTY2 ...) (VALUE1 VALUE2 ...))
-
-where PROPERTY indicates an overlay property name (a symbol), and
-VALUE indicates an arbitrary value or lisp expression.
-
-For each overlay between START and END, first the values
-corresponding to the property names are retrieved from the
-overlay, then FUNCTION is called with the properties values
-followed by the other values as its arguments. The test is
-satisfied if the result is non-nil, otherwise it fails. Tests are
-evaluated in order, but only up to the first failure. Only
-overlays that satisfy all property tests are returned.
-
-If WITHIN is non-nil, only overlays entirely within START and END
-are returned. If INACTIVE is non-nil, both active and inactive
-overlays are returned (usually inactive ones are ignored).
-
-Note that this function returns any overlay. If you want to
-restrict it to auto overlays, include '(identity auto-overlay) in
-PROP-TEST."
-
-  ;; make sure prop-test is a list of lists, even if there's only one, and
-  ;; exclude inactive overlays unless told not to
-  (cond
-   ((null prop-test)
-    (unless inactive (setq prop-test '((null inactive)))))
-   ((functionp (car prop-test))
-    (if inactive
-	(setq prop-test (list prop-test))
-      (setq prop-test (list '(null inactive) prop-test))))
-   (t
-    (unless inactive (setq prop-test (push '(null inactive) prop-test)))))
-  
-  (let (overlay-list function prop-list value-list result)    
-    ;; check properties of each overlay in region
-    (dolist (o (overlays-in start end))
-      ;; check overlay is entirely within region
-      (if (and within
-	       (or (< (overlay-start o) start) (> (overlay-end o) end)))
-	  (setq result nil)
-	
-	;; if it is, or we don't care
-	(setq result t)
-	(catch 'failed
-	  ;; check if properties match
-	  (dolist (test prop-test)
-	    ;; (Note: the whole thing would be neater with something like
-	    ;; (apply 'and (map ...)) but 'and is a special form, not a
-	    ;; function, so can't be applied)
-	    (setq function (nth 0 test))
-	    (unless (listp (setq prop-list (nth 1 test)))
-	      (setq prop-list (list prop-list)))
-	    (setq value-list nil)
-	    (unless (or (< (length test) 3)
-			(and (setq value-list (nth 2 test))  ; nil isn't list
-			     (listp value-list)))
-	      (setq value-list (list value-list)))
-	    
-	    ;; apply the test
-	    (setq result
-		  (and result
-		       (apply function
-			      (append (mapcar (lambda (p) (overlay-get o p))
-					      prop-list)
-				      value-list))))
-	    (when (null result) (throw 'failed nil)))))
-      
-      ;; add overlay to result list if its properties matched
-      (when result (push o overlay-list)))
-    ;; return result list
-    overlay-list)
-)
-
-
-
-(defun auto-overlay-highest-priority-at-point (&optional point proptest)
-  "Return highest priority overlay at POINT (defaults to the point).
-
-If two overlays have the same priority, the innermost one takes
-precedence (i.e. the one that begins later, or if they begin at
-the same point the one that ends earlier).
-
-See `auto-overlays-at' for ane explanation of the PROPTEST argument."
-  
-  (unless point (setq point (point)))
-  
-  ;; get all overlays at point with a non-nil SYMBOL property
-  (let* ((overlay-list (auto-overlays-at-point point proptest))
-	 (overlay (pop overlay-list))
-	 p p1)
-
-    ;; find the highest priority, innermost overlay
-    (dolist (o1 overlay-list)
-      (setq p (overlay-get overlay 'priority))
-      (setq p1 (overlay-get o1 'priority))
-      (when (or (and (null p) p1)
-		(and p p1 (> p1 p))
-		(and (equal p1 p)
-		     (or (> (overlay-start o1) (overlay-start overlay))
-			 (and (= (overlay-start o1) (overlay-start overlay))
-			      (< (overlay-end o1) (overlay-end o1))))))
-	(setq overlay o1)))
-
-    ;; return the overlay
-    overlay)
-)
-
-
-
-(defun auto-overlay-local-binding (symbol &optional point)
-  "Return \"overlay local \" binding of SYMBOL at POINT,
-or the current local binding if there is no overlay
-binding. POINT defaults to the point.
-
-An \"overlay local\" binding is creating by giving an overlay a
-non-nil value for a property named SYMBOL. If more than one
-overlay at POINT has a non-nil SYMBOL property, the value from
-the highest priority overlay is returned.
-
-See `auto-overlay-highest-priority-at-point' for a definition of
-\"highest priority\"."
-  
-  (let ((overlay (auto-overlay-highest-priority-at-point
-		  point `(identity ,symbol))))
-    (if overlay
-	(overlay-get overlay symbol)
-      (when (boundp symbol) (eval symbol))))
-)
-
-;; auto-overlay-common.el ends here

File pida/editors/emacs/share/completion/auto-overlay-flat.el

-
-;;; auto-overlay-flat.el --- flat start/end-delimited automatic overlays
-
-
-;; Copyright (C) 2006-2008 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.1.2
-;; Keywords: automatic, overlays, flat, unnested
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is part of the Emacs Automatic Overlays package.
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Change Log:
-;;
-;; Version 0.1.2
-;; * added new `auto-overlay-complex-class' property
-;; * renamed 'entry-id and 'subentry-id to 'definition-id and 'regexp-id
-;;
-;; Version 0.1.1
-;; * set overlay properties straight after creation, rather than leaving it to
-;;   `auto-overlay-update', in case matching causes exclusive reparsing, for
-;;   which properties are already required
-;;
-;; Version 0.1
-;; * initial version
-
-
-
-;;; Code:
-
-
-(require 'auto-overlays)
-(provide 'auto-overlay-flat)
-
-
-;; set flat overlay parsing and suicide functions, and indicate class requires
-;; separate start and end regexps
-(put 'flat 'auto-overlay-parse-function 'auto-o-parse-flat-match)
-(put 'flat 'auto-overlay-suicide-function 'auto-o-flat-suicide)
-(put 'flat 'auto-overlay-complex-class t)
-
-
-
-(defun auto-o-parse-flat-match (o-match)
-  ;; Perform any necessary updates of auto overlays due to a match for a flat
-  ;; regexp.
-
-  (let (o-parent)
-    (cond
-
-     ;; if match is for a start regexp...
-     ((eq (auto-o-edge o-match) 'start)
-      ;; if match is within an existing overlay, ignore match
-      (unless (auto-overlays-at-point
-	       (overlay-get o-match 'delim-end)  ; FIXME: is this right?
-	       `((identity auto-overlay)
-		 (eq set-id ,(overlay-get o-match 'set-id))
-		 (eq definition-id ,(overlay-get o-match 'definition-id))))
-
-	;; otherwise, look for next end-match...
-	(let ((o-end (auto-o-next-flat-match o-match 'end)))
-	  (cond
-	   ;; if there is one that has a parent, steal start of the parent
-	   ;; overlay
-	   ((and o-end (overlay-get o-end 'parent))
-	    (auto-o-match-overlay (overlay-get o-end 'parent) o-match)
-	    nil)  ; return nil since haven't created any overlays
-
-	   ;; if there is one but it's parentless, make a new overlay, match
-	   ;; it with O-MATCH and the next end-match, and return it
-	   (o-end
-	    (let ((pos (overlay-get o-match 'delim-end)))
-	      (setq o-parent (make-overlay pos pos nil nil 'rear-advance)))
-	    (overlay-put o-parent 'auto-overlay t)
-	    (overlay-put o-parent 'set-id (overlay-get o-match 'set-id))
-	    (overlay-put o-parent 'definition-id
-			 (overlay-get o-match 'definition-id))
-	    (auto-o-match-overlay o-parent o-match o-end)
-	    o-parent)
-
-	   (t ;; otherwise, make a new, end-unmatched overlay and return it
-	    (let ((pos (overlay-get o-match 'delim-end)))
-	      (setq o-parent (make-overlay pos pos nil nil 'read-advance))
-	      (overlay-put o-parent 'auto-overlay t)
-	      (overlay-put o-parent 'set-id (overlay-get o-match 'set-id))
-	      (overlay-put o-parent 'definition-id
-			   (overlay-get o-match 'definition-id))
-	      (auto-o-match-overlay o-parent o-match 'unmatched)
-	      o-parent))
-	   ))))
-
-
-     (t ;; if match is for an end regexp...
-      ;; if match is within existing overlay with same set-d and definition-id...
-      (when (setq o-parent
-		(car  ; FIXME: is this right?
-		 (auto-overlays-at-point
-		  (overlay-get o-match 'delim-start)  ; FIXME: is this right?
-		  `((identity auto-overlay)
-		    (eq set-id ,(overlay-get o-match 'set-id))
-		    (eq definition-id ,(overlay-get o-match 'definition-id))))))
-
-	;; if overlay can simply be re-matched with new end-match, do so
-	(let ((o-end (overlay-get o-parent 'end))
-	      (o-start (auto-o-next-flat-match o-match 'start)))
-	  (if (not (and o-end o-start
-			(<= (overlay-get o-start 'delim-end)
-			    (overlay-get o-end 'delim-start))))
-	      (progn (auto-o-match-overlay o-parent nil o-match) nil)
-
-	    ;; if overlay was end-matched, and there's a start match within
-	    ;; existing overlay that will be "unmasked" when end is stolen,
-	    ;; create a new overlay between that start match and the end match
-	    ;; we're stealing from
-	    (auto-o-match-overlay o-parent nil o-match)
-	    (let ((pos (overlay-get o-start 'delim-end)))
-	      (setq o-parent (make-overlay pos pos nil nil 'read-advance))
-	      (overlay-put o-parent 'auto-overlay t)
-	      (overlay-put o-parent 'set-id (overlay-get o-match 'set-id))
-	      (overlay-put o-parent 'definition-id
-			   (overlay-get o-match 'definition-id))
-	      (auto-o-match-overlay o-parent o-start o-end))
-	    o-parent))  ; return newly created overlay
-	))))
-)
-
-
-
-(defun auto-o-flat-suicide (o-self)
-  ;; Called when match no longer matches. Unmatch the match overlay O-SELF,
-  ;; re-matching or deleting its parent overlay as necessary.
-
-  (let ((o-parent (overlay-get o-self 'parent)))
-    (cond
-     ;; if we have no parent, don't need to do anything
-     ((null o-parent))
-
-     ;; if we're a start-match...
-     ((eq (auto-o-edge o-self) 'start)
-      ;; if parent is end-unmatched, delete parent
-      (if (null (overlay-get o-parent 'end))
-	  (auto-o-delete-overlay o-parent)
-
-	;; otherwise, look for next start match...
-	(let ((o-start (auto-o-next-flat-match o-self 'start)))
-	  ;; if there is one, match parent with it
-	  (if o-start
-	      (auto-o-match-overlay o-parent o-start)
-	    ;; otherwise, delete parent
-	    (auto-o-delete-overlay o-parent)))))
-
-
-     (t ;; if we're an end-match, look for next end-match...
-      (let ((o-start (overlay-get o-parent 'start))
-	    (o-end (auto-o-next-flat-match o-self 'end)))
-	(cond
-	 ;; if there is one, match parent with it
-	 (o-end
-	  ;; if end-match already has a parent, delete it as its now
-	  ;; superfluous (note: no need to parse, since parent overlay will be
-	  ;; extended to cover same region anyway)
-	  (when (overlay-get o-end 'parent)
-	    (auto-o-delete-overlay (overlay-get o-end 'parent) 'no-parse))
-	  (auto-o-match-overlay o-parent nil o-end))
-
-	 (t ;; otherwise, make parent end-unmatched
-	  (auto-o-match-overlay o-parent nil 'unmatched)))))
-     ))
-)
-
-
-
-(defun auto-o-next-flat-match (o-match edge)
-  ;; Find first match overlay for EDGE ('start of 'end) after match overlay
-  ;; O-MATCH in buffer, with same set-id and definition-id as O-MATCH.
-
-  ;; get sorted list of matching overlays after O-MATCH
-  (let ((o-list
-	 (sort (auto-overlays-in
-		(overlay-start o-match) (point-max)  ; FIXME: is start right?
-		`((identity auto-overlay-match)
-		  (eq set-id ,(overlay-get o-match 'set-id))
-		  (eq definition-id ,(overlay-get o-match 'definition-id))
-		  (,(lambda (set-id definition-id regexp-id edge)
-		      (eq (auto-o-entry-edge set-id definition-id regexp-id)
-			  edge))
-		   (set-id definition-id regexp-id) (,edge))))
-	       (lambda (a b) (<= (overlay-start a) (overlay-start b))))))
-    ;; if searching for same EDGE as O-MATCH, first overlay in list is always
-    ;; O-MATCH itself, so we drop it
-    (if (eq (auto-o-edge o-match) edge) (nth 1 o-list) (car o-list)))
-)
-
-
-
-;;; auto-overlay-flat.el ends here

File pida/editors/emacs/share/completion/auto-overlay-line.el

-
-;;; auto-overlay-line.el --- automatic overlays for single lines
-
-
-;; Copyright (C) 2005-2007 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.3.4
-;; Keywords: automatic, overlays, line
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is part of the Emacs Automatic Overlays package.
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Change Log:
-;;
-;; Version0.3.4
-;; * renamed 'entry-id and 'subentry-id to 'definition-id and 'regexp-id
-;;
-;; Version 0.3.3
-;; * set overlay properties straight after creation, rather than leaving it to
-;;   `auto-overlay-update', in case matching causes exclusive reparsing, for
-;;   which properties are already required
-;;
-;; Version 0.3.2
-;; * removed `auto-overlay-functions' and changed to use new interface
-;;
-;; Version 0.3.1
-;; * updated to reflect changes in `auto-overlays.el'
-;;
-;; Version 0.3
-;; * updated `auto-o-extend-line' to bring it into line with new procedure for
-;;   calling functions after a buffer modification
-;;
-;; Version 0.2.1
-;; * bug fixes in auto-o-extend-line
-;;
-;; Version 0.2:
-;; * got rid of fake end match overlays, which ensured the overlay always
-;;   extended to end of line, in favour of adding a function to the
-;;   modification hooks of the line overlay itself
-;;
-;; Version 0.1:
-;; * initial version separated off from auto-overlays.el
-
-
-
-;;; Code:
-
-
-(require 'auto-overlays)
-(provide 'auto-overlay-line)
-
-
-;; set line overlay parsing and suicide funtions
-(put 'line 'auto-overlay-parse-function 'auto-o-parse-line-match)
-(put 'line 'auto-overlay-suicide-function
-     (lambda (o) (auto-o-delete-overlay (overlay-get o 'parent))))
-
-
-
-(defun auto-o-parse-line-match (o-match)
-  ;; Create overlay for a new line match.
-  (let ((o-new (make-overlay (overlay-get o-match 'delim-end)
-			     (save-excursion
-			       (goto-char (overlay-get o-match 'delim-end))
-			       (1+ (line-end-position))))))
-    
-    ;; give new overlay some basic properties
-    (overlay-put o-new 'auto-overlay t)
-    (overlay-put o-new 'set-id (overlay-get o-match 'set-id))
-    (overlay-put o-new 'definition-id (overlay-get o-match 'definition-id))
-    ;; match start of new overlay with match
-    (auto-o-match-overlay o-new o-match nil)
-    ;; set overlay's modification hooks to ensure that it always extends to
-    ;; end of line
-    (overlay-put o-new 'modification-hooks
-		 (cons 'auto-o-schedule-extend-line
-		       (overlay-get o-new 'modification-hooks)))
-    ;; return new overlay
-    o-new)
-)
-
-
-(defun auto-o-schedule-extend-line (o-self modified &rest unused)
-  ;; All line overlay modification hooks are set to this function, which
-  ;; schedules `auto-o-extend-line' to run after any suicide functions have
-  ;; been called, but before the overlays are updated.
-  (unless modified (add-to-list 'auto-o-pending-post-suicide
-				(list 'auto-o-extend-line o-self)))
-)
-
-
-
-(defun auto-o-extend-line (o-self)
-  ;; Checks if overlay still extends to end of line, and update the necessary
-  ;; if not.
-
-  ;; if we haven't been deleted by a suicide function...
-  (when (overlay-buffer o-self)
-    (save-match-data
-      (let ((start (overlay-start o-self))
-	    (end (overlay-end o-self)))
-	(cond
-	 ;; if we no longer extend to end of line...
-	 ((null (string-match "\n" (buffer-substring-no-properties
-				    (overlay-start o-self)
-				    (overlay-end o-self))))
-	  ;; grow ourselves so we extend till end of line
-	  (move-overlay o-self start (save-excursion
-				       (goto-char (overlay-end o-self))
-				       (1+ (line-end-position))))
-	  ;; if we're exclusive, delete lower priority overlays in newly
-	  ;; covered region
-	  (auto-o-update-exclusive (overlay-get o-self 'set-id)
-				   end (overlay-end o-self)
-				   nil (overlay-get o-self 'priority)))
-	 
-	 ;; if we extend beyond end of line...
-	 ((/= (overlay-end o-self) (+ start (match-end 0)))
-	  ;; shrink ourselves so we extend till end of line
-	  (move-overlay o-self start (+ start (match-end 0)))
-	  ;; if we're exclusive, re-parse region that is no longer covered
-	  (auto-o-update-exclusive (overlay-get o-self 'set-id)
-				   (overlay-end o-self) end
-				   (overlay-get o-self 'priority) nil))
-	 ))))
-)
-      
-  
-;; auto-overlay-line.el ends here

File pida/editors/emacs/share/completion/auto-overlay-nested.el

-
-;;; auto-overlay-nested.el --- nested start/end-delimited automatic overlays
-
-
-;; Copyright (C) 2005-2007 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.1.7
-;; Keywords: automatic, overlays, nested
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is part of the Emacs Automatic Overlays package.
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Change Log:
-;;
-;; Version 0.1.7
-;; * added new `auto-overlay-complex-class' property
-;; * renamed 'entry-id and 'subentry-id to 'definition-id and 'regexp-id
-;;
-;; Version 0.1.6
-;; * renamed from "nest" to "nested"
-;; 
-;; Version 0.1.5
-;; * set overlay properties straight after creation in `auto-o-make-nest',
-;;   rather than leaving it to `auto-overlay-update', in case matching causes
-;;   exclusive reparsing, for which properties are already required
-;;
-;; Version 0.1.4
-;; * removed `auto-overlay-functions' and changed to use new interface
-;; * renamed from "stack" to "nest"
-;;
-;; Version 0.1.3
-;; * updated to reflect changes in `auto-overlays.el'
-;;
-;; Version 0.1.2
-;; * bug fix to `auto-o-suicide' behaviour, require change to `auto-o-stack'
-;;
-;; Version 0.1.1
-;; * bug fixes
-;;
-;; Version 0.1
-;; * initial version separated off from auto-overlays.el
-
-
-
-;;; Code:
-
-
-(require 'auto-overlays)
-(provide 'auto-overlay-nested)
-
-
-;; set nested overlay parsing and suicide functions, and indicate class
-;; requires separate start and end regexps
-(put 'nested 'auto-overlay-parse-function 'auto-o-parse-nested-match)
-(put 'nested 'auto-overlay-suicide-function 'auto-o-nested-suicide)
-(put 'nested 'auto-overlay-complex-class t)
-
-
-
-(defun auto-o-parse-nested-match (o-match)
-  ;; Perform any necessary updates of auto overlays due to a match for a
-  ;; nested regexp.
-
-  (let* ((overlay-stack (auto-o-nested-stack o-match))
-	 (o (car overlay-stack)))
-    (cond
-     ;; if the stack is empty, just create and return a new unmatched overlay
-     ((null overlay-stack)
-      (auto-o-make-nested o-match 'unmatched))
-     
-     ;; if appropriate edge of innermost overlay is unmatched, just match it
-     ((or (and (eq (auto-o-edge o-match) 'start)
-	       (not (auto-o-start-matched-p o)))
-	  (and (eq (auto-o-edge o-match) 'end)
-	       (not (auto-o-end-matched-p o))))
-      (auto-o-match-overlay o o-match)
-      ;; return nil since haven't created any new overlays
-      nil)
-     
-     ;; otherwise...
-     (t
-      ;; create new innermost overlay and add it to the overlay stack
-      (push (auto-o-make-nested o-match) overlay-stack)
-      ;; sort out the overlay stack
-      (auto-o-nested-stack-cascade overlay-stack)
-      ;; return newly created overlay
-      (car overlay-stack)))
-    )
-)
-
-
-
-
-(defun auto-o-nested-suicide (o-self)
-  ;; Called when match no longer matches. Unmatch the match overlay O-SELF, if
-  ;; necessary deleting its parent overlay or cascading the stack.
-  
-  (let* ((overlay-stack (auto-o-nested-stack o-self))
-	(o-parent (car overlay-stack)))
-    
-    (cond
-     ;; if other end of parent is unmatched, just delete parent
-     ((not (auto-o-edge-matched-p
-	    o-parent
-	    (if (eq (auto-o-edge o-self) 'start) 'end 'start)))
-      (auto-o-delete-overlay o-parent))
-
-     ;; if parent is the only overlay in the stack...
-     ((= (length overlay-stack) 1)
-      ;; if we're a start match, make parent start-unmatched
-      (if (eq (auto-o-edge o-self) 'start)
-	  (auto-o-match-overlay o-parent 'unmatched nil)
-	    ;; if we're an end match, make parent end-unmatched
-	(auto-o-match-overlay o-parent nil 'unmatched)))
-     
-      ;; otherwise, unmatch ourselves from parent and cascade the stack
-     (t
-      (overlay-put o-parent (auto-o-edge o-self) nil)
-      (overlay-put o-self 'parent nil)
-      (auto-o-nested-stack-cascade overlay-stack))
-     ))
-)
-
-      
-
-
-(defun auto-o-make-nested (o-match &optional unmatched)
-  ;; Create a nested overlay for match overlay O-MATCH.
-  ;; If UNMATCHED is nil, overlay will start and end at O-MATCH.
-  ;; If non-nil, overlay will start or end from O-MATCH (depending on whether
-  ;; O-MATCH is a 'start or 'end match) and stretch till end or beginning of
-  ;; buffer.
-
-  (let (o-new pos)
-    ;; create new nested overlay and match it with O-MATCH
-    (cond
-     ((eq (auto-o-edge o-match) 'start)
-      (setq pos (overlay-get o-match 'delim-end))
-      (setq o-new (make-overlay pos pos nil nil 'rear-advance))
-      (overlay-put o-new 'auto-overlay t)
-      (overlay-put o-new 'set-id (overlay-get o-match 'set-id))
-      (overlay-put o-new 'definition-id (overlay-get o-match 'definition-id))
-      (auto-o-match-overlay o-new o-match 'unmatched))
-     
-     ((eq (auto-o-edge o-match) 'end)
-      (setq pos (overlay-get o-match 'delim-start))
-      (setq o-new (make-overlay pos pos nil nil 'rear-advance))
-      (overlay-put o-new 'auto-overlay t)
-      (overlay-put o-new 'set-id (overlay-get o-match 'set-id))
-      (overlay-put o-new 'definition-id (overlay-get o-match 'definition-id))
-      (auto-o-match-overlay o-new 'unmatched o-match)))
-
-    ;; return the new overlay
-    o-new)
-)
-
-
-
-(defun auto-o-nested-stack-cascade (overlay-stack)
-  ;; Cascade the ends of the overlays in OVERLAY-STACK up or down the stack,
-  ;; so as to re-establish a valid stack. It assumes that only the innermost
-  ;; is incorrect.
-  
-  (let ((o (car overlay-stack)) o1)
-    (cond
-     
-     ;; if innermost overlay is start-matched (and presumably
-     ;; end-unmatched)...
-     ((auto-o-start-matched-p o)
-      ;; cascade overlay end matches up through stack until one is left
-      (dotimes (i (- (length overlay-stack) 1))
-	(setq o (nth i overlay-stack))
-	(setq o1 (nth (+ i 1) overlay-stack))
-	(auto-o-match-overlay o nil
-			      (if (overlay-get o1 'end)
-				    (overlay-get o1 'end)
-				'unmatched)
-			      nil nil 'protect-match))
-      ;; if final overlay is start-matched, make it end-unmatched, otherwise
-      ;; delete it
-      (if (auto-o-start-matched-p o1)
-	  ;; FIXME: could postpone re-parsing here in case it can be avoided
-	  (auto-o-match-overlay o1 nil 'unmatch nil nil 'protect-match)
-	(auto-o-delete-overlay o1 nil 'protect-match)))
-     
-     
-     ;; if innermost overlay is end-matched (and presumably
-     ;; start-unmatched)...
-     ((auto-o-end-matched-p o)
-      ;; cascade overlay start matches up through stack until one is left
-      (dotimes (i (- (length overlay-stack) 1))
-	(setq o (nth i overlay-stack))
-	(setq o1 (nth (+ i 1) overlay-stack))
-	(auto-o-match-overlay o (if (overlay-get o1 'start)
-				    (overlay-get o1 'start)
-				  'unmatched)
-			      nil nil nil 'protect-match))
-      ;; if final overlay is end-matched, make it start-unmatched, otherwise
-      ;; delete it
-      (if (auto-o-end-matched-p o1)
-	  ;; FIXME: could postpone re-parsing here in case it can be avoided
-	  (auto-o-match-overlay o1 'unmatch nil nil nil 'protect-match)
-	(auto-o-delete-overlay o1 nil 'protect-match))))
-    )
-)
-
-
-
-
-(defun auto-o-nested-stack (o-match)
-  ;; Return a list of the overlays that overlap and correspond to same entry
-  ;; as match overlay O-MATCH, ordered from innermost to outermost. (Assumes
-  ;; overlays are correctly stacked.) The parent of O-MATCH is guaranteed to
-  ;; come before any other overlay that has exactly the same length (which
-  ;; implies they cover identical regions if overlays are correctly
-  ;; stacked). For other overlays with identical lengths, the order is
-  ;; undefined.
-  
-  ;; find overlays corresponding to same entry overlapping O-MATCH
-  (let ((overlay-stack (auto-overlays-at-point
-			(if (eq (auto-o-edge o-match) 'start)
-			    (overlay-get o-match 'delim-end)
-			  (overlay-get o-match 'delim-start))
-			(list '(eq auto-overlay t)
-			      (list 'eq 'set-id (overlay-get o-match 'set-id))
-			      (list 'eq 'definition-id
-				    (overlay-get o-match 'definition-id)))))
-	(o-parent (overlay-get o-match 'parent)))
-    ;; sort the list by overlay length, i.e. from innermost to outermose
-    (sort overlay-stack
-	  (lambda (a b)
-	    (let ((len-a (- (overlay-end a) (overlay-start a)))
-		  (len-b (- (overlay-end b) (overlay-start b))))
-	      ;; parent of O-MATCH comes before any other overlay with
-	      ;; identical length, otherwise sort by length
-	      (if (= len-a len-b) (eq o-parent a) (< len-a len-b)))))
-    )
-)
-
-
-;; auto-overlay-nested.el ends here

File pida/editors/emacs/share/completion/auto-overlay-self.el

-
-;;; auto-overlay-self.el --- self-delimited automatic overlays
-
-
-;; Copyright (C) 2005-2007 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.2.8
-;; Keywords: automatic, overlays, self
-;; URL: http://www.dr-qubit.org/emacs.php
-
-;; This file is part of the Emacs Automatic Overlays package.
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Change Log:
-;;
-;; Version 0.2.8
-;; * renamed 'entry-id and 'subentry-id to 'definition-id and 'regexp-id
-;;
-;; Version 0.2.7
-;; * fixed bug in `auto-o-parse-self-match' which caused a matched self match
-;;   to have null 'parent property if a new self match was created inside an
-;;   existing self overlay
-;;
-;; Version 0.2.6
-;; * set overlay properties straight after creation in `auto-o-make-self',
-;;   rather than leaving it to `auto-overlay-update', in case matching causes
-;;   exclusive reparsing, for which properties are already required
-;;
-;; Version 0.2.5
-;; * removed `auto-overlay-functions' and changed to use new interface
-;;
-;; Version 0.2.4
-;; * fixed(?) bug in auto-o-self-list that caused it to
-;;   sometimes miss out the parent overlay itself from the list
-;;
-;; Version 0.2.3
-;; * updated to reflect changes in `auto-overlays.el'
-;; * changed `auto-o-self-list' to make it run faster
-;;
-;; Version 0.2.2
-;; * small but important bug fix
-;;
-;; Version 0.2.1
-;; * bug fixes
-;;
-;; Version 0.2
-;; * substantially re-written to postpone cascading until absolutely
-;;   necessary, for improved responsiveness
-;;
-;; Version 0.1
-;; * initial version separated off from auto-overlays.el
-
-
-
-;;; Code:
-
-
-(require 'auto-overlays)
-(provide 'auto-overlay-self)
-
-(defvar auto-o-pending-self-cascade nil)
-
-;; set self overlay parsing and suicide functions
-(put 'self 'auto-overlay-parse-function 'auto-o-parse-self-match)
-(put 'self 'auto-overlay-suicide-function 'auto-o-self-suicide)
-
-;; add initialisation and clear functions to hooks
-(add-hook 'auto-overlay-load-hook 'auto-o-self-load)
-(add-hook 'auto-overlay-unload-hook 'auto-o-self-unload)
-
-
-
-(defun auto-o-self-load ()
-  ;; Make sure `auto-o-perform-self-cascades' is in `before-change-functions',
-  ;; so that any cascading that is required is performed before anything else
-  ;; happens.
-  (add-hook 'before-change-functions 'auto-o-perform-self-cascades
-	    nil t)
-  ;; initialise variables
-  (setq auto-o-pending-self-cascade nil)
-)
-
-
-(defun auto-o-self-unload ()
-  ;; Remove `auto-o-perform-self-cascades' from `before-change-functions'.
-  (remove-hook 'before-change-functions 'auto-o-perform-self-cascades t)
-)
-
-
-
-
-(defun auto-o-parse-self-match (o-match)
-  ;; perform any necessary updates of auto overlays due to a match for a self
-  ;; regexp
-  
-  (let* ((overlay-list (auto-o-self-list o-match))
-	 (o (car overlay-list)))
-    
-    (cond
-     ;; if stack is empty, create a new end-unmatched overlay, adding it to
-     ;; the list of unascaded overlays (avoids treating it as a special
-     ;; case), and return it
-     ((null overlay-list)
-      (auto-o-make-self o-match nil))
-     
-     ;; if new delimiter is inside the first existing overlay and existing one
-     ;; is end-unmatched, just match it
-     ((and (not (overlay-get o 'end))
-	   (>= (overlay-get o-match 'delim-start) (overlay-start o)))
-      (auto-o-match-overlay o nil o-match 'no-props)
-      ;; remove it from the list of uncascaded overlays
-      (setq auto-o-pending-self-cascade (delq o auto-o-pending-self-cascade))
-      ;; return nil since haven't created any new overlays
-      nil)
-     
-     
-     ;; otherwise...
-     (t
-      (let (o-new)
-	;; if the new match is outside existing overlays...
-	(if (< (overlay-get o-match 'delim-end) (overlay-start o))
-	    ;; create overlay from new match till start of next match, and add
-	    ;; it to the list of uncascaded overlays
-	    (setq o-new (auto-o-make-self
-			 o-match
-			 (overlay-get (overlay-get o 'start) 'delim-start)))
-	  
-	  ;; if the new match is inside an existing overlay...
-	  (setq o (pop overlay-list))
-	  ;; create overlay from end of existing one till start of the one
-	  ;; after (or end of buffer if there isn't one), and add it to the
-	  ;; list of uncascaded overlays
-	  (setq o-new (auto-o-make-self
-		       (overlay-get o 'end)
-		       (when overlay-list
-			 (overlay-get (overlay-get (car overlay-list) 'start)
-				      'delim-start))))
-	  ;; match end of existing one with the new match, protecting its old
-	  ;; end match which is now matched with start of new one
-	  (auto-o-match-overlay o nil o-match 'no-props nil 'protect-match))
-      
-      ;; return newly created overlay
-      o-new))
-     ))
-)
-
-
-
-
-(defun auto-o-self-suicide (o-self)
-  ;; Called when match no longer matches. Unmatch the match overlay O-SELF, if
-  ;; necessary deleting its parent overlay or cascading.
-
-  (let ((o-parent (overlay-get o-self 'parent)))
-    (cond
-     ;; if parent is end-unmatched, delete it from buffer and from list of
-     ;; uncascaded overlays
-     ((not (auto-o-end-matched-p o-parent))
-      (auto-o-delete-overlay o-parent)
-      (setq auto-o-pending-self-cascade
-	    (delq o-parent auto-o-pending-self-cascade)))
-
-     ;; if we match the end of parent...
-     ((eq (overlay-get o-parent 'end) o-self)
-      ;; unmatch ourselves from parent and extend parent till next overlay, or
-      ;; end of buffer if there is none
-      (let ((o (nth 1 (auto-o-self-list o-self))))
-	(auto-o-match-overlay
-	 o-parent nil (if o (overlay-get (overlay-get o 'start) 'delim-start)
-			'unmatched)))
-      ;; add parent to uncascaded overlay list
-      (push o-parent auto-o-pending-self-cascade))
-
-     ;; if we match the start of parent...
-     (t
-      (let* ((o-end (overlay-get o-parent 'end))
-	     (o (nth 1 (auto-o-self-list o-end))))
-	;; unmatch ourselves from parent and "flip"
-	(auto-o-match-overlay
-	 o-parent o-end
-	 (if o (overlay-get (overlay-get o 'start) 'delim-start)
-	   'unmatched)))
-      ;; add parent to uncascaded overlay list
-      (push o-parent auto-o-pending-self-cascade))
-     ))
-)
-
-
-
-
-(defun auto-o-make-self (o-start &optional end)
-  ;; Create a self overlay starting at match overlay O-START.
-  ;; If END is a number or marker, the new overlay is end-unmatched and ends
-  ;; at the buffer location specified by the number or marker.
-  ;; If END is nil, the new overlay is end-unmatched and ends at the end of
-  ;; the buffer.
-  (let (o-new)
-    
-    ;; create new overlay (location ensures right things happen when matched)
-    (let (pos)
-      (cond
-       ((overlayp end) (setq pos (overlay-get end 'delim-start)))
-       ((number-or-marker-p end) (setq pos end))
-       (t (setq pos (point-max))))
-      (setq o-new (make-overlay pos pos nil nil 'rear-advance)))
-    
-    ;; give overlay some basic properties
-    (overlay-put o-new 'auto-overlay t)
-    (overlay-put o-new 'set-id (overlay-get o-start 'set-id))
-    (overlay-put o-new 'definition-id (overlay-get o-start 'definition-id))
-    
-    ;; if overlay is end-unmatched, add it to the list of uncascaded overlays
-    (unless (overlayp end) (push o-new auto-o-pending-self-cascade))
-    
-    ;; match the new overlay and return it
-    (auto-o-match-overlay o-new o-start (if (overlayp end) end nil))
-    o-new)
-)
-
-
-
-
-(defun auto-o-perform-self-cascades (beg end)
-  ;; Perform any necessary self-overlay cascading before the text in the
-  ;; buffer is modified. Called from `before-change-functions'.
-
-  ;; check all overlays waiting to be cascaded, from first in buffer to last
-  (dolist (o (sort auto-o-pending-self-cascade
-		   (lambda (a b) (< (overlay-start a) (overlay-start b)))))
-    ;; if buffer modification occurs after the end of an overlay waiting to be
-    ;; cascaded, cascade all overlays between it and the modified text
-    (when (and (overlay-end o) (< (overlay-end o) end))
-      (auto-o-self-cascade (auto-o-self-list (overlay-get o 'start) end))))
-)
-
-
-
-
-(defun auto-o-self-cascade (overlay-list)
-  ;; "Flip" overlays down through buffer (assumes first overlay in list is
-  ;; end-unmatched).
-  (when (> (length overlay-list) 1)
-    (let ((o (car overlay-list))
-	  (o1 (nth 1 overlay-list)))
-      
-      ;; match first (presumably end-matched) overlay and remove it from list
-      (pop overlay-list)
-      (auto-o-match-overlay o nil (overlay-get o1 'start) 'no-props)
-      ;; remove it from list of uncascaded overlays
-      (setq auto-o-pending-self-cascade (delq o auto-o-pending-self-cascade))
-      ;; if we've hit an end-unmatched overlay, we can stop cascading
-      (if (not (auto-o-end-matched-p o1))
-	  (progn
-	    (auto-o-delete-overlay o1 nil 'protect-match)
-	    (setq auto-o-pending-self-cascade
-		  (delq o1 auto-o-pending-self-cascade)))
-
-	;; otherwise, cascade overlay list till one is left or we hit an
-	;; end-unmached overlay
-	(unless
-	    (catch 'stop
-	      (dotimes (i (1- (length overlay-list)))
-		(setq o (nth i overlay-list))
-		(setq o1 (nth (1+ i) overlay-list))
-		(auto-o-match-overlay o (overlay-get o 'end)
-				      (overlay-get o1 'start)
-				      'no-props nil 'protect-match)
-		;; if we hit an end-unmatched overlay, we can stop cascading
-		(when (not (auto-o-end-matched-p o1))
-		  (throw 'stop (progn
-				 ;; delete the end-unmatched overlay
-				 (auto-o-delete-overlay o1 nil 'protect-match)
-				 ;; remove it from uncascaded overlays list
-				 (setq auto-o-pending-self-cascade
-				       (delq o1 auto-o-pending-self-cascade))
-				 ;; return t to indicate cascading ended early
-				 t)))))
-	  
-	  ;; if there's an overlay left, "flip" it so it's end-unmatched and
-	  ;; extends to next overlay in buffer, and add it to the list of
-	  ;; unmatched overlays
-	  (let (pos)
-	    (setq o (car (last overlay-list)))
-	    (if (setq o1 (nth 1 (auto-o-self-list (overlay-get o 'end))))
-		(setq pos (overlay-get (overlay-get o1 'start) 'delim-start))
-	      (setq pos (point-max)))
-	    (auto-o-match-overlay o (overlay-get o 'end) pos
-				  'no-props nil 'protect-match))
-	  (push o auto-o-pending-self-cascade)))
-      ))
-)
-
-
-
-
-;; (defun auto-o-self-list (o-start &optional end)
-;;   ;; Return list of self overlays ending at or after match overlay O-START and
-;;   ;; starting before or at END, corresponding to same entry as O-START. If END
-;;   ;; is null, all overlays after O-START are included.
-
-;;   (when (null end) (setq end (point-max)))
-  
-;;   (let (overlay-list)
-;;     ;; create list of all overlays corresponding to same entry between O-START
-;;     ;; and END
-;;     (mapc (lambda (o) (when (and (>= (overlay-end o)
-;; 				     (overlay-get o-start 'delim-start))
-;; 				 (<= (overlay-start o) end))
-;; 			(push o overlay-list)))
-;; 	  (auto-overlays-in
-;; 	   (point-min) (point-max)
-;; 	   (list
-;; 	    '(identity auto-overlay)
-;; 	    (list 'eq 'set-id (overlay-get o-start 'set-id))
-;; 	    (list 'eq 'definition-id (overlay-get o-start 'definition-id)))))
-;;     ;; sort the list by start position, from first to last
-;;     (sort overlay-list
-;; 	  (lambda (a b) (< (overlay-start a) (overlay-start b)))))
-;; )
-
-
-
-(defun auto-o-self-list (o-start &optional end)
-  ;; Return list of self overlays ending at or after match overlay O-START and
-  ;; starting before or at END, corresponding to same entry as O-START. If END
-  ;; is null, all overlays after O-START are included.
-
-  (when (null end) (setq end (point-max)))
-  
-  (let (overlay-list)
-    ;; create list of all overlays corresponding to same entry between O-START
-    ;; and END
-    (setq overlay-list
-	  ;; Note: We subtract 1 from start and add 1 to end to catch overlays
-	  ;;       that end at start or start at end. This seems to give the
-	  ;;       same results as the old version of `auto-o-self-list'
-	  ;;       (above) in all circumstances.
-	  (auto-overlays-in
-	   (1- (overlay-get o-start 'delim-start)) (1+ end)
-	   (list
-	    '(identity auto-overlay)
-	    (list 'eq 'set-id (overlay-get o-start 'set-id))
-	    (list 'eq 'definition-id (overlay-get o-start 'definition-id)))))
-    ;; sort the list by start position, from first to last
-    (sort overlay-list
-	  (lambda (a b) (< (overlay-start a) (overlay-start b)))))
-)
-
-
-;;; auto-overlay-self.el ends here

File pida/editors/emacs/share/completion/auto-overlay-word.el

-
-;;; auto-overlay-word.el --- automatic overlays for single "words"
-
-
-;; Copyright (C) 2005-2007 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.1.4
-;; Keywords: automatic, overlays, word
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is part of the Emacs Automatic Overlays package.
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Change Log:
-;;
-;; Version 0.1.4
-;; * renamed 'entry-id and 'subentry-id to 'definition-id and 'regexp-id
-;;
-;; Version 0.1.3
-;; * set overlay properties straight after creation, rather than leaving it to
-;;   `auto-overlay-update', in case overlay is exclusive and we reparse, for
-;;   which properties are already required
-;;
-;; Version 0.1.2
-;; * removed `auto-overlay-functions' and changed to use new interface
-;;
-;; Version 0.1.1
-;; * updated to reflect changes in `auto-overlays.el'
-;;
-;; Version 0.1:
-;; * initial version separated off from auto-overlays.el
-
-
-
-;;; Code:
-
-
-(require 'auto-overlays)
-(provide 'auto-overlay-word)
-
-
-;; set word overlay parsing and suicide functions
-(put 'word 'auto-overlay-parse-function 'auto-o-parse-word-match)
-(put 'word 'auto-overlay-suicide-function
-     (lambda (o) (auto-o-delete-overlay (overlay-get o 'parent))))
-
-
-
-(defun auto-o-parse-word-match (o-match)
-  ;; Create a new word overlay for new word match
-  (let ((o-new (make-overlay (overlay-get o-match 'delim-start)
-			     (overlay-get o-match 'delim-end)
-			     nil nil 'rear-advance)))
-    ;; give overlays appropriate properties
-    (overlay-put o-new 'auto-overlay t)
-    (overlay-put o-new 'set-id (overlay-get o-match 'set-id))
-    (overlay-put o-new 'definition-id (overlay-get o-match 'definition-id))
-    (overlay-put o-new 'start o-match)
-    (overlay-put o-match 'parent o-new)
-    ;; bundle properties inside list if not already, then update overlay
-    ;; properties
-    (let ((props (auto-o-props o-match)))
-      (when (symbolp (car props)) (setq props (list props)))
-      (dolist (p (auto-o-props o-match))
-	(overlay-put o-new (car p) (cdr p))))
-    
-    ;; if new overlay is exclusive, delete lower priority overlays within it
-    (when (and (overlay-get o-new 'exclusive)
-	       (/= (overlay-start o-new) (overlay-end o-new)))
-      (auto-o-update-exclusive (overlay-get o-new 'set)
-			       (overlay-start o-new) (overlay-end o-new)
-			       nil (overlay-get o-new 'priority)))
-    
-    ;; return new overlay
-    o-new)
-)
-
-
-;; auto-overlay-word.el ends here

File pida/editors/emacs/share/completion/auto-overlays-compat.el

-
-;;; auto-overlays-compat.el --- compatability functions for auto-overlays package
-
-
-;; Copyright (C) 2006 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.3.1
-;; Keywords: auto-overlay, automatic, overlays, compatability
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is part of the Emacs Automatic Overlays package.
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License
-;; as published by the Free Software Foundation; either version 2
-;; of the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-;; Boston, MA 02111-1307 USA
-
-
-;;; Change Log:
-;;
-;; Version 0.3.1
-;; * fixed another bug in line-number-at-pos compatibility function
-;;
-;; Version 0.3
-;; * fixed bug in line-number-at-pos compatibility function
-;;
-;; Version 0.2
-;; * added replace-regexps-in-string compatibility function
-;;
-;; Version 0.1
-;; * initial release
-
-
-;;; Code:
-
-(provide 'auto-overlays-compat)
-
-
-(defun auto-overlays-compat-line-number-at-pos (&optional pos)
-  "Return (narrowed) buffer line number at position POS.
-\(Defaults to the point.\)"
-  (unless pos (setq pos (point)))
-  ;; note: need to add 1 if at beginning of line
-  (+ (count-lines (point-min) pos)