help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

elisp problem!


From: hans nieuwenhuizen
Subject: elisp problem!
Date: Tue, 3 Feb 2004 22:00:28 +0100

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    
address@hidden                         |
;;         |                     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:
address@hidden
dom Paul Bellotweg 8
5624 KZ Eindhoven - NL
 
Tel [{++31|0}40]2442226
-----------------------------------------------------------------------------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]