From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: major mode for fpscalc + some meta Date: Wed, 02 Oct 2013 02:19:54 +0200 Organization: Aioe.org NNTP Server Message-ID: <87siwk1q2k.fsf@nl106-137-194.student.uu.se> References: <87mwn4j4om.fsf@nl106-137-194.student.uu.se> <87ioxsl9z6.fsf@nl106-137-194.student.uu.se> <87eh8gs5nf.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1380673518 32441 80.91.229.3 (2 Oct 2013 00:25:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Oct 2013 00:25:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 02 02:25:23 2013 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 1VRAFl-0008KQ-GG for geh-help-gnu-emacs@m.gmane.org; Wed, 02 Oct 2013 02:25:21 +0200 Original-Received: from localhost ([::1]:33322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRAFl-00070n-4F for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Oct 2013 20:25:21 -0400 Original-Path: usenet.stanford.edu!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 112 Original-NNTP-Posting-Host: VVbyYd/iFZoeWNmD9i++cQ.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:1lXH+dryzdnjrCgtO882skMrMJM= Original-Xref: usenet.stanford.edu gnu.emacs.help:201513 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:93782 Archived-At: OK, I hope to close the book on this with this last fix. First, to get indentation, I derived the mode from the C mode. Because the syntaxes are so close, I thought that would work. And it did.... except for the M-; "!" comment. Such comments could be inserted on M-;, but not *removed*, instead, I got another comment layer, just like the nested quotes in messages. Also, comments broke indentation. So, I dropped the C mode, and the comments worked both ways. Last, I used some material I found on the web to get indentation. (The code below is very close to what I found.) (You have to have indentation. "May I indent your code?" is still the worst hacker insult in the book, a book that by now has quite a heft... Seriously, it stinks without it: half the time you just match lines.) I include the new code below, if you don't care to get the real file. I wonder... I got lots of help on this. Personally, I never care for credit because I always use whatever I want, and I expect everyone else to do the same with my stuff. But, if you guys want me to mention "thanks to the GEH people" I'll add it, of course. Last, I made an example in LaTeX how to create diagrams, that can be used in connection with fpscalc, diagrams such as this: http://user.it.uu.se/~embe8573/cis/1-5.pdf The LaTeX source, and more on this: http://user.it.uu.se/~embe8573/cis/ (I write this, as this post might by Googled for fpscalc, and lots of poor students, held at starvation point by the pitch-dark computer industry, might benefit from both the Emacs mode, and the diagram LaTeX skeleton code.) OK, back to the Emacs mode: All material, including screenshots and readmes: http://user.it.uu.se/~embe8573/fps/ The mode code: http://user.it.uu.se/~embe8573/fps/fpscalc.el Example data to edit/run: http://user.it.uu.se/~embe8573/fps/demo.fps The new code: (define-generic-mode 'fpscalc-mode '("!") nil fpscalc-keywords '("\\.fps\\'") '((lambda () (progn (setq indent-line-function 'fpscalc-indent-line) (local-set-key "\C-c\C-c" 'compute) ))) "Major mode for .fps files and the fpscalc tool.") (defvar fpscalc-mode-map (let ((the-map (make-keymap))) (define-key the-map (kbd "TAB") 'newline-and-indent) the-map) "Keymap for the fpscalc major mode.") (defun fpscalc-indent-line () "Indentation function." (interactive) (beginning-of-line) (if (bobp) (indent-line-to 0) (let ((not-indented t) (cur-indent 0) (indent-unit 2)) (if (looking-at "^[ \t]*}") (progn (save-excursion (forward-line -1) (setq cur-indent (- (current-indentation) indent-unit) )) (if (< cur-indent 0) (setq cur-indent 0)) ) (save-excursion (while not-indented (forward-line -1) (if (looking-at "^[ \t]*}") (progn (setq cur-indent (current-indentation)) (setq not-indented nil) ) (if (looking-at "^[ \t]*\\(system\\|declarations\\|semaphores\\|initialise\\|formulas\\)") (progn (setq cur-indent (+ (current-indentation) indent-unit)) (setq not-indented nil) ) (if (bobp) (setq not-indented nil) )))))) (indent-line-to cur-indent) ))) -- Emanuel Berg - programmer (hire me! CV below) computer projects: http://user.it.uu.se/~embe8573 internet activity: http://home.student.uu.se/embe8573