From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#21072: Brave new mark-defun (and a testing tool) Date: Tue, 25 Apr 2017 16:49:08 -0400 Message-ID: References: <87o9ydrzkr.fsf@mbork.pl> <87k28sdka6.fsf@jane> <87efyze00g.fsf@jane> <87bmu2eoji.fsf@jane> <87wpcpw61w.fsf@jane> <83o9xdghmc.fsf@gnu.org> <87o9wkoald.fsf@jane> <87a881ofsu.fsf@jane> <87k272wh8x.fsf@users.sourceforge.net> <871st4aal7.fsf@jane> <87tw5l7v26.fsf@jane> <877f2hs1nw.fsf@users.sourceforge.net> <87zifa9ce5.fsf@jane> <87shl0pbcg.fsf@users.sourceforge.net> <87shky9ez8.fsf@jane> <8737cyotmt.fsf@users.sourceforge.net> <87wpa8yaol.fsf@jane> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1493153415 32010 195.159.176.226 (25 Apr 2017 20:50:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2017 20:50:15 +0000 (UTC) Cc: 21072@debbugs.gnu.org, Stefan Monnier To: Marcin Borkowski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 25 22:50:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37PV-0008Bo-NC for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Apr 2017 22:50:09 +0200 Original-Received: from localhost ([::1]:51347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d37Pb-0005dh-K8 for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Apr 2017 16:50:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d37PR-0005bm-KC for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:50:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d37PO-0008Fr-Hy for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:50:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d37PO-0008Fi-Dj for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d37PO-0003uk-4J for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Apr 2017 20:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21072 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21072-submit@debbugs.gnu.org id=B21072.149315335614985 (code B ref 21072); Tue, 25 Apr 2017 20:50:02 +0000 Original-Received: (at 21072) by debbugs.gnu.org; 25 Apr 2017 20:49:16 +0000 Original-Received: from localhost ([127.0.0.1]:40158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37Oe-0003tc-I0 for submit@debbugs.gnu.org; Tue, 25 Apr 2017 16:49:16 -0400 Original-Received: from mail-oi0-f48.google.com ([209.85.218.48]:35723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37Od-0003tN-7A for 21072@debbugs.gnu.org; Tue, 25 Apr 2017 16:49:15 -0400 Original-Received: by mail-oi0-f48.google.com with SMTP id j201so186680768oih.2 for <21072@debbugs.gnu.org>; Tue, 25 Apr 2017 13:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=3E2n6Did/Lci778gfbnlA5fWwDKoRIL7JM56Cz3bkqk=; b=RzIpSBqCP+ctAS9Un8nhU+E/grkxqUifJRhHJFkrpwmJqo1iIwm81bssP4U7wSZIDM qg4ndIpY3/VrsGo22Yj6VCeklavpmrco59SYx252KCuFRCX3xDB9xfM9wA0Z8Ue1gSDe aaaxCowuRQGlQ8G9SIDfDALkLOS8ZXZk57s9lpDlSwcw0Ln7XPllPwZ7N+qxlUVtxam+ D8yyNnEEP5bLMOQ4rFyLGXKHX9jCaLKGm4415USU1RN8zCLMeK+dE1HIYFvpgczItgHz Cdpe9aLgcOz4T02rAccE5XQhqiKoNHVUv1vAv8u2AKfASI/FrgrO6ZsLddNo+GpjhQtz Ir3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=3E2n6Did/Lci778gfbnlA5fWwDKoRIL7JM56Cz3bkqk=; b=QQPNtq5cJ8xUlaEIkdwCKKvcyc8KGBLJDwwnmgJS4lQqEdrUCzLm9w4BInTPFIYPAo /a0TSClGIsh6t15TZ+9LQD+elA3mdvbgJ+4J0xnTaNJPwZAuHHruNpAsEH/cadFEHgtW sxRArj8tLQI6dR7HTt4NlbIpnsD5s72Kz/3OP/RSHal4KsaR2S3WcD4+tOu5hEjNHiGq w2WbAcvjsq4cTmbXMBSxbjM4f35iq8vBPx9MMAVl2qLZQXkILgSSDIVQoTOKO4s9jVpk jwoYqW/laegboKhPCsXjUqUDcvF2hZiI1yKjVdNuY5I+naGnHbQ1QqoSvbqLRHrRiDX1 PSYQ== X-Gm-Message-State: AN3rC/57e95n6qwp0spcnGj3axiMTqCrTGmfWbEOjooyWrIiPSkHhZBD uEbncRWHjvdSb+ql6+2GuifVQo81oA== X-Received: by 10.202.56.68 with SMTP id f65mr10965932oia.26.1493153349381; Tue, 25 Apr 2017 13:49:09 -0700 (PDT) Original-Received: by 10.157.25.10 with HTTP; Tue, 25 Apr 2017 13:49:08 -0700 (PDT) In-Reply-To: <87wpa8yaol.fsf@jane> X-Google-Sender-Auth: WDmjQe2s_is8WB-XSsmMLQeIzO4 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131978 Archived-At: On Tue, Apr 25, 2017 at 7:43 AM, Marcin Borkowski wrote: >> >> Hmm, I was testing before now just by evaluating the changed functions >> after startup, I must have messed something up. I think this one might >> be okay. > > Quick tests show that you are right. I'd like to understand the code, > too - that will take me a while. I started commenting the code a bit which made me think of some more strange corner cases, like /* foo */ foo; function () { return 0; } and I ended up with this (defun beginning-of-defun-comments (&optional arg) "Move to the beginning of ARGth defun, including comments." (interactive "^p") (unless arg (setq arg 1)) (beginning-of-defun arg) (let (bobp) (while (let ((ppss (progn (setq bobp (= (forward-line -1) -1)) (syntax-ppss (line-end-position))))) (while (and (nth 4 ppss) ; If eol is in a line-spanning comment, (< (nth 8 ppss) (line-beginning-position))) (goto-char (nth 8 ppss)) ; skip to comment start. (setq ppss (syntax-ppss (line-end-position)))) (and (not bobp) (progn (skip-syntax-backward "-" (line-beginning-position)) (not (bolp))) ; Check for blank line. (progn (parse-partial-sexp (line-beginning-position) (line-end-position) nil t (syntax-ppss (line-beginning-position))) (eolp))))) ; Check for non-comment text. (forward-line (if bobp 0 1))))