unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] espresso-mode breaks on JSON input
@ 2009-09-11 23:19 Deniz Dogan
  2009-09-11 23:25 ` Daniel Colascione
  0 siblings, 1 reply; 4+ messages in thread
From: Deniz Dogan @ 2009-09-11 23:19 UTC (permalink / raw)
  To: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

(N.B. I'm not sure if this patch belongs here.)

Using a buffer with the following contents (JSON), espresso-mode would
break telling me it expected a number or marker but got nil whenever I
tried to indent the region. I put together a patch which effectively
indents it correctly and doesn't report an error. It basically checks
that (char-before) is non-nil before comparing it to ?\).

[
   {
     "pk": 2,
  "fields": {
          "url": "http://abc.go.com/",
       "name": "ABC"
    }
      }
]

Attached is the patch. I'm not sure about the format, but I hope it can be used.

-- 
Deniz Dogan

[-- Attachment #2: espresso-fix-json-indent-deniz.patch --]
[-- Type: application/octet-stream, Size: 762 bytes --]

diff -c /home/deniz/sources/espresso/espresso.el /home/deniz/.emacs.d/espresso.el
--- /home/deniz/sources/espresso/espresso.el	2009-09-12 01:08:12.000000000 +0200
+++ /home/deniz/.emacs.d/espresso.el	2009-09-12 01:09:13.000000000 +0200
@@ -1809,7 +1809,9 @@
              (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
                  (progn
                    (skip-syntax-backward " ")
-                   (when (= (char-before) ?\)) (backward-list))
+                   (when (and (char-before)
+                              (= (char-before) ?\)))
+                     (backward-list))
                    (back-to-indentation)
                    (cond (same-indent-p
                           (current-column))

Diff finished.  Sat Sep 12 01:09:22 2009

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] espresso-mode breaks on JSON input
  2009-09-11 23:19 [PATCH] espresso-mode breaks on JSON input Deniz Dogan
@ 2009-09-11 23:25 ` Daniel Colascione
  2009-09-12  0:00   ` Chong Yidong
  2009-09-12  4:18   ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Colascione @ 2009-09-11 23:25 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Good catch! Thanks.

On Sep 11, 2009, at 7:19 PM, Deniz Dogan wrote:
> Attached is the patch. I'm not sure about the format, but I hope it  
> can be used.

Just FYI, patch(1) can cope with emails that include a patch at the  
end. It's usually better to include a patch inline than to attach it.  
Doing it that way makes patches easier to discuss.

This patch does the same thing yours does, but more concisely.

Index: js.el
===================================================================
- --- js.el	(revision 213)
+++ js.el	(working copy)
@@ -1808,7 +1808,7 @@
               (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
                   (progn
                     (skip-syntax-backward " ")
- -                   (when (= (char-before) ?\)) (backward-list))
+                   (when (eq (char-before) ?\)) (backward-list))
                     (back-to-indentation)
                     (cond (same-indent-p
                            (current-column))

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAkqq3H8ACgkQ17c2LVA10VualQCg43C6Egs9ie9P7CE5uVbdxG1q
2WIAoIWS3JqwJ4hes24+3jcq8r0C13M1
=+s+8
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] espresso-mode breaks on JSON input
  2009-09-11 23:25 ` Daniel Colascione
@ 2009-09-12  0:00   ` Chong Yidong
  2009-09-12  4:18   ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2009-09-12  0:00 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Emacs-Devel devel, Deniz Dogan

Daniel Colascione <dan.colascione@gmail.com> writes:

> Good catch! Thanks.

Checked into trunk.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] espresso-mode breaks on JSON input
  2009-09-11 23:25 ` Daniel Colascione
  2009-09-12  0:00   ` Chong Yidong
@ 2009-09-12  4:18   ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2009-09-12  4:18 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Emacs-Devel devel, Deniz Dogan

> Just FYI, patch(1) can cope with emails that include a patch at the
> end. It's usually better to include a patch inline than to attach it.
> Doing it that way makes patches easier to discuss.

Ironically your patch got mangled along the way ;-)


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-12  4:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-11 23:19 [PATCH] espresso-mode breaks on JSON input Deniz Dogan
2009-09-11 23:25 ` Daniel Colascione
2009-09-12  0:00   ` Chong Yidong
2009-09-12  4:18   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).