all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Iterating/Finding all Comment- and String-Regions
Date: Fri, 18 Dec 2009 16:05:13 +0100	[thread overview]
Message-ID: <4B2B9A29.5090403@easy-emacs.de> (raw)
In-Reply-To: <2d31ae05-8ff5-4225-8cc2-57e95e1ebea0@d21g2000yqn.googlegroups.com>

Nordlöw wrote:
> How can I find iterate over all the comment- and string-regions (BEG
> END) in a buffer using the mode-specific syntax?
> 
> /Nordlöw
> 


Hi,

function below works with python-mode and emacs-lisp.

However, you need some files from

https://code.launchpad.net/s-x-emacs-werkstatt/

Sorry for the inconvenience, but don't know a replacement for
`forward-string-atpt' `forward-comment-atpt'

You need
thing-at-point-utils.el
thingatpt-utils-base.el

which require from same location

beg-end.el
sh-beg-end.el
misc-utils.el

Probably these requirements are not crucial for your
function, don't know.

BTW once installed are related functions available, as
string-atpt, which returns string, comment-atpt etc.

HTH

Andreas

;;;;;;;;;;;;;;;;;;;;;;;;

(defun next-comment-or-string ()
  "Jump forward to the end of next comment or string "
  (interactive)
  (lexical-let* ((pos (point))
                 (string-orig pos)
                 (comment-orig pos)
                 (comment-pos pos)
                 (string-pos pos))
    (save-excursion (when (forward-string-atpt) (setq string-pos (point))))
    (save-excursion (when (forward-comment-atpt) (setq comment-pos (point))))
    (cond ((and (< string-orig string-pos)(< comment-orig comment-pos))
           (if (< string-pos comment-pos)
               (goto-char string-pos)
             (goto-char comment-pos)))
          ((< comment-orig comment-pos)
           (goto-char comment-pos))
          ((< string-orig string-pos)
           (goto-char string-pos))
          (t (message "%s" "No further matching!")))))


;;;; Comments welcome... :)









  reply	other threads:[~2009-12-18 15:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-17 12:51 Iterating/Finding all Comment- and String-Regions Nordlöw
2009-12-18 15:05 ` Andreas Röhler [this message]
2009-12-18 16:00 ` Drew Adams
2009-12-18 16:02 ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B2B9A29.5090403@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.