Issue542

classification
Title [PATCH] Bad func-menu display in Python mode when there are nested functions
Type patch Module edit-utils
Severity inconvenience Platform N/A
Keywords has patch Nosy List jeberger, mike.kupfer
explanation
process
These controls should only be changed by committers and tracker administrators.
Status new   Reason
Superseder  
Priority normal   Assigned To

Created on 2009-07-08.08:54:58 by jeberger, last changed 2009-07-26.17:42:00 by stephen.

Messages
msg1266 [hidden] ([hidden]) Date: 2009-07-08.08:54:58
When "fume-python-fully-qualified-names" is true and there are nested
functions, like for example:

def foo:
    def bar:
        pass

Then the func-menu displays extra wide empty entries for those functions.

I suggest replacing the function "fume-find-next-python-function-name"
with the following:

(defun fume-find-next-python-function-name (buffer)
  "Search for the next Python function in BUFFER."
  (set-buffer buffer)
  (if (re-search-forward fume-function-name-regexp nil t)
      (save-excursion
        (let* ((retpnt (match-beginning 2))
               (retname (buffer-substring retpnt (match-end 2))))
          (when fume-python-fully-qualified-names
            (goto-char (match-beginning 0))
            (cond ((looking-at "\\s-+def")
                   (cond ((/= (re-search-backward
                              
"^\\(class\\|def\\)\\s-*\\([A-Za-z0-9_]+\\)\\s-*[(:]" nil t) retpnt)
                          (setq retname
                                (concat
                                 (buffer-substring (match-beginning 2)
(match-end 2))
                                 "."
                                 retname)))))))
          (cons retname retpnt)))))

This will qualify the name with the top parent function (i.e. "foo.bar"
with the above example). It only handles one level of nesting, but it
shouldn't break if there are more (i.e. it will display "foo.baz"
instead of "foo.bar.baz" but the display will still be useful).
History
Date User Action Args
2009-07-26 17:42:00stephensetkeyword: + has patch
2009-07-09 17:08:31mike.kupfersetnosy: + mike.kupfer
2009-07-08 08:54:58jebergercreate