popup-el icon indicating copy to clipboard operation
popup-el copied to clipboard

posn-at-point returns unexpected list

Open kostafey opened this issue 9 years ago • 6 comments

In common cases (posn-at-point) returns structure like: (#<window 12 on TAGS<idid>> 90 (0 . 100) 0 nil 90 (0 . 5) nil (0 . 0) (10 . 20))

In rare cases (posn-at-point) returns: (#<frame : 0x1149ad8> nil (0 . 0) 0)

E.g. after ^L char in TAGS buffers.

This leads to error on popup-create call:

Debugger entered--Lisp error: (wrong-type-argument windowp #<frame : /home/kostafey/.emacs.d/elpa/popup-20150116.1223/popup.el 0x1149ad8>)
  window-buffer(#<frame : /home/kostafey/.emacs.d/elpa/popup-20150116.1223/popup.el 0x1149ad8>)
  posn-col-row((#<frame : /home/kostafey/.emacs.d/elpa/popup-20150116.1223/popup.el 0x1149ad8> nil (0 . 0) 0))
  popup-create(640 50 15 :max-width nil :around nil :face popup-menu-face :mouse-face popup-menu-mouse-face :selection-face popup-menu-selection-face :summary-face popup-menu-summary-face :margin-left 1 :margin-right 0 :scroll-bar t :symbol nil :parent nil :parent-offset nil)
  popup-menu*(("popup.el<popup-20150116.1223>" "TAGS<idid>" "*scratch*" "*Messages*" "*Compile-Log*" "*Quail Completions*" "popup.el<popup-el>" "profiles.clj" "keyboard.c" "subr.el.gz" "popup-switcher.el" "speed.clj" "report.html" "wservice.clj" "clojure-conf.el" "cider-interaction.el" "key-bindings.org" "clomacs.el" "core.clj" "plot.sh" "helpers.clj" "form-init916177696597684299.clj" "project.clj" "form-init5549897678859169329.clj" "handler.clj" "launch.txt" "form-init5785223491863655970.clj" "plotting_data1.dat" "org-loaddefs.el<org-plus-contrib-20150223>" "org-loaddefs.el<org-20150223>" "stat.h") :point 640 :height 15 :scroll-bar t :margin-left 1 :margin-right 1 :around nil :isearch t)
  psw-popup-menu(("popup.el<popup-20150116.1223>" "TAGS<idid>" "*scratch*" "*Messages*" "*Compile-Log*" "*Quail Completions*" "popup.el<popup-el>" "profiles.clj" "keyboard.c" "subr.el.gz" "popup-switcher.el" "speed.clj" "report.html" "wservice.clj" "clojure-conf.el" "cider-interaction.el" "key-bindings.org" "clomacs.el" "core.clj" "plot.sh" "helpers.clj" "form-init916177696597684299.clj" "project.clj" "form-init5549897678859169329.clj" "handler.clj" "launch.txt" "form-init5785223491863655970.clj" "plotting_data1.dat" "org-loaddefs.el<org-plus-contrib-20150223>" "org-loaddefs.el<org-20150223>" "stat.h"))
  psw-switcher(:items-list (#<buffer popup.el<popup-20150116.1223>> #<buffer TAGS<idid>> #<buffer TAGS<idid>> #<buffer *scratch*> #<buffer *Messages*> #<buffer *Compile-Log*> #<buffer *Quail Completions*> #<buffer popup.el<popup-el>> #<buffer profiles.clj> #<buffer keyboard.c> #<buffer subr.el.gz> #<buffer popup-switcher.el> #<buffer speed.clj> #<buffer report.html> #<buffer wservice.clj> #<buffer clojure-conf.el> #<buffer cider-interaction.el> #<buffer key-bindings.org> #<buffer clomacs.el> #<buffer core.clj> #<buffer plot.sh> #<buffer helpers.clj> #<buffer form-init916177696597684299.clj> #<buffer project.clj> #<buffer form-init5549897678859169329.clj> #<buffer handler.clj> #<buffer launch.txt> #<buffer form-init5785223491863655970.clj> #<buffer plotting_data1.dat> #<buffer org-loaddefs.el<org-plus-contrib-20150223>> #<buffer org-loaddefs.el<org-20150223>> #<buffer stat.h>) :item-name-getter #[257 "r\211q\210\203\301 \203\302 \204\303 \304P\202\303 )\207" [psw-mark-modified-buffers buffer-modified-p psw-is-temp-buffer buffer-name " *"] 3 "\n\n(fn BUFFER)"] :switcher switch-to-buffer)
  psw-switch-buffer()
  call-interactively(psw-switch-buffer nil nil)
  command-execute(psw-switch-buffer)

The early used (popup-current-physical-column) (see: https://github.com/kenbeese/popup-el/commit/c02ec730101184481d90df143524c88801a5b015#diff-99b97c0478ea73bf04732050d7160dc4L539) don't have such problems.

Is it possible to return previous (popup-current-physical-column) usage or any other solutions to get current point position correctly in all cases?

kostafey avatar Feb 27 '15 09:02 kostafey

Another disadvantage of using posn-at-point is different column positions of menu items. It seems, early used popup-current-physical-column looks better for many reasons.

kostafey avatar Apr 01 '15 14:04 kostafey

I'm also encountering this error a lot of times:

Debugger entered--Lisp error: (wrong-type-argument windowp #<frame [email protected] 0x2d8b1c0>)
  window-buffer(#<frame [email protected] 0x2d8b1c0>)
  posn-col-row((#<frame [email protected] 0x2d8b1c0> nil (0 . 0) 0))
  popup-create(nil 46 15 :min-height nil :max-width nil :around t :margin-left nil :margin-right nil :scroll-bar nil :face popup-tip-face :parent nil :parent-offset nil)
  popup-tip("pgu.UUID composite literal uses unkeyed fields")
  flycheck-pos-tip-error-messages(([cl-struct-flycheck-error #<buffer sort_test.go> go-vet "/home/robert/agflow/projects/web/go-lib/model/quote/sort_test.go" 21 nil "pgu.UUID composite literal uses unkeyed fields" warning nil]))
  flycheck-display-errors(([cl-struct-flycheck-error #<buffer sort_test.go> go-vet "/home/robert/agflow/projects/web/go-lib/model/quote/sort_test.go" 21 nil "pgu.UUID composite literal uses unkeyed fields" warning nil]))
  #[0 "\301 \210\205

robert-zaremba avatar Sep 23 '15 15:09 robert-zaremba

@robert-zaremba Could you tell us how to reproduce your issue ?

syohex avatar Sep 24 '15 08:09 syohex

@robert-zaremba, Im my case you should create popup menu after ^L char in TAGS buffer. Probably, it may be any other buffer with special (non-text) characters.

kostafey avatar Sep 24 '15 10:09 kostafey

Im my case you should create popup menu after ^L char in TAGS buffer.

I cannot reproduce by this way.

output

syohex avatar Sep 25 '15 06:09 syohex

UPD: Is seems, it's hard to reproduce it any time. I'll try to find permanent reproduction steps. The last case here.

UPD2: full repro seps:

  • emacs -Q
  • Assume you have already installed popup-el, clojure-mode, fill-column-indicator packages, eval:
(package-initialize)

(with-eval-after-load "popup-el")
(require 'popup)

(with-eval-after-load "fill-column-indicator")
(with-eval-after-load "clojure-mode")

(require 'fill-column-indicator)
(setq-default fill-column 80)
(setq-default fci-rule-column fill-column)
(setq fci-rule-width 1)
(define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1)))
(global-fci-mode 1)

(global-linum-mode)

(set-face-font 'default "FiraMono-12.5:antialias=subpixel")
  • Split windows C-x 3. Open positions_searcher.clj at the right window, put cursor to (def ^{:dynamic true} and run M-: (popup-tip "qwe") (see below tiny screencast for details).

However, I'm afraid the result depends on your screen resolution and font size.

Reproduction file example: https://github.com/kostafey/clucy/blob/master/src/clucy/positions_searcher.clj

Trace:

Debugger entered--Lisp error: (wrong-type-argument windowp #<frame :  0x1149ad8>)
  window-buffer(#<frame :  0x1149ad8>)
  posn-col-row((#<frame :  0x1149ad8> nil (0 . 0) 0))
  popup-create(nil 3 15 :min-height nil :max-width nil :around t :margin-left nil :margin-right nil :scroll-bar nil :face popup-tip-face :parent nil :parent-offset nil)
  popup-tip("qwe")
  eval((popup-tip "qwe") nil)
  eval-expression((popup-tip "qwe") nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

Picture: optimised

kostafey avatar Jan 11 '16 15:01 kostafey