From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: XeCycle Newsgroups: gmane.emacs.help Subject: Re: recommended html modes Date: Fri, 23 Mar 2012 23:35:34 +0800 Message-ID: <87aa37z5x5.fsf@Gmail.com> References: <87r4wmpfmo.fsf@psinom.home> <873992no39.fsf@Gmail.com> <871uolptjx.fsf@psinom.home> <87obrpo479.fsf@psinom.home> <87k42dnqdb.fsf@Gmail.com> <87bonompdr.fsf@psinom.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1332516989 5243 80.91.229.3 (23 Mar 2012 15:36:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 23 Mar 2012 15:36:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 23 16:36:29 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SB6XP-0003Gl-2g for geh-help-gnu-emacs@m.gmane.org; Fri, 23 Mar 2012 16:36:23 +0100 Original-Received: from localhost ([::1]:60860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SB6XL-0001BC-Do for geh-help-gnu-emacs@m.gmane.org; Fri, 23 Mar 2012 11:36:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SB6XC-0001Ac-TB for help-gnu-emacs@gnu.org; Fri, 23 Mar 2012 11:36:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SB6X5-0003eS-Ab for help-gnu-emacs@gnu.org; Fri, 23 Mar 2012 11:36:10 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:58234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SB6X5-0003dv-3O for help-gnu-emacs@gnu.org; Fri, 23 Mar 2012 11:36:03 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SB6Wy-0002u5-Uq for help-gnu-emacs@gnu.org; Fri, 23 Mar 2012 16:35:56 +0100 Original-Received: from 59.78.37.25 ([59.78.37.25]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Mar 2012 16:35:56 +0100 Original-Received: from XeCycle by 59.78.37.25 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Mar 2012 16:35:56 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 94 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 59.78.37.25 User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.94 (gnu/linux) Cancel-Lock: sha1:h4OqyiFYQ6bOiprPlIrl4VrK/MU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84098 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable prad writes: > XeCycle writes: [...] >> A more robust way is to use add-to-list 'auto-mode-alist. >> > ok thx carl! > i did it that way. Never mind. [...] > 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 "" 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. Well, if you're curious, that's already bound to C-x C-x. > 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 The active region is always between the point and (active) mark. When you insert text all marks after the point will be automatically shifted accordingly. So I suggest using the point and mark. Also you can have a look at (save-excursion (save-restriction ...)). =2D-=20 Carl Lei (XeCycle) Department of Physics, Shanghai Jiao Tong University OpenPGP public key: 7795E591 Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJPbJhGAAoJEI1xjsR3leWRszUIAI/Q+heSOEqjrf+ckMtB8Ex5 g6mBLs31EH1Dp07SwBgvM2zSM6IphpZSHTEpxU0T0YCqntjeiiB4QsUkXguu2g5P 8o01MRo+CoZGuD3N3U22Y+W3H1167MfE+26fHiFV8PQCS/nHd7Egrn0wiElWmmvn h65zxpV3zZ/MAPzBtypVSELwCXCB6s7Q/tEiKx7IrYrdy+zk0Rz9EbrwawMFP4pO A6MCEXOQOWtPm8uIfv0Qmd2iAE8EpN0wmuEvsYVFS2eu9S3b1ZMwclQtChO3GIyE 1w1X8tdVIir0eG0RIpbWRI8XawuRAcl67oUp4G5qmBGfI4b6Tuyyfb1xLT6jcYI= =xkk8 -----END PGP SIGNATURE----- --=-=-=--