arnested / drupal-mode

Advanced Emacs minor mode for Drupal development
https://melpa.org/#/drupal-mode
GNU General Public License v3.0
32 stars 14 forks source link

wrong type argument in drupal-convert-line-ending #53

Closed dhaley closed 9 years ago

dhaley commented 9 years ago

Backtrace: https://gist.github.com/dhaley/5851985

Hi in the defun, drupal-convert-line-ending, the function /= is sometimes passes a non-numeric value triggering a backtrace.

In my drupal buffer, evaluating (coding-system-eol-type buffer-file-coding-system), returns:

[utf-8-unix utf-8-dos utf-8-mac]

The HELP for coding-system-eol-type says that, "A vector value indicates that a format of end-of-line should be detected automatically. Nth element of the vector is the subsidiary coding system whose eol-type is N."

I think I have a patch for the issue.

arnested commented 9 years ago

Good catch.

I not able to produce a situation where a vector is returned - but this should be fixed nonetheless.

I'm thinking the fix could be a bit simpler if we just change:

(/= (coding-system-eol-type buffer-file-coding-system) 0)

to

(not (equal (coding-system-eol-type buffer-file-coding-system) 0))

If a vector is returned this will offer to change the EOL type.

I can't really figureot the end-of-line should be detected automatically part. Who, how and when should the EOL be detected automatically? And do we know what will be used?

Another thing is we should probably also consult the variable coding-system-for-write if it is set:

(not (equal (coding-system-eol-type (or coding-system-for-write buffer-file-coding-system)) 0))