From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Emacs programming question Date: Fri, 05 Oct 2012 13:57:08 +0200 Organization: Informatimago Message-ID: <87r4pdqgh7.fsf@kuiper.lan.informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1349438423 10742 80.91.229.3 (5 Oct 2012 12:00:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Oct 2012 12:00:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 05 14:00:27 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TK6Zu-0000FH-Un for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Oct 2012 14:00:27 +0200 Original-Received: from localhost ([::1]:39557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TK6Zo-0007Ew-L0 for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Oct 2012 08:00:20 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 63 Original-X-Trace: individual.net GU7K77Gyo66LbVBbcCZlDgK6y/5Y/NA/CfVpPV3j00vNJxP3mp Cancel-Lock: sha1:MThjNWI4YzQ2ZTFlMWU2Y2I2YjgxMGI2OTkxODZlMzRmMTU3YmQ5Nw== sha1:XdMFg5oMu2kM6IyR0A+mTLhqA6w= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:194744 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87079 Archived-At: Evan Driscoll writes: > Hi, > > I want to write an emacs mode to display a particular type of > file. However, the way I'd like to display the file isn't the literal > text contents in the file, but rather a (text) rendering of parts of > the information contained within. Unfortunately, I don't know any > modes that do something comparable; the closest ones I can think of > are what you get if you load an image. As a postscript I've included a > fairly wordy description of what I'm trying to do to set some context; > It's step (2) in that description that I foresee the most problems > with. There are a lot of modes that don't display the literal data. hexl-mode forms-mode etc As I see it, you have two solutions: - when you switch to your mode, you can create a new "editing" buffer, where the user will give commands, and those commands will update the file buffer. - you can also "parse" the buffer contents and put it in some data structures (kept in buffer local variables), and then show in the buffer any view of that data you want. Editing commands will update the data structure. Saving will unparse it into a text file. There are more variants. The forms-mode for example, actually use the forms file to build a meta data structure in the forms buffer, and actually opens another data file to be edited thru the forms buffer. > What I want is something to the effect of opening the file normally > but then (1) saving the contents of the buffer into a lisp variable, > (2) clearing the buffer, (3) inserting into the buffer some computed > contents from step (1). (Fortunately, I can set the buffer to > read-only for my purposes and I don't have to worry about user edits > to it.) Indeed, you would define your own commands and key bindings to edit the data anyways. > [… some specs …] Indeed, you can program anything (that's computable). emacs lisp is a general algorithmic programming language: you can write any program with it. As a bonus, you have a big library for text editing and a lot of libraries for various other things. Don't let the libraries obscure your view that emacs lisp is just a programming language. You have your specifications. Write the program. -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.