coldnew / pangu-spacing

emacs minor-mode to add space between Chinese/Japanese/Korean and English characters.
147 stars 18 forks source link

Do not write real space in special region in org-mode #37

Closed yangsheng6810 closed 5 years ago

yangsheng6810 commented 5 years ago

Start the framework for major-mode fixer as suggested in #11 .

coldnew commented 5 years ago

@yangsheng6810 I think there's some promblem in this PR, is this work on your machine ?

$ make test
emacs  -batch -q -no-site-file -L . -L . -l test/pangu-spacing-test.el -f ert-run-tests-batch-and-exit
Source file ‘/home/coldnew/ramdisk/c/pangu-spacing/pangu-spacing.el’ newer than byte-compiled file
Running 4 tests (2019-08-23 12:02:54+0800, selector ‘t’)
   passed  1/4  pangu-spacing-test/japanese (0.000245 sec)
   passed  2/4  pangu-spacing-test/modify (0.000196 sec)
1
2
3
4
Test pangu-spacing-test/org-mode-special-region backtrace:
  signal(ert-test-failed (((should (string-equal (buffer-string) "* En
  ert-fail(((should (string-equal (buffer-string) "* English 中文 Englis
  (if (unwind-protect (setq value-12 (apply fn-10 args-11)) (setq form
  (let (form-description-14) (if (unwind-protect (setq value-12 (apply
  (let ((value-12 'ert-form-evaluation-aborted-13)) (let (form-descrip
  (let* ((fn-10 #'string-equal) (args-11 (condition-case err (let ((si
  (progn (insert "* English中文English [[https://github.com/][link中文li..
  (unwind-protect (progn (insert "* English中文English [[https://github.
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-b
  (lambda nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (sa
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name pangu-spacing-test/org-mode-special-r
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test 
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("-L" "." "-L" "." "-l" "test/pangu-spacing-test.el" 
  command-line()
  normal-top-level()
Test pangu-spacing-test/org-mode-special-region condition:
    (ert-test-failed
     ((should
       (string-equal
        (buffer-string)
        "* English 中文 English [[https://github.com/][link中文link]]
   CLOSED: [2018-10-14日21:42]
   - State \"DONE\"       from \"TODO\"       [2018-10-14日21:42]
   [2018-09-17一]
   English 中文 English
* ~English中文English~
   <2018-09-17一>
   =/home/me/English中文English.conf=
   #+BEGIN_SRC conf :tangle English中文English.conf
     English中文English
   #+END_SRC"))
      :form
      (string-equal
       #("* English 中文 English [[https://github.com/][link 中文 link]]
   CLOSED: [2018-10-14 日 21:42]
   - State \"DONE\"       from \"TODO\"       [2018-10-14 日 21:42]
   [2018-09-17 一]
   English 中文 English
* ~English 中文 English~
   <2018-09-17 一>
   =/home/me/English 中文 English.conf=
   #+BEGIN_SRC conf :tangle English 中文 English.conf
     English 中文 English
   #+END_SRC" 0 8
    (fontified nil)
    14 47
    (fontified nil)
    53 80
    (fontified nil)
    85 143
    (fontified nil)
    148 167
    (fontified nil)
    170 181
    (fontified nil)
    187 203
    (fontified nil)
    209 230
    (fontified nil)
    233 254
    (fontified nil)
    260 307
    (fontified nil)
    313 336
    (fontified nil)
    342 361
    (fontified nil))
       "* English 中文 English [[https://github.com/][link中文link]]
   CLOSED: [2018-10-14日21:42]
   - State \"DONE\"       from \"TODO\"       [2018-10-14日21:42]
   [2018-09-17一]
   English 中文 English
* ~English中文English~
   <2018-09-17一>
   =/home/me/English中文English.conf=
   #+BEGIN_SRC conf :tangle English中文English.conf
     English中文English
   #+END_SRC")
      :value nil))
   FAILED  3/4  pangu-spacing-test/org-mode-special-region (0.700983 sec)
   passed  4/4  pangu-spacing-test/show (0.000187 sec)

Ran 4 tests, 3 results as expected, 1 unexpected (2019-08-23 12:02:55+0800, 0.943362 sec)

1 unexpected results:
   FAILED  pangu-spacing-test/org-mode-special-region

make: *** [Makefile:21: test] Error 1
coldnew commented 5 years ago

SInce my emacs version is 27.0.50, not sure if it's my emacs problem or not.

yangsheng6810 commented 5 years ago

It works on my machine, with emacs 26.2, org-mode both 9.1.9 in emacs, and 9.2.5 from melpa. Let me see if I can get a copy of emacs 27.

yangsheng6810 commented 5 years ago

I tried emacs-git-snapshot from evm, which provides emacs 27.0.50, and all tests pass. I noticed the following line in your log:

Source file ‘/home/coldnew/ramdisk/c/pangu-spacing/pangu-spacing.el’ newer than byte-compiled file

Could it be the reason?

coldnew commented 5 years ago

oops, yes :(

After I remove *.elc, all test passed. Thank you!