unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47279: 28.0.50; hideif wrong-type-argument in org src block
@ 2021-03-20 11:10 Zhiwei Chen
  2021-03-21  3:25 ` Zhiwei Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Zhiwei Chen @ 2021-03-20 11:10 UTC (permalink / raw)
  To: 47279

How to reproduce:
    emacs -Q --eval '(progn
(require (quote org))
(require (quote hideif))
(add-hook (quote c-mode-hook) (quote hide-ifdef-mode))
(setq hide-ifdef-initially t)
(setq hide-ifdef-shadow t))'

Then edit an org file that contains a src block for C.

#+begin_src C
  void foo() { }
#+end_src

C-c ' on that src block will echo an error message:

    Initialization fails with: "Wrong type argument: stringp, nil"

Since C-c ' opens a special buffer that hasn't a file related, the
`buffer-file-name' will return `nil'. It's the second parameter of
`string-match' in `hide-ifdef-gets'.

The definition of `hide-ifdef-guts` follows.

(defun hide-ifdef-guts ()
  "Does most of the work of `hide-ifdefs'.
It does not do the work that's pointless to redo on a recursive entry."
  ;; (message "hide-ifdef-guts")
  (save-excursion
    (let* ((case-fold-search t) ; Ignore case for `hide-ifdef-header-regexp'
           (expand-header (and hide-ifdef-expand-reinclusion-protection
                               (string-match hide-ifdef-header-regexp
                                             (buffer-file-name))
                               (zerop hif-recurse-level)))
           (case-fold-search nil)
           min max)
      (goto-char (point-min))
      (setf min (point))
      (cl-loop do
               (setf max (hif-find-any-ifX))
               (hif-add-new-defines min max)
               (if max
                   (hif-possibly-hide expand-header))
               (setf min (point))
               while max))))

-- 
Zhiwei Chen





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

* bug#47279: 28.0.50; hideif wrong-type-argument in org src block
  2021-03-20 11:10 bug#47279: 28.0.50; hideif wrong-type-argument in org src block Zhiwei Chen
@ 2021-03-21  3:25 ` Zhiwei Chen
  2021-03-21  7:09   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Zhiwei Chen @ 2021-03-21  3:25 UTC (permalink / raw)
  To: 47279@debbugs.gnu.org; +Cc: condy0919@gmail.com


[-- Attachment #1.1: Type: text/plain, Size: 42 bytes --]

a trivial patch


--
Zhiwei Chen



[-- Attachment #1.2: Type: text/html, Size: 1040 bytes --]

[-- Attachment #2: 0001-Fix-hide-if-wrong-type-argument-in-org-src-block-bug.patch --]
[-- Type: application/octet-stream, Size: 1297 bytes --]

From b28ba5a8bda62b0effc05a49f6edd42dfc1db9f1 Mon Sep 17 00:00:00 2001
From: Zhiwei Chen <chenzhiwei03@kuaishou.com>
Date: Sun, 21 Mar 2021 11:16:57 +0800
Subject: [PATCH] Fix hide-if wrong-type-argument in org src block bug#47279

---
 lisp/progmodes/hideif.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index 923f85fd4d..bd18f49df8 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -1743,12 +1743,13 @@ hif-add-new-defines
 (defun hide-ifdef-guts ()
   "Does most of the work of `hide-ifdefs'.
 It does not do the work that's pointless to redo on a recursive entry."
-  ;; (message "hide-ifdef-guts")
   (save-excursion
     (let* ((case-fold-search t) ; Ignore case for `hide-ifdef-header-regexp'
+           (buf-name (buffer-file-name))
            (expand-header (and hide-ifdef-expand-reinclusion-protection
+                               buf-name
                                (string-match hide-ifdef-header-regexp
-                                             (buffer-file-name))
+                                             buf-name)
                                (zerop hif-recurse-level)))
            (case-fold-search nil)
            min max)
-- 
2.24.3 (Apple Git-128)


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

* bug#47279: 28.0.50; hideif wrong-type-argument in org src block
  2021-03-21  3:25 ` Zhiwei Chen
@ 2021-03-21  7:09   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-21  7:09 UTC (permalink / raw)
  To: Zhiwei Chen; +Cc: condy0919@gmail.com, 47279@debbugs.gnu.org

Zhiwei Chen <chenzhiwei03@kuaishou.com> writes:

> a trivial patch  

Thanks; applied to Emacs 28 (with some minor changes).

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-03-21  7:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 11:10 bug#47279: 28.0.50; hideif wrong-type-argument in org src block Zhiwei Chen
2021-03-21  3:25 ` Zhiwei Chen
2021-03-21  7:09   ` Lars Ingebrigtsen

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).