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

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

Re: recommended html modes


From: prad
Subject: Re: recommended html modes
Date: Thu, 22 Mar 2012 12:01:20 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

XeCycle <XeCycle@Gmail.com> writes:

> prad <prad@towardsfreedom.com> writes:
>
>> PJ Weisberg <pj@irregularexpressions.net> writes:
>>
>>> (push '("\\.s?html?$" . nxml-mode) auto-mode-alist)
>>>
>> hey thx pj!  never knew about auto-mode-alist!  (i thought you'd have
>> to use hooks or something, but i never explored it.)
>
> A more robust way is to use add-to-list 'auto-mode-alist.
>
ok thx carl!
i did it that way.


>> a quick question about nxml mode.
>>
>> if i want to surround a paragraph with <p></p> is there a mechanism for
>> selecting the paragraph and enclosing it (eg M-ret does this in
>> html-helper-mode). i haven't been able to find something like this in
>> any of the docs on nxml i've come across so far.
>
> Don't think it's provided, but it should be easy to write one.
> It's just about marking the paragraph, insert <p> -> swap point
> and mark -> insert </p>.
>
inspired by your above comment, i gave this a shot - figured i'd better start 
learning elisp. :D

i don't know much about interactive etc, but i found the ref manual and
the gnu tutorial.

here's what i got and it does work (though i don't know if it is a good
way or not):

;; region wrapping with tag functions

(defun tag-enclose (tag)
  "encloses region with inputted tag"
  (interactive "sTag: ")
  (wrap-with-tags))

(defun wrap-with-tags ()
  "builds html tags from tag then wraps region"
  (interactive)
  (let* ((begend (region-parameters))
         (beg (car begend))
         (end (cadr begend))
         (tagbeg (format "<%s>" tag))
         (tagend (format "</%s>" tag)))
    (goto-char end)
    (insert tagend)
    (goto-char beg)
    (insert tagbeg)))

(defun region-parameters ()
  "gets region beg and end"
  (interactive)
  (list (region-beginning) (region-end)))


i didn't do your swap idea because i haven't found that function yet.

however, i realized that i had to put the end tag on first, because as
soon as i do the beg tag, the positions all shift forward and my end
position isn't what it is supposed to be anymore. :D

-- 
in friendship,
prad




reply via email to

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