* code critique requested
@ 2007-11-30 16:10 metaperl.com
2007-11-30 16:44 ` Lennart Borgman (gmail)
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: metaperl.com @ 2007-11-30 16:10 UTC (permalink / raw)
To: help-gnu-emacs
Hi, any feedback on improving this is appreciated. I have been getting
some reports with warnings on byte-compilation. I'm mainly interested
in GNU Emacs correctness, but if I can support both major emacsen
without too much hassle, then I will do it.
;;; asciidoc.el --- asciidoc text file development support
;; Copyright (C) 2007 Terrence Brannon <bauhaus@metaperl.com>
;; Author: Terrence Brannon <bauhaus@metaperl.com>
;; Created: 21 Sept 2007
;; Version: 0.1
;; Keywords: text-formatting
;; This file is not (yet) part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Description:
;; Suggested (but entirely optional) add-ons:
;; doc-mode: font-locking for asciidoc buffers
;; http://xpt.sourceforge.net/tools/doc-mode/
;; - connect asciidoc.el to doc-mode as follows:
;; (autoload 'doc-mode "doc-mode" nil t)
;; (add-to-list 'auto-mode-alist '("\\.adoc$" . doc-mode))
;; (add-hook 'doc-mode-hook
;; '(lambda ()
;; (turn-on-auto-fill)
;; (require 'asciidoc)))
;; Author extends thanks to:
;; Steve Youngs (JackaLX on irc://irc.freenode.net/xemacs)
;; bpalmer, twb
;; Alexander Kinzer - byte-compile bug reports
;; Version control:
;; This software is under Mercurial version control and maybe
retrieved via:
;; hg clone http://hg.metaperl.com/asciidoc-el
;; Code:
(setq debug-on-error t)
(require 'easymenu)
(require 'cl)
(require 'apropos)
(require 'compile)
(defvar *asciidoc-indent-level* 2 "Number of spaces to indent per
level")
(defvar *delimiter-length* 70
"How many characters to use when building a delimited block string.
4 min")
(defun asciidoc-header (title author revision)
"Insert asciidoc header consisting of TITLE and optional AUTHOR and
REVISION"
(interactive "sHeader title: \nsHeader author (return if none):
\nsHeader revision (return if none):")
(insert
(concat title "\n"
(make-string (length title) ?=) "\n"
author "\n"
revision "\n"
"\n"
)))
(defun asciidoc-get-started ()
(interactive)
(let ((date (format-time-string "%D" (current-time))))
(asciidoc-header "Document Title"
"Terrence Brannon <bauhaus@metaperl.com>"
date)))
(defun asciidoc-emphasized (text)
"Insert text with asciidoc emphasis formatting"
(interactive "sText to be emphasized: ")
(insert
(concat "_" text "_")))
(defun asciidoc-strong (text)
"Insert text with asciidoc strong formatting"
(interactive "sText to be strong-formatted: ")
(insert
(concat "*" text "*")))
(defun asciidoc-monospace (text)
"Insert text with asciidoc monospace formatting"
(interactive "sText to be monospace formatted: ")
(insert
(concat "`" text "`")))
(defun asciidoc-quoted (text)
"Insert text with asciidoc quoted-text formatting"
(interactive "sText to be enclosed in quotation marks: ")
(insert
(concat "``" text "''")))
(defun asciidoc-unquoted (text)
"Insert text with asciidoc unquoted text formatting"
(interactive "sText to be non-quoted: ")
(insert
(concat "#" text "#")))
(defun asciidoc-passthru-triple-plus (text)
"Insert text with asciidoc triple plus passthrough formatting"
(interactive "sText to be formatted for no change: ")
(insert
(concat "+++" text "+++")))
(defun asciidoc-passthru-double-dollar (text)
"Insert text with asciidoc double-dollar formatting"
(interactive "sText to be formatted for no change except escaping
special characters: ")
(insert
(concat "$$" text "$$")))
(defun asciidoc-superscript (text)
"Insert text with asciidoc superscript formatting"
(interactive "sText to be formatted for superscripting: ")
(insert
(concat "^" text "^")))
(defun asciidoc-subscript (text)
"Insert text with asciidoc subscript formatting"
(interactive "sText to be formatted for subscripting: ")
(insert
(concat "~" text "~")))
(defun asciidoc-line-break ()
"Insert asciidoc forced line break"
(interactive)
(insert
(concat " +\n")))
(defun asciidoc-horizontal-rule ()
"Insert asciidoc <hr /> tag for HTML only"
(interactive)
(insert
(concat "'''\n")))
(defun asciidoc-copyright ()
"Insert asciidoc copyright replacement"
(interactive)
(insert "(C) "))
(defun asciidoc-trademark ()
"Insert asciidoc copyright replacement"
(interactive)
(insert "(TM) "))
(defun asciidoc-registered-trademark ()
"Insert asciidoc registered copyright replacement"
(interactive)
(insert "(R) "))
(defun asciidoc-section-title (section-level title)
"Insert asciidoc one-line title syntax"
(interactive "NNumber of equals signs (2-4): \nsSection title: ")
; " " equals-signs
(let ((equals-signs (make-string (1+ section-level) ?=)))
(insert
(concat
"\n"
equals-signs " " title
"\n\n"))))
(defun asciidoc-block-title (text)
"Insert text with asciidoc block title formatting"
(interactive "sText to be formatted as block title: ")
(insert
(concat "." text "\n")))
(defun asciidoc-block-id-element (text)
"Insert text with asciidoc BlockId Element formatting"
(interactive "sText to be formatted as block-id: ")
(insert
(concat "[[" text "]]" "\n")))
(defun asciidoc-block-reference (block-id descriptive-text)
"Insert asciidoc reference to a block consisting of BLOCK-ID and
DESCRIPTIVE-TEXT"
(interactive "sBlockId: \nsDescriptive text: ")
(insert
(concat "<<" block-id "," descriptive-text ">>"
)))
(defun asciidoc-verse-paragraph (text)
"Insert verse paragraph formatting"
(interactive)
(insert (concat "[verse]" "\n")))
(defun asciidoc-literal-paragraph (text)
"Insert literal paragraph formatting"
(interactive)
(insert (concat " " "\n")))
(defun asciidoc-admonition-paragraph (text)
"Insert admonition paragraph formatting"
(interactive)
(insert (concat "[NOTE]" "\n")))
(defun asciidoc-delimited-block (delimiter text)
""
(let ((str (make-string *delimiter-length* delimiter)))
(insert (concat str "\n" text "\n" str "\n\n"))))
(defun asciidoc-comment-block (text)
"create an asciidoc CommentBlock"
(interactive "sText for comment block? ")
(asciidoc-delimited-block ?/ text))
(defun asciidoc-passthru-block (text)
"create an asciidoc PassthroughBlock"
(interactive "sText for passthru block? ")
(asciidoc-delimited-block ?+ text))
(defun asciidoc-listing-block (text)
"create an asciidoc ListingBlock"
(interactive "sText for listing block? ")
(asciidoc-delimited-block ?- text))
(defun asciidoc-literal-block (text)
"create an asciidoc LiteralBlock"
(interactive "sText for literal block? ")
(asciidoc-delimited-block ?. text))
(defun asciidoc-sidebar-block (text)
"create an asciidoc SidebarBlock"
(interactive "sText for sidebar block? ")
(asciidoc-delimited-block ?* text))
(defun asciidoc-example-block (text)
"create an asciidoc ExampleBlock, using TEXT and optionally
modifying the default EXAMPLE-LABEL and EXAMPLE-DESCRIPTION"
(interactive "sText for example block? ")
(let ((example-label (read-string "Example label? (it needs a space
at the end) " "Example: "))
(example-description (read-string "Example description? " "An
example")))
(if (not (string= "" example-label))
(insert "[caption=" "\"" example-label "\"" "]" "\n"))
(if (not (string= "" example-description))
(insert "." example-description "\n"))
(asciidoc-delimited-block ?= text)))
(defun asciidoc-quotation-block (text author source)
"create an asciidoc QuoteBlock"
(interactive "sText of quotation? \nsAuthor of quotation? \nsWhere
did this quotation come from? ")
(insert
(concat "["
"attribution=" "\"" author "\""
","
"citetitle=" "\"" source "\""
"]" "\n"))
(asciidoc-delimited-block ?_ text))
(defun asciidoc-compile ()
(interactive)
(setq compile-command
(concat
"asciidoc -a numbered -a toc -a toclevels=4" " "
(file-name-nondirectory (buffer-file-name))
))
(call-interactively 'compile))
(defvar *asciidoc-bullet* '("-" "*")
"strings representing each of the two bullet levels offered by
Asciidoc")
(defun asciidoc-bullet-item (bullet-level text)
"At BULLET_LEVEL, insert TEXT"
(interactive "NBullet level (1 or 2): \nsText for bullet: ")
(let* ((level (if (= bullet-level 2) 1 0))
(bullet (nth level *asciidoc-bullet*))
(tab-space (make-string (* level 4) ?\s)))
(insert
(concat
tab-space bullet " " text "\n"))))
(defun asciidoc-numbered-list-item (item-level text)
"At ITEM-LEVEL, insert TEXT"
(interactive "NItem level (1 or 2): \nsText for bullet: ")
(let* ((level (if (= item-level 2) 2 1))
(bullet (make-string level ?.))
(tab-space (make-string (* (- level 1) 4) ?\s)))
(insert
(concat
tab-space bullet " " text "\n"))))
(defun asciidoc-labelled-list-item (text)
"Insert TEXT"
(interactive "sLabel for list item: ")
(insert
(concat
text "::" "\n ")))
(defun asciidoc-bibliography-item (ref-label ref-text)
"Insert bibliography item consisting of REF-LABEL and REF-TEXT"
(interactive "sLabel for bib item: \nsText of bibitem: ")
(insert
(concat
"+" " " "[[[" ref-label "]]]" " " ref-text "\n")))
(defun asciidoc-href (url link-text)
"Insert hyperlink consisting of URL and LINK-TEXT"
(interactive "sURL: \nsText describing URL: ")
(insert
(concat
url "[" link-text "]" "\n"
)))
(defun asciidoc-relative-href (url link-text)
"Insert hyperlink consisting of URL and LINK-TEXT"
(interactive "sRelative path to file (anchors allowed): \nsText
describing link: ")
(insert
(concat
"link:"
url "[" link-text "]" "\n"
)))
(defun asciidoc-image-href (url link-text)
"Insert hyperlink consisting of URL and LINK-TEXT"
(interactive "sURL to image file: \nsText describing image (only
displayed when image unavailable): ")
(insert
(concat
"image:"
url "[" "\"" link-text "\"" "]" "\n"
)))
(setq asciidoc-global-menuspec
(list "Doc"
(list
"Links and refs"
(vector "Href" 'asciidoc-href)
(vector "Image" 'asciidoc-image-href)
(vector "Relative url" 'asciidoc-relative-href)
(vector "Internal document references" 'asciidoc-block-
reference)
)
(list
"Reference items"
(vector "Bibliography listing" 'asciidoc-bibliography-item)
(vector "BlockId element" 'asciidoc-block-id-element))
(list
"Bullets and lists"
(vector "Bulleted list" 'asciidoc-bullet-item)
(vector "Numbered list" 'asciidoc-numbered-list-item)
(vector "Labelled list" 'asciidoc-labelled-list-item)
)
(list
"Text formatting"
(vector "Emphasis" 'asciidoc-emphasized)
(vector "Strong (bold)" 'asciidoc-strong)
(vector "Monospaced" 'asciidoc-monospace)
(vector "Quotation marks around text" 'asciidoc-quoted)
(vector "Superscript" 'asciidoc-superscript)
(vector "Subscript" 'asciidoc-subscript)
)
(list
"Special symbols"
(vector "Copyright" 'asciidoc-copyright)
(vector "Trademark" 'asciidoc-trademark)
(vector "Registered trademark" 'asciidoc-registered-trademark)
)
(list
"Blocks"
(vector "Example block" 'asciidoc-example-block)
(vector "Listing block" 'asciidoc-listing-block)
(vector "Quotation block" 'asciidoc-quotation-block)
(vector "Literal block" 'asciidoc-literal-block)
(vector "Sidebar block" 'asciidoc-sidebar-block)
(vector "Comment block" 'asciidoc-comment-block)
(vector "Pass-through block" 'asciidoc-passthru-triple-plus)
)
(list
"Run Asciidoc"
(vector "Compile" 'asciidoc-compile)
(vector "Recompile" 'recompile)
)
(vector "Start document" 'asciidoc-get-started)
))
(easy-menu-define
asciidoc-global-menu global-map "" asciidoc-global-menuspec)
(provide 'asciidoc)
;;; asciidoc.el ends here
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-11-30 16:10 code critique requested metaperl.com
@ 2007-11-30 16:44 ` Lennart Borgman (gmail)
[not found] ` <mailman.4360.1196441057.18990.help-gnu-emacs@gnu.org>
2007-12-01 16:27 ` John Paul Wallington
2 siblings, 0 replies; 10+ messages in thread
From: Lennart Borgman (gmail) @ 2007-11-30 16:44 UTC (permalink / raw)
To: metaperl.com; +Cc: help-gnu-emacs
metaperl.com wrote:
> Hi, any feedback on improving this is appreciated. I have been getting
> some reports with warnings on byte-compilation. I'm mainly interested
> in GNU Emacs correctness, but if I can support both major emacsen
> without too much hassle, then I will do it.
>
> ;;; asciidoc.el --- asciidoc text file development support
...
> ;;; Description:
>
> ;; Suggested (but entirely optional) add-ons:
> ;; doc-mode: font-locking for asciidoc buffers
> ;; http://xpt.sourceforge.net/tools/doc-mode/
> ;; - connect asciidoc.el to doc-mode as follows:
> ;; (autoload 'doc-mode "doc-mode" nil t)
> ;; (add-to-list 'auto-mode-alist '("\\.adoc$" . doc-mode))
> ;; (add-hook 'doc-mode-hook
> ;; '(lambda ()
> ;; (turn-on-auto-fill)
> ;; (require 'asciidoc)))
>
> ;; Author extends thanks to:
> ;; Steve Youngs (JackaLX on irc://irc.freenode.net/xemacs)
> ;; bpalmer, twb
> ;; Alexander Kinzer - byte-compile bug reports
It would be nice if the description said something more about what the
file does or where to get more info.
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.4360.1196441057.18990.help-gnu-emacs@gnu.org>]
* Re: code critique requested
[not found] ` <mailman.4360.1196441057.18990.help-gnu-emacs@gnu.org>
@ 2007-11-30 18:25 ` metaperl.com
2007-11-30 19:09 ` Lennart Borgman (gmail)
2007-11-30 19:36 ` Joel J. Adamson
0 siblings, 2 replies; 10+ messages in thread
From: metaperl.com @ 2007-11-30 18:25 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 30, 11:44 am, "Lennart Borgman (gmail)"
<lennart.borg...@gmail.com> wrote:
>
> It would be nice if the description said something more about what the
> file does or where to get more info
Ok, I have updated the source code (below) with such information.
Thanks for the feedback.
;;; asciidoc.el --- asciidoc text file development support
;; Copyright (C) 2007 Terrence Brannon <bauhaus@metaperl.com>
;; Author: Terrence Brannon <bauhaus@metaperl.com>
;; Created: 21 Sept 2007
;; Version: 0.1
;; Keywords: text-formatting
;; This file is not (yet) part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Description:
;; == website
;; http://www.metaperl.com/asciidoc-el/
;; == Version control:
;; This software is under Mercurial version control is retrieved via:
;; hg clone http://hg.metaperl.com/asciidoc-el
;; == Suggested (but entirely optional) add-ons:
;; doc-mode: font-locking for asciidoc buffers
;; http://xpt.sourceforge.net/tools/doc-mode/
;; - connect asciidoc.el to doc-mode as follows:
;; (autoload 'doc-mode "doc-mode" nil t)
;; (add-to-list 'auto-mode-alist '("\\.adoc$" . doc-mode))
;; (add-hook 'doc-mode-hook
;; '(lambda ()
;; (turn-on-auto-fill)
;; (require 'asciidoc)))
;; == Author extends thanks to
;; Steve Youngs (JackaLX on irc://irc.freenode.net/xemacs)
;; bpalmer, twb
;; Alexander Kinzer - byte-compile bug reports
;; == Usage
;; When this file is loaded, it creates a menubar option labeled
"Doc".
;; You can go to this menubar option to get help formatting text in
;; http://methods.co.nz/asciidoc[Asciidoc] format.
;; There is also some support for turning your Asciidoc document into
;; HTML in the menubar.
;; Code:
(setq debug-on-error t)
(require 'apropos)
(require 'cl)
(require 'compile)
(require 'easymenu)
(defvar *asciidoc-indent-level* 2 "Number of spaces to indent per
level")
(defvar *delimiter-length* 70
"How many characters to use when building a delimited block string.
4 min")
(defun asciidoc-header (title author revision)
"Insert asciidoc header consisting of TITLE and optional AUTHOR and
REVISION"
(interactive "sHeader title: \nsHeader author (return if none):
\nsHeader revision (return if none):")
(insert
(concat title "\n"
(make-string (length title) ?=) "\n"
author "\n"
revision "\n"
"\n"
)))
(defun asciidoc-get-started ()
(interactive)
(let ((date (format-time-string "%D" (current-time))))
(asciidoc-header "Document Title"
"Terrence Brannon <bauhaus@metaperl.com>"
date)))
(defun asciidoc-emphasized (text)
"Insert text with asciidoc emphasis formatting"
(interactive "sText to be emphasized: ")
(insert
(concat "_" text "_")))
(defun asciidoc-strong (text)
"Insert text with asciidoc strong formatting"
(interactive "sText to be strong-formatted: ")
(insert
(concat "*" text "*")))
(defun asciidoc-monospace (text)
"Insert text with asciidoc monospace formatting"
(interactive "sText to be monospace formatted: ")
(insert
(concat "`" text "`")))
(defun asciidoc-quoted (text)
"Insert text with asciidoc quoted-text formatting"
(interactive "sText to be enclosed in quotation marks: ")
(insert
(concat "``" text "''")))
(defun asciidoc-unquoted (text)
"Insert text with asciidoc unquoted text formatting"
(interactive "sText to be non-quoted: ")
(insert
(concat "#" text "#")))
(defun asciidoc-passthru-triple-plus (text)
"Insert text with asciidoc triple plus passthrough formatting"
(interactive "sText to be formatted for no change: ")
(insert
(concat "+++" text "+++")))
(defun asciidoc-passthru-double-dollar (text)
"Insert text with asciidoc double-dollar formatting"
(interactive "sText to be formatted for no change except escaping
special characters: ")
(insert
(concat "$$" text "$$")))
(defun asciidoc-superscript (text)
"Insert text with asciidoc superscript formatting"
(interactive "sText to be formatted for superscripting: ")
(insert
(concat "^" text "^")))
(defun asciidoc-subscript (text)
"Insert text with asciidoc subscript formatting"
(interactive "sText to be formatted for subscripting: ")
(insert
(concat "~" text "~")))
(defun asciidoc-line-break ()
"Insert asciidoc forced line break"
(interactive)
(insert
(concat " +\n")))
(defun asciidoc-horizontal-rule ()
"Insert asciidoc <hr /> tag for HTML only"
(interactive)
(insert
(concat "'''\n")))
(defun asciidoc-copyright ()
"Insert asciidoc copyright replacement"
(interactive)
(insert "(C) "))
(defun asciidoc-trademark ()
"Insert asciidoc copyright replacement"
(interactive)
(insert "(TM) "))
(defun asciidoc-registered-trademark ()
"Insert asciidoc registered copyright replacement"
(interactive)
(insert "(R) "))
(defun asciidoc-section-title (section-level title)
"Insert asciidoc one-line title syntax"
(interactive "NNumber of equals signs (2-4): \nsSection title: ")
; " " equals-signs
(let ((equals-signs (make-string (1+ section-level) ?=)))
(insert
(concat
"\n"
equals-signs " " title
"\n\n"))))
(defun asciidoc-block-title (text)
"Insert text with asciidoc block title formatting"
(interactive "sText to be formatted as block title: ")
(insert
(concat "." text "\n")))
(defun asciidoc-block-id-element (text)
"Insert text with asciidoc BlockId Element formatting"
(interactive "sText to be formatted as block-id: ")
(insert
(concat "[[" text "]]" "\n")))
(defun asciidoc-block-reference (block-id descriptive-text)
"Insert asciidoc reference to a block consisting of BLOCK-ID and
DESCRIPTIVE-TEXT"
(interactive "sBlockId: \nsDescriptive text: ")
(insert
(concat "<<" block-id "," descriptive-text ">>"
)))
(defun asciidoc-verse-paragraph (text)
"Insert verse paragraph formatting"
(interactive)
(insert (concat "[verse]" "\n")))
(defun asciidoc-literal-paragraph (text)
"Insert literal paragraph formatting"
(interactive)
(insert (concat " " "\n")))
(defun asciidoc-admonition-paragraph (text)
"Insert admonition paragraph formatting"
(interactive)
(insert (concat "[NOTE]" "\n")))
(defun asciidoc-delimited-block (delimiter text)
""
(let ((str (make-string *delimiter-length* delimiter)))
(insert (concat str "\n" text "\n" str "\n\n"))))
(defun asciidoc-comment-block (text)
"create an asciidoc CommentBlock"
(interactive "sText for comment block? ")
(asciidoc-delimited-block ?/ text))
(defun asciidoc-passthru-block (text)
"create an asciidoc PassthroughBlock"
(interactive "sText for passthru block? ")
(asciidoc-delimited-block ?+ text))
(defun asciidoc-listing-block (text)
"create an asciidoc ListingBlock"
(interactive "sText for listing block? ")
(asciidoc-delimited-block ?- text))
(defun asciidoc-literal-block (text)
"create an asciidoc LiteralBlock"
(interactive "sText for literal block? ")
(asciidoc-delimited-block ?. text))
(defun asciidoc-sidebar-block (text)
"create an asciidoc SidebarBlock"
(interactive "sText for sidebar block? ")
(asciidoc-delimited-block ?* text))
(defun asciidoc-example-block (text)
"create an asciidoc ExampleBlock, using TEXT and optionally
modifying the default EXAMPLE-LABEL and EXAMPLE-DESCRIPTION"
(interactive "sText for example block? ")
(let ((example-label (read-string "Example label? (it needs a space
at the end) " "Example: "))
(example-description (read-string "Example description? " "An
example")))
(if (not (string= "" example-label))
(insert "[caption=" "\"" example-label "\"" "]" "\n"))
(if (not (string= "" example-description))
(insert "." example-description "\n"))
(asciidoc-delimited-block ?= text)))
(defun asciidoc-quotation-block (text author source)
"create an asciidoc QuoteBlock"
(interactive "sText of quotation? \nsAuthor of quotation? \nsWhere
did this quotation come from? ")
(insert
(concat "["
"attribution=" "\"" author "\""
","
"citetitle=" "\"" source "\""
"]" "\n"))
(asciidoc-delimited-block ?_ text))
(defun asciidoc-compile ()
(interactive)
(setq compile-command
(concat
"asciidoc -a numbered -a toc -a toclevels=4" " "
(file-name-nondirectory (buffer-file-name))
))
(call-interactively 'compile))
(defvar *asciidoc-bullet* '("-" "*")
"strings representing each of the two bullet levels offered by
Asciidoc")
(defun asciidoc-bullet-item (bullet-level text)
"At BULLET_LEVEL, insert TEXT"
(interactive "NBullet level (1 or 2): \nsText for bullet: ")
(let* ((level (if (= bullet-level 2) 1 0))
(bullet (nth level *asciidoc-bullet*))
(tab-space (make-string (* level 4) ?\s)))
(insert
(concat
tab-space bullet " " text "\n"))))
(defun asciidoc-numbered-list-item (item-level text)
"At ITEM-LEVEL, insert TEXT"
(interactive "NItem level (1 or 2): \nsText for bullet: ")
(let* ((level (if (= item-level 2) 2 1))
(bullet (make-string level ?.))
(tab-space (make-string (* (- level 1) 4) ?\s)))
(insert
(concat
tab-space bullet " " text "\n"))))
(defun asciidoc-labelled-list-item (text)
"Insert TEXT"
(interactive "sLabel for list item: ")
(insert
(concat
text "::" "\n ")))
(defun asciidoc-bibliography-item (ref-label ref-text)
"Insert bibliography item consisting of REF-LABEL and REF-TEXT"
(interactive "sLabel for bib item: \nsText of bibitem: ")
(insert
(concat
"+" " " "[[[" ref-label "]]]" " " ref-text "\n")))
(defun asciidoc-href (url link-text)
"Insert hyperlink consisting of URL and LINK-TEXT"
(interactive "sURL: \nsText describing URL: ")
(insert
(concat
url "[" link-text "]" "\n"
)))
(defun asciidoc-relative-href (url link-text)
"Insert hyperlink consisting of URL and LINK-TEXT"
(interactive "sRelative path to file (anchors allowed): \nsText
describing link: ")
(insert
(concat
"link:"
url "[" link-text "]" "\n"
)))
(defun asciidoc-image-href (url link-text)
"Insert hyperlink consisting of URL and LINK-TEXT"
(interactive "sURL to image file: \nsText describing image (only
displayed when image unavailable): ")
(insert
(concat
"image:"
url "[" "\"" link-text "\"" "]" "\n"
)))
(setq asciidoc-global-menuspec
(list "Doc"
(list
"Links and refs"
(vector "Href" 'asciidoc-href)
(vector "Image" 'asciidoc-image-href)
(vector "Relative url" 'asciidoc-relative-href)
(vector "Internal document references" 'asciidoc-block-
reference)
)
(list
"Reference items"
(vector "Bibliography listing" 'asciidoc-bibliography-item)
(vector "BlockId element" 'asciidoc-block-id-element))
(list
"Bullets and lists"
(vector "Bulleted list" 'asciidoc-bullet-item)
(vector "Numbered list" 'asciidoc-numbered-list-item)
(vector "Labelled list" 'asciidoc-labelled-list-item)
)
(list
"Text formatting"
(vector "Emphasis" 'asciidoc-emphasized)
(vector "Strong (bold)" 'asciidoc-strong)
(vector "Monospaced" 'asciidoc-monospace)
(vector "Quotation marks around text" 'asciidoc-quoted)
(vector "Superscript" 'asciidoc-superscript)
(vector "Subscript" 'asciidoc-subscript)
)
(list
"Special symbols"
(vector "Copyright" 'asciidoc-copyright)
(vector "Trademark" 'asciidoc-trademark)
(vector "Registered trademark" 'asciidoc-registered-trademark)
)
(list
"Blocks"
(vector "Example block" 'asciidoc-example-block)
(vector "Listing block" 'asciidoc-listing-block)
(vector "Quotation block" 'asciidoc-quotation-block)
(vector "Literal block" 'asciidoc-literal-block)
(vector "Sidebar block" 'asciidoc-sidebar-block)
(vector "Comment block" 'asciidoc-comment-block)
(vector "Pass-through block" 'asciidoc-passthru-triple-plus)
)
(list
"Run Asciidoc"
(vector "Compile" 'asciidoc-compile)
(vector "Recompile" 'recompile)
)
(vector "Start document" 'asciidoc-get-started)
))
(easy-menu-define
asciidoc-global-menu global-map "" asciidoc-global-menuspec)
(provide 'asciidoc)
;;; asciidoc.el ends here
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-11-30 18:25 ` metaperl.com
@ 2007-11-30 19:09 ` Lennart Borgman (gmail)
2007-11-30 19:36 ` Joel J. Adamson
1 sibling, 0 replies; 10+ messages in thread
From: Lennart Borgman (gmail) @ 2007-11-30 19:09 UTC (permalink / raw)
To: metaperl.com; +Cc: help-gnu-emacs
metaperl.com wrote:
> On Nov 30, 11:44 am, "Lennart Borgman (gmail)"
> <lennart.borg...@gmail.com> wrote:
>
>> It would be nice if the description said something more about what the
>> file does or where to get more info
>
> Ok, I have updated the source code (below) with such information.
> Thanks for the feedback.
Maybe you should present asciidoc, I had to find out what it was by
searching the net. A link should suffice.
Please look into major modes in the Emacs manual. Notice the function
define-derived-mode.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-11-30 18:25 ` metaperl.com
2007-11-30 19:09 ` Lennart Borgman (gmail)
@ 2007-11-30 19:36 ` Joel J. Adamson
1 sibling, 0 replies; 10+ messages in thread
From: Joel J. Adamson @ 2007-11-30 19:36 UTC (permalink / raw)
To: help-gnu-emacs
"metaperl.com" <metaperl@gmail.com> writes:
> On Nov 30, 11:44 am, "Lennart Borgman (gmail)"
> <lennart.borg...@gmail.com> wrote:
>
>>
>> It would be nice if the description said something more about what the
>> file does or where to get more info
I second that; plus you could post this on gnu.emacs.sources and get a
"critique" without even requesting it ;) Of course, if you do post
there, you should adhere directly to the guidelines in the Elisp manual,
especially the Appendices.
Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA 02114
(617) 643-1432
(303) 880-3109
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-11-30 16:10 code critique requested metaperl.com
2007-11-30 16:44 ` Lennart Borgman (gmail)
[not found] ` <mailman.4360.1196441057.18990.help-gnu-emacs@gnu.org>
@ 2007-12-01 16:27 ` John Paul Wallington
2007-12-02 1:29 ` Tim X
2 siblings, 1 reply; 10+ messages in thread
From: John Paul Wallington @ 2007-12-01 16:27 UTC (permalink / raw)
To: help-gnu-emacs
metaperl.com wrote:
> (defvar *asciidoc-indent-level*
Sticking asterisks around special variable names is a Common Lisp
affliction that isn't done in Emacs Lisp.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-12-01 16:27 ` John Paul Wallington
@ 2007-12-02 1:29 ` Tim X
2007-12-02 10:44 ` Sebastian Tennant
0 siblings, 1 reply; 10+ messages in thread
From: Tim X @ 2007-12-02 1:29 UTC (permalink / raw)
To: help-gnu-emacs
jpw@pobox.com (John Paul Wallington) writes:
> metaperl.com wrote:
>
>> (defvar *asciidoc-indent-level*
>
> Sticking asterisks around special variable names is a Common Lisp
> affliction that isn't done in Emacs Lisp.
From the emacs lisp reference ....
* In some other systems there is a convention of choosing variable
names that begin and end with `*'. We don't use that convention
in Emacs Lisp, so please don't use it in your programs. (Emacs
uses such names only for special-purpose buffers.) The users will
find Emacs more coherent if all libraries use the same conventions.
and
* Since all global variables share the same name space, and all
functions share another name space, you should choose a short word
to distinguish your program from other Lisp programs(1). Then
take care to begin the names of all global variables, constants,
and functions in your program with the chosen prefix. This helps
avoid name conflicts.
regards,
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-12-02 1:29 ` Tim X
@ 2007-12-02 10:44 ` Sebastian Tennant
2007-12-12 4:57 ` Kevin Rodgers
[not found] ` <mailman.4909.1197435470.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 10+ messages in thread
From: Sebastian Tennant @ 2007-12-02 10:44 UTC (permalink / raw)
To: help-gnu-emacs
Quoth Tim X <timx@nospam.dev.null>:
> jpw@pobox.com (John Paul Wallington) writes:
>
>> metaperl.com wrote:
>>
>>> (defvar *asciidoc-indent-level*
>>
>> Sticking asterisks around special variable names is a Common Lisp
>> affliction that isn't done in Emacs Lisp.
>
> From the emacs lisp reference ....
>
> * In some other systems there is a convention of choosing variable
> names that begin and end with `*'. We don't use that convention
> in Emacs Lisp, so please don't use it in your programs. (Emacs
> uses such names only for special-purpose buffers.)
Can anyone expand on this? When exactly should buffer names include or
not include asteri?
Sebastian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: code critique requested
2007-12-02 10:44 ` Sebastian Tennant
@ 2007-12-12 4:57 ` Kevin Rodgers
[not found] ` <mailman.4909.1197435470.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 10+ messages in thread
From: Kevin Rodgers @ 2007-12-12 4:57 UTC (permalink / raw)
To: help-gnu-emacs
Sebastian Tennant wrote:
> Quoth Tim X <timx@nospam.dev.null>:
>> jpw@pobox.com (John Paul Wallington) writes:
>>
>>> metaperl.com wrote:
>>>
>>>> (defvar *asciidoc-indent-level*
>>> Sticking asterisks around special variable names is a Common Lisp
>>> affliction that isn't done in Emacs Lisp.
>> From the emacs lisp reference ....
>>
>> * In some other systems there is a convention of choosing variable
>> names that begin and end with `*'. We don't use that convention
>> in Emacs Lisp, so please don't use it in your programs. (Emacs
>> uses such names only for special-purpose buffers.)
>
> Can anyone expand on this? When exactly should buffer names include or
> not include asteri?
I don't know about "exactly", but I think the convention is buffers that
are not visiting files. (Not that buffer names have anything to do with
variable names.)
P.S. http://en.wiktionary.org/wiki/asteri
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.4909.1197435470.18990.help-gnu-emacs@gnu.org>]
* Re: code critique requested
[not found] ` <mailman.4909.1197435470.18990.help-gnu-emacs@gnu.org>
@ 2007-12-12 11:43 ` Tim X
0 siblings, 0 replies; 10+ messages in thread
From: Tim X @ 2007-12-12 11:43 UTC (permalink / raw)
To: help-gnu-emacs
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> Sebastian Tennant wrote:
>> Quoth Tim X <timx@nospam.dev.null>:
>>> jpw@pobox.com (John Paul Wallington) writes:
>>>
>>>> metaperl.com wrote:
>>>>
>>>>> (defvar *asciidoc-indent-level*
>>>> Sticking asterisks around special variable names is a Common Lisp
>>>> affliction that isn't done in Emacs Lisp.
>>> From the emacs lisp reference ....
>>>
>>> * In some other systems there is a convention of choosing variable
>>> names that begin and end with `*'. We don't use that convention
>>> in Emacs Lisp, so please don't use it in your programs. (Emacs
>>> uses such names only for special-purpose buffers.)
>>
>> Can anyone expand on this? When exactly should buffer names include or
>> not include asteri?
>
> I don't know about "exactly", but I think the convention is buffers that
> are not visiting files. (Not that buffer names have anything to do with
> variable names.)
>
That is my understanding as well. In addition, there is also the practice
of putting a space at the start of the buffer name to hide it from the
normal buffer listing (i.e. for temporary/working buffers the user normally
won't be interested in seeing etc).
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-12-12 11:43 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-30 16:10 code critique requested metaperl.com
2007-11-30 16:44 ` Lennart Borgman (gmail)
[not found] ` <mailman.4360.1196441057.18990.help-gnu-emacs@gnu.org>
2007-11-30 18:25 ` metaperl.com
2007-11-30 19:09 ` Lennart Borgman (gmail)
2007-11-30 19:36 ` Joel J. Adamson
2007-12-01 16:27 ` John Paul Wallington
2007-12-02 1:29 ` Tim X
2007-12-02 10:44 ` Sebastian Tennant
2007-12-12 4:57 ` Kevin Rodgers
[not found] ` <mailman.4909.1197435470.18990.help-gnu-emacs@gnu.org>
2007-12-12 11:43 ` Tim X
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.