unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "hans nieuwenhuizen" <hans@nieuwenhuizen-jk.nl>
Subject: elisp problem!
Date: Tue, 3 Feb 2004 22:00:28 +0100	[thread overview]
Message-ID: <000401c3ea98$f0481410$93d19b83@campus.tue.nl> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 5814 bytes --]

Dear Sirs, 

I use emacs 21.2.1, have studied Cameron and Glickstein, and read most of elisp-manual-21-2-7, emacs-lisp-intro-2.04, elisp-20.2.5, as well as the underlying .texi files for searching subjects, but did not find even a suggestion how to solve my problems. I have asked for a quotation for the printed version but not yet received it and I would very much appreciate to receive a hint from you how to solve this, or --- better --- hear what books may contain what I need. 

The problem: 

I have a program that builds any sourcefile ( .txt, .texi, .tex, .ltx, .pl, .dh, .c, .cc, ...., 22 in total, see below ) with standard header including date of last update like this:


;; 
;;   Category 1        : 53482 
;;   ID                : 
;;   Category 2        : 
;;   Filename          : UpdateDate.el
;;   Lastedit          : 2004-01-31
;;   Version           : 1.0.0
;;   
;;   System            : Emacs lisp
;;   Date of 1st issue : 2004-01-31
;;   Directory         : /home/hans/5.Interesses/3.Computers/4.Developments/8.Utilities/2.Diskutils/UpdateDate.el
;;   Changelog         : 
;;   Status            : 
;;   Purpose           : 
;;   
;;   Usage             : 
;; 
;;         
;;         +---------------------------------------------------------------+
;;         | Copyright:                                                    |
;;         |                                                               | 
;;         |              Ir. J.K. Nieuwenhuizen B.V.                      |
;;         |   dom Paul Bellotweg 8, 5624 KZ Eindhoven,  The Netherlands   |
;;         |                                                               |
;;         |   Telephone [ {..31|0} 40 ] 2442226                           |
;;         |   email     nhzbv@nieuwenhuizen-jk.nl                         |
;;         |                     Registration KvK Eindhoven 170370770000   |
;;         +---------------------------------------------------------------+
;;         
;; 
;; 

;; 
;; =======================  B E G I N   O F   F I L E  ========================
;; 

After an update I want emacs to change the 'Lastedit" date and write the old date with a leading "Intermediate comment" lined up wth the others under 'Changelog".
 
I thereto need a 21 * 6 S(string)matrix like:    

(setq Filetypes 

;;; === No, Title, postfix, Single, Opening, Closing, Intermediate ===
;;; Filetypes, array[0-21] of array[0-5]
    ( vconcat 
 [ "Pure Text"          "txt"  "### " "### " "### "   "### " ] 
 [ "Texinfo"            "texi" "### " "### " "### " "### " ] 
 [ "Plain TeX"          "tex"  "%%% " "%%% " "%%% " "%%% " ]
 [ "LaTeX"              "ltx"  "%%% " "%%% " "%%% " "%%% " ]
 [ "HTML"               "html" "    " "<!--" "--> " "    " ]
 [ "Assembler"          "asm"  ";;; " ";;; " ";;; " ";;; " ]
 [ "GNU Assembler"      "S"    ";;; " ";;; " ";;; " ";;; " ]
 [ "Emacs lisp"         "el"   ";;; " ";;; " ";;; " ";;; " ]  ( <--- this file )
 [ "Acad lisp"          "lsp"  ";;; " ";;; " ";;; " ";;; " ]
 [ "Perl script"        "pl"   "### " "### " "### " "### " ]
 [ "Bash script"        "sh"   "### " "### " "### " "### " ]
 [ "C definitions"      "h"    "    " "/*  " " */ " " *  " ]
 [ "C main"             "c"    "    " "/*  " " */ " " *  " ]
 [ "C procedures"       "c"    "    " "/*  " " */ " " *  " ]
 [ "C++ definitions"    "hpp"  "    " "/*  " " */ " " *  " ]
 [ "C++ implementation" "cc"   " // " "/*  " " */ " " *  " ]
 [ "C++ main program"   "cc"   " // " "/*  " " */ " " *  " ]
 [ "C++ procedures"     "cc"   " // " "/*  " " */ " " *  " ]
 [ "C Makefile"         "mak"  "### " "### " "### " "### " ]
 [ "C++ Makefile"       "mak"  "### " "### " "### " "### " ]
 [ "Prof. Nhz. letter"  "ltx"  "%%% " "%%% " "%%% " "%%% " ]
 [ "NhzBV letter"       "ltx"  "%%% " "%%% " "%%% " "%%% " ]
    )
) ### (setq Filetypes 

but the best I an do is build ( as shown ) a 126 items Vector and extract element [row][column] as [ 6 * row + column]. 
(** `(aref (( aref Filetypes [row] )) [column] )` is flagged as error **) 

(defun update-date ( )
    "Update Fileheader::LastEdit with Today and Fileheader::Changelog with present LastEdit."
    (interactive)
    (goto-char (point-min))
;;; Find type of file
    (search-forward "Filename")
    (re-search-forward "\\.\\(\\w*\\)$")    ;;;     (setq postfix "\\1") THIS DOES NOT WORK. Copy One after the other?
    (setq end (point))
    (search-backward ".")
    (forward-char)                 

    (setq start (point))       ;;; region : "el\n" above. start=101, end=103 OK
    (kill-ring-save start end) ;;; And now? How to copy the kill-ring into a form to be combared with Filetypes[count][1]?
  

Now I need to compare the region ( start - end ) with column #1 of the matrix to find what commentsymbol to use. But none of my books or manuals tells me how to 
copy a regexp matched ( see "\\(\\w*\\)$" above, as in perl : postfix = $1; ) so that I can compare it with the items of column #1 in my matrix. Even in your 992 pages long manual I don't see how to copy the region into a variable ( see postfix above ) or register, nor how to read from one of the 256 registers identified by 1 single char ( ? ). 

Or is there a better way to do these things? 


Where can I find the needed info?  
 


;; 
;; =========================  E N D   O F   F I L E  ==========================
;; 

Thanks,

Nieuwenhuizen
2004-02-03




----------------------------------------------------------------------------
Prof. Ir. j.k. nieuwenhuizen                 email: hans@nieuwenhuizen-jk.nl
dom Paul Bellotweg 8
5624 KZ Eindhoven - NL

Tel [{++31|0}40]2442226
-----------------------------------------------------------------------------

[-- Attachment #1.2: Type: text/html, Size: 13017 bytes --]

[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

             reply	other threads:[~2004-02-03 21:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-03 21:00 hans nieuwenhuizen [this message]
     [not found] <mailman.1826.1075842117.928.help-gnu-emacs@gnu.org>
2004-02-04 12:58 ` elisp problem! Joakim Hove
2004-02-05  9:02 ` Kai Grossjohann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000401c3ea98$f0481410$93d19b83@campus.tue.nl' \
    --to=hans@nieuwenhuizen-jk.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).