* elisp problem!
@ 2004-02-03 21:00 hans nieuwenhuizen
0 siblings, 0 replies; 3+ messages in thread
From: hans nieuwenhuizen @ 2004-02-03 21:00 UTC (permalink / 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: elisp problem!
[not found] <mailman.1826.1075842117.928.help-gnu-emacs@gnu.org>
@ 2004-02-04 12:58 ` Joakim Hove
2004-02-05 9:02 ` Kai Grossjohann
1 sibling, 0 replies; 3+ messages in thread
From: Joakim Hove @ 2004-02-04 12:58 UTC (permalink / raw)
"hans nieuwenhuizen" <hans@nieuwenhuizen-jk.nl> writes:
> Dear Sirs,
> [...] how to solve this, or --- better --- hear what books may contain
Well, first of all it is less than clear what you want to solve. When
asking for help on a forum like this you should try to formulate a
minimal version of your problem.
> 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 **)
It seems you are trying to push C-throughts down the throat of the
lisp interpreter. Lisp has much more flexible lists (and builtin
hashes could be maybe be usefull).
> ;;; Find type of file
> (search-forward "Filename")
> (re-search-forward "\\.\\(\\w*\\)$") ;;; (setq postfix "\\1") THIS DOES NOT WORK. Copy One after the other?
I would heavily recommend a function like
(defun getheader (header)
...
)
returns the value of the header "header", or nil if it does not exist.
> Where can I find the needed info?
Well it is all in the manual - but you seem to have started out on a
quite ambitious project. Maybe start with something simpler.
Joakim
--
/--------------------------------------------------------------------\
/ Joakim Hove / hove@bccs.no / (55 5) 84076 | \
| Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
| CMU | 5231 Paradis |
\ Thormøhlensgt.55, 5020 Bergen. | 55 91 28 18 /
\--------------------------------------------------------------------/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: elisp problem!
[not found] <mailman.1826.1075842117.928.help-gnu-emacs@gnu.org>
2004-02-04 12:58 ` Joakim Hove
@ 2004-02-05 9:02 ` Kai Grossjohann
1 sibling, 0 replies; 3+ messages in thread
From: Kai Grossjohann @ 2004-02-05 9:02 UTC (permalink / raw)
"hans nieuwenhuizen" <hans@nieuwenhuizen-jk.nl> writes:
> 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.
Quite often, Emacs already has a package for what you want. For
example, see the Autotype manual (C-h i d m Autotype RET) for
automatically inserting stuff.
> After an update I want emacs to change the 'Lastedit" date
Emacs comes with time-stamp.el which is reasonably easy to use.
However, by default it expects a somewhat different format of the
given line. But time-stamp.el is configurable so you can get
something that's closer to your format, at least.
> and write the old date with a leading "Intermediate comment" lined
> up wth the others under 'Changelog".
Hm. Writing the old date does not automatically work. Hm. What to
do?
In any case, the indent-new-comment-line function is proably useful
for inserting the ChangeLog stuff.
Another way to get a similar effect is to use a revision control
system, such as RCS. With RCS, you put $Log$ into the file and then
RCS will take care of automatically writing the log message at that
spot. Of course, this requires you to type C-x v v to create a new
version, but I hope that's not too terrible. As an added value, you
get access to old versions.
Kai
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-05 9:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-03 21:00 elisp problem! hans nieuwenhuizen
[not found] <mailman.1826.1075842117.928.help-gnu-emacs@gnu.org>
2004-02-04 12:58 ` Joakim Hove
2004-02-05 9:02 ` Kai Grossjohann
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.