Flexichain an Editable Sequence and Its Gap-Buffer Implementation

Total Page:16

File Type:pdf, Size:1020Kb

Flexichain an Editable Sequence and Its Gap-Buffer Implementation Flexichain An editable sequence and its gap-buffer implementation Robert Strandh, Tim Moore, Matthieu Villeneuve [email protected], [email protected], [email protected] Laboratoire Bordelais de Recherche en Informatique (LaBRI) Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.1/19 API Model An editable sequence of objects containing an arbitrary number of cursors. Cursors Arbitrary Objects Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.2/19 Uses of API • Emacs-like text editors for the entire buffer • Emacs-like text editors for one line of a buffer • Emacs-like text editors for the sequence of lines • Gsharp (at 4 different levels) Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.3/19 Possible representations • Doubly linked list • Gap buffer Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.4/19 Doubly linked list Advantages: fast, easy to implement Inconveniences: no direct access, high memory overhead Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.5/19 Gap buffer Advantages: direct access, low memory overhead Inconveniences: slow worst-case, hard to implement Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.6/19 Previous work • Multics Emacs: a doubly-linked list of lines, each line a vector (special instructions) • GNU Emacs: entire buffer is a gap buffer • Hemlock: doubly-linked list of lines, the open line is a gap buffer • Goatee (McCLIM): doubly-linked list of lines, each line is a gap buffer • Gsharp: currently uses singly-linked lists Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.7/19 Purpose of Flexichain In order of priorities: 1. Replace specialized, slow code in Gsharp 2. Replace line implementation in Goatee 3. Replace list of lines in Goatee 4. Perhaps use in portable Hemlock Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.8/19 Two layers: Flexichain and cursorchain The Flexichain layer uses positions to access, insert, and delete elements. The Cursorchain layer uses cursors. The two are compatible. Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.9/19 The Flexichain layer insert<* chain element position insert>* chain element position delete* chain position element* chain position (setf element*) position element chain Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.10/19 Stack and queue operations push-start chain element push-end chain element pop-start chain pop-end chain rotate chain &optional (n 1) Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.11/19 Implementation of Flexichain layer • Use a gap buffer • Consider the buffer as circular (avoids bad worst cases) • Expand and shrink factors • Moving the gap is messy Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.12/19 Moving the gap Three situations exist: Move left or right according to the number of elements that need to be moved in each case. Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.13/19 Moving the gap Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.14/19 The Cursorchain layer at-beginning-p cursor at-end-p cursor move< cursor move> cursor insert< object cursor insert> object cursor delete< cursor &optional (n 1) delete> cursor &optional (n 1) element< cursor element> cursor Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.15/19 The Cursorchain layer • cursorchain is a subclass of flexichain • cursors store physical position rather than logical positions in order to avoid updating all cursors at every operation • to avoid memory leaks, we use weak references to store cursors Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.16/19 The Cursorchain layer • we use an internal protocol for resizing and for moving the gap • cursor update are done by :before and :after methods of internal protocol Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.17/19 State of implementation Flexichain is finished. Cursorchain will be finished this summer (we all have daytime jobs). Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.18/19 That's all Thank You! Questions? Flexichain – Lisp and Scheme Conference, Oslo 2004 – p.19/19.
Recommended publications
  • Texing in Emacs Them
    30 TUGboat, Volume 39 (2018), No. 1 TEXing in Emacs them. I used a simple criterion: Emacs had a nice tutorial, and Vim apparently did not (at that time). Marcin Borkowski I wince at the very thought I might have chosen Abstract wrong! And so it went. I started with reading the In this paper I describe how I use GNU Emacs to manual [8]. As a student, I had a lot of free time work with LAT X. It is not a comprehensive survey E on my hands, so I basically read most of it. (I still of what can be done, but rather a subjective story recommend that to people who want to use Emacs about my personal usage. seriously.) I noticed that Emacs had a nice TEX In 2017, I gave a presentation [1] during the joint mode built-in, but also remembered from one of GUST/TUG conference at Bachotek. I talked about the BachoTEXs that other people had put together my experiences typesetting a journal (Wiadomo´sci something called AUCTEX, which was a TEX-mode Matematyczne, a journal of the Polish Mathematical on steroids. Society), and how I utilized LAT X and GNU Emacs E In the previous paragraph, I mentioned modes. in my workflow. After submitting my paper to the In order to understand what an Emacs mode is, let proceedings issue of TUGboat, Karl Berry asked me me explain what this whole Emacs thing is about. whether I'd like to prepare a paper about using Emacs with LATEX. 1 Basics of Emacs Well, I jumped at the proposal.
    [Show full text]
  • Flexichain: an Editable Sequence and Its Gap-Buffer Implementation
    Flexichain: An editable sequence and its gap-buffer implementation Robert Strandh (LaBRI∗), Matthieu Villeneuve, Tim Moore (LaBRI) 2004-04-05 Abstract Flexichain is an API for editable sequences. Its primary use is in end-user applications that edit sequences of objects such as text editors (characters), word processors (characters, paragraphs, sections, etc), score editors (notes, clusters, measures, etc), though it can also be used as a stack and a double- ended queue. We also describe an efficient implementation of the API in the form of a cir- cular gap buffer. Circularity avoids a common worst case in most implemen- tations, makes queue operations efficient, and makes worst-case performance twice as good as that of ordinary implementations 1 Introduction Editable sequences are useful, in particular in interactive applications such as text editors, word processors, score editors, and more. In such applications, it is highly likely that an editing operation is close to the previous one, measured as the dif- ference in positions in the sequence. This statistical behavior makes it feasible to implement the editable sequence as a gap buffer. The basic idea is to store objects in a vector that is usually longer than the number of elements stored in it. For a sequence of N elements where editing is required at ∗Laboratoire Bordelais de Recherche en Informatique, Bordeaux, France 1 index i, elements 0 through i are stored at the beginning of the vector, and elements i + 1 through N − 1 are stored at the end of the vector. When the vector is longer N, this storage leaves a gap.
    [Show full text]
  • Learn Emacs Through Org-Mode
    About Emacs Configuration & Basics The org-mode Further Topics Learn Emacs through org-mode Linyxus1 Dec 2018 [email protected] Linyxus Learn Emacs through org-mode About Emacs Configuration & Basics The org-mode Further Topics Outline About Emacs Configuration & Basics The org-mode Further Topics Linyxus Learn Emacs through org-mode About Emacs Configuration & Basics The org-mode Further Topics Learning curve Emacs may be best known for its learning curve: Linyxus Learn Emacs through org-mode About Emacs Configuration & Basics The org-mode Further Topics History2 A brief list: I 1970s, in Artificial Intelligence Laboratory at MIT, TECO I 1976, by Stallman, the first Emacs("Editor MACroS") I 1978, by Bernard Greenberg, MulticsEmacs, introducing MacLisp I 1981, the first Emacs to run on Linux, Gosling Emacs I 1984, by Stallman, GNU Emacs 2according to EmacsWiki Linyxus Learn Emacs through org-mode About Emacs Configuration & Basics The org-mode Further Topics What a excellent editor is like I Highly extensible (Emacs can do everthing!) I FLexible (freely define your own key bindings) I Portable (bring your Emacs everywhere) I Compatible (GUI && Terminal) I Macros Linyxus Learn Emacs through org-mode About Emacs Configuration & Basics The org-mode Further Topics Emacs deserves your efforts I It will never be out of date. I Be used in a wide range. I Programming I Documenting I Mailing I IRC I Playing games I ... I It’s really powerful. Linyxus Learn Emacs through org-mode About Emacs Configuration & Basics The org-mode Further Topics Aim of this lecture Find your passion The best way to learn Emacs is to use it.
    [Show full text]
  • Multics Emacs
    MULT'ICS TECHNICAL BULLETIN ~-ITB - 439 Date: 3 March 1980 From: Bernard S. Greenberg Subject: Emacs Paper for Honeywel.L Conference To: ~rrB Distribution Attached is a reproduction of my paper, "Multics Emacs, an Experiment in Computer Interact ion," which I will p~·esent · at the Fourth Annual Honeywell International Software Conference, in Minneapolis, on March 25. Unlike most t>!ultics Technical Bulletins, this memo is not limited to the Multics Development Community. It may be reproduced without permission, as long as its contents, origin, and this title page are left intact. It may not be republished without permission. MUL!lL~ tMAL~ --- AN ~XP~HlMtNl lN LUM~U!~ft ~Nl~na~!lUN ~/~U/OU Bernard S. Greenberg Honeywell Information Systems, Inc. Cambridge Information Systems Laboratory, MSD/LISD 575 Technology Sq. (Mail Sta. MA22) Cambridge, MA, 02139 HVN 261-9330 Overview Multics Emacs i~ a video oriented text preparation and editing facility being released as a product in Multics Release 8.0 in early 1980. Multics Emacs features the ease of use of stand-alone word processing coupled with the power of the full Multics progtam environment. Multics Emacs is coded in th& Lisp language, and is the first released Honeywell software coded· in Lisp. The use of Lisp has provided an extensibility which has nourished the development of a wide variety of features which have brought Multics Emacs far beyond its original goals. Multics Emacs marks the entry of Multics into the arena of video oriented user interfaces. While its original conception was as a text editor, it has grown into an entire user environment: an embedded mail system, interactive message system, features for compiling and debugging programs with automatic aid, and other features, have since brought Multics Emacs out of the domain of text editors and into the domain of comprehensive paradigms for user interaction.
    [Show full text]
  • ASDF 3, Or Why Lisp Is Now an Acceptable Scripting Language (Extended Version)
    ASDF 3, or Why Lisp is Now an Acceptable Scripting Language (Extended version) François-René Rideau Google [email protected] Abstract libraries, or network services; one can scale them into large, main- ASDF, the de facto standard build system for Common Lisp, has tainable and modular systems; and one can make those new ser- been vastly improved between 2009 and 2014. These and other im- vices available to other programs via the command-line as well as provements finally bring Common Lisp up to par with "scripting via network protocols, etc. languages" in terms of ease of writing and deploying portable code The last barrier to making that possible was the lack of a that can access and "glue" together functionality from the underly- portable way to build and deploy code so a same script can run ing system or external programs. "Scripts" can thus be written in unmodified for many users on one or many machines using one or Common Lisp, and take advantage of its expressive power, well- many different compilers. This was solved by ASDF 3. defined semantics, and efficient implementations. We describe the ASDF has been the de facto standard build system for portable most salient improvements in ASDF and how they enable previ- CL software since shortly after its release by Dan Barlow in 2002 ously difficult and portably impossible uses of the programming (Barlow 2004). The purpose of a build system is to enable divi- language. We discuss past and future challenges in improving this sion of labor in software development: source code is organized key piece of software infrastructure, and what approaches did or in separately-developed components that depend on other compo- didn’t work in bringing change to the Common Lisp community.
    [Show full text]
  • Programming Mac OS X: a GUIDE for UNIX DEVELOPERS
    Programming Mac OS X: A GUIDE FOR UNIX DEVELOPERS KEVIN O’MALLEY MANNING Programming Mac OS X Programming Mac OS X A GUIDE FOR UNIX DEVELOPERS KEVIN O’MALLEY MANNING Greenwich (74° w. long.) For electronic information and ordering of this and other Manning books, go to www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. 209 Bruce Park Avenue Fax: (203) 661-9018 Greenwich, CT 06830 email: [email protected] ©2003 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books they publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Copyeditor: Tiffany Taylor 209 Bruce Park Avenue Typesetter: Denis Dalinnik Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1-930110-85-5 Printed in the United States of America 12345678910–VHG–05 040302 brief contents PART 1OVERVIEW ............................................................................. 1 1 ■ Welcome to Mac OS X 3 2 ■ Navigating and using Mac OS X 27 PART 2TOOLS ..................................................................................
    [Show full text]
  • Multics Emacs : Histoire De La Conception D’Un Logiciel Mythique
    Multics Emacs : histoire de la conception d’un logiciel mythique Stephane´ Bortzmeyer <[email protected]> Premiere` redaction´ de cet article le 27 avril 2006 https://www.bortzmeyer.org/multics-emacs.html —————————- Comme le savent mes fideles` lecteurs, j’aime beaucoup lire les vieux articles d’informatique : il y a beaucoup de choses a` apprendre du passe´ et, si la liste des failles de securit´ e´ de PHP n’a guere` d’inter´ etˆ deux ans apres,` beaucoup d’autres choses en informatique sont bien plus permanentes. D’ou` mon inter´ etˆ pour ce remarquable article, qui decrit´ la conception et le developpement´ de la premiere` version de l’editeur´ Emacs pour le systeme` Multics. Multics etait´ un systeme` d’exploitation de ”mainframe”, tres` avance´ pour son epoque,´ qui n’a eu qu’un tres` faible succes` commercial, mais qui avait reussi´ a` creer´ une communaute´ d’utilisateurs dy- namique et creative,´ comme le font les Unix libres aujourd’hui. Il est donc logique qu’il existe un site Web dedi´ e´ a` Multics <http://www.multicians.org/>, d’ou` se trouve distribue´ notre texte, ”Mul- tics Emacs : The History, Design and Implementation” <http://www.multicians.org/mepap.html>. (Personnellement, je n’ai fait que de courtes incursions sur un systeme` Multics, vers 1989.) Multics n’avait comme editeur´ que des programmes qui, memeˆ a` l’epoque,´ etaient´ juges´ archa¨ıques. Par exemple, aucun ne fonctionnait en plein ecran,´ tellement ils etaient´ optimises´ pour des terminaux papier. D’ou` la motivation pour developper´ un nouvel editeur,´ Emacs, inspire´ du programme du memeˆ nom qui tournait sur un autre systeme` d’exploitation, ITS.
    [Show full text]
  • CS 131 (Eggert) Notes W 1 M Lec 1-10-17 Microsoft Interview Was This
    CS 131 (Eggert) Notes W 1 M Lec 1-10-17 • Microsoft interview was this exact same question! • This is one of the most famous problems in Computer Science • NOT the halting problem or P = NP, but rather a programming language problem • Solved by Donald Knuth, a Turing Award winner • Knuth was a Professor at Stanford, formerly at CalTech. • At CalTech, he decided to write a textbook to write about everything important about computer programming • 1962 and the field was still young! • CS 31 and 32 of the day and the last chapter would be about programming languages • Knuth is a world-class computer science researcher and he is OCD about writing the best possible book • NOT embarrassed to jump into calculus to explain why it runs efficiently. • Published by Addison-Wesley in 1969 (first class academic publisher) • The plates were all created by hand • Knuth wasn’t happy! • The book looked okay but he thought we should be doing something better. • Wrote a tool to help him generate the book. • When a job is NOT done well, you write a program to automate the repeated part. • TEX - source code that the TEX processor reads and generates something that looks nice on the screen. • Knuth found images for a book that were better than the Addison-Wesley ones did by hand Fundamental Algorithms is now done with TEX! • The TEX output is so good that now, CS professionals use TEX! • Word just isn’t good at this. • Knuth being a software engineer as well as an academic wanted to write this TEX program so that he could do his own book but other people could use the program as well.
    [Show full text]
  • Signature Redacted Signature of Author •
    Th6 Design and Implementation of a Display-Oriented Editor Writing System by Owen Theodore Anderson Submitted in Partial Fulfillment of the Requirements for the Degree of 3achel0r of Science at th0 Massachusetts Institute of Technology ,January, 1979 ~~'1 - /l Signature redacted Signature of Author •.. ~• .,, •• ,....... --. •, .. ,..... ·-.- ...·- ..... -................ Department of Physics, January 1979 Signature redacted Certified by ... ., ............................................... Thesis Supervisor ...- Signature redacted Accepted bY••••ti>••••••••••••••••••cov••••••c•••n•••••••••••••••• Chairperson, Departmental Committee on Theses Archive~ MASSACi-iUSETTS INST:T:J. E OF T~CIH-~)L'JSY M?\R 2 2 1979 LIB~AP.!ES 2 The Design and Implementation of a Display-Oriented Editor Writing System by Owen Theodore Anderson SubMitted to the Department of Physics on January 19, 1979 in partial fulfillment of the requiremP.nts for the Degree of Bachelor of Science Abstract This thesis describes the design and implementation of an editing system in use on the MagicSix operating system at MIT's Architecture Machine Group. The foundation of the system is a simulated stack machine which implements all of the basic editing functions. This is the target machine for a LISP-like language compiler. This language is used to write a real-time display oriented editor with many advanced features. Signature redacted I - Name and Title of Thesis Supervisor: Nicholas Negroponte Associate Professor of Computer Graphics 3 Table of Contents Abstract 2 Table
    [Show full text]
  • 9 European Lisp Symposium
    Proceedings of the 9th European Lisp Symposium AGH University of Science and Technology, Kraków, Poland May 9 – 10, 2016 Irène Durand (ed.) ISBN-13: 978-2-9557474-0-7 Contents Preface v Message from the Programme Chair . vii Message from the Organizing Chair . viii Organization ix Programme Chair . xi Local Chair . xi Programme Committee . xi Organizing Committee . xi Sponsors . xii Invited Contributions xiii Program Proving with Coq – Pierre Castéran .........................1 Julia: to Lisp or Not to Lisp? – Stefan Karpinski .......................1 Lexical Closures and Complexity – Francis Sergeraert ...................2 Session I: Language design3 Refactoring Dynamic Languages Rafael Reia and António Menezes Leitão ..........................5 Type-Checking of Heterogeneous Sequences in Common Lisp Jim E. Newton, Akim Demaille and Didier Verna ..................... 13 A CLOS Protocol for Editor Buffers Robert Strandh ....................................... 21 Session II: Domain Specific Languages 29 Using Lisp Macro-Facilities for Transferable Statistical Tests Kay Hamacher ....................................... 31 A High-Performance Image Processing DSL for Heterogeneous Architectures Kai Selgrad, Alexander Lier, Jan Dörntlein, Oliver Reiche and Marc Stamminger .... 39 Session III: Implementation 47 A modern implementation of the LOOP macro Robert Strandh ....................................... 49 Source-to-Source Compilation via Submodules Tero Hasu and Matthew Flatt ............................... 57 Extending Software Transactional
    [Show full text]
  • A CLOS Protocol for Editor Buffers
    A CLOS Protocol for Editor Buffers Robert Strandh University of Bordeaux 351, Cours de la Libération Talence, France [email protected] ABSTRACT because a data structure with optimal asymptotic worst- Many applications and libraries contain a data structure for case complexity would be considered as having too much storing and editing text. Frequently, this data structure is overhead, both in terms of execution time, and in terms of chosen in a somewhat arbitrary way, without taking into memory requirements. account typical use cases and their consequence to perfor- For a text editor with advanced features such as keyboard mance. In this paper, we present a data structure in the macros, it is crucial to distinguish between two different con- form of a CLOS protocol that addresses these issues. In trol loops: particular, the protocol is divided into an edit protocol and • The innermost loop consists of inserting and deleting an update protocol, designed to be executed at different fre- 1 quencies. The update protocol is based on the concept of individual items in the buffer, and of moving one or time stamps allowing multiple views without any need for more cursors from one position to an adjacent posi- observers or similar techniques for informing the views of tion. changes to the model (i.e., the text buffer). • The outer loop consists of updating the views into the In addition to the protocol definition, we also present two buffer. Each view is typically an interval of less than different implementations of the definition. The main im- a hundred lines of the buffer.
    [Show full text]
  • The Copyright Law of the United States (Title 17, U.S
    NOTICE WARNING CONCERNING COPYRIGHT RESTRICTIONS: The copyright law of the United States (title 17, U.S. Code) governs the making of photocopies or other reproductions of copyrighted material. Any copying of this document without permission of its author may be prohibited by law. Hemlock User's Manual Robert A. MacLachlan BUI Chiles April 1989 CMU-CS-89-133 3 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 This is a revised version of Technical Report CMU-CS-87-158. Abstract This document describes the Hemlock text editor, as of version M3.0. Hemlock is a customizable, extensible text editor whose initial command set closely resembles that of ITS/TOPS-20 Emacs. Hemlock is written in CMU COMMON LISP and has been ported to other implementations. This research was sponsored by the Defense Advanced Research Projects Agency (DOD), ARPA Order No. 4976 under contract F33615-87-C-1499 and monitored by the Avionics Laboratory, Air Force Wright Aeronautical Laboratories, Aeronautical Systems Division (AFSC), Wright-Patterson AFB, OHIO 45433-6543. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Defense Advanced Research Projects Agency or the U.S. Government. INDEX 1 Table of Contents 1. Introduction 1 1.1. The Point and The Cursor 1 1.2. Notation 1 1.2.1. Characters 1 1.2.2. Commands 2 1.23. Hemlock Variables 2 1.3. Invoking Commands 2 13.1. Key Bindings 3 13.2. Extended Commands 3 1.4.
    [Show full text]