【已解决】mac下postframe报错的问题

小弟刚转入mac下,发现在mac终端下company会报如下错误: Debugger entered–Lisp error: (wrong-type-argument stringp nil) font-info(nil) (aref (font-info (font-at (if (and (= position (point-max))) (- position 1) position))) 3) (if (= position 1) (default-line-height) (aref (font-info (font-at (if (and (= position (point-max))) (- position 1) position))) 3)) (progn (if (= position 1) (default-line-height) (aref (font-info (font-at (if (and (= position (point-max))) (- position 1) position))) 3))) (if (integerp position) (progn (if (= position 1) (default-line-height) (aref (font-info (font-at (if (and (= position (point-max))) (- position 1) position))) 3)))) (let ((height (if (integerp position) (progn (if (= position 1) (default-line-height) (aref (font-info (font-at (if (and (= position (point-max))) (- position 1) position))) 3)))))) (setq posframe–last-font-height-info (cons position height)) height) (if (eq position (car posframe–last-font-height-info)) (cdr posframe–last-font-height-info) (let ((height (if (integerp position) (progn (if (= position 1) (default-line-height) (aref (font-info (font-at (if (and (= position (point-max))) (- position 1) position))) 3)))))) (setq posframe–last-font-height-info (cons position height)) height)) posframe–get-font-height(8) (let* ((position (or position (point))) (posframe-buffer (get-buffer-create posframe-buffer)) (x-pixel-offset (or x-pixel-offset 0)) (y-pixel-offset (or y-pixel-offset 0)) (min-width (or min-width 1)) (min-height (or min-height 1)) (parent-window (selected-window)) (parent-window-top (window-pixel-top parent-window)) (parent-window-left (window-pixel-left parent-window)) (parent-window-width (window-pixel-width parent-window)) (parent-window-height (window-pixel-height parent-window)) (position-info (posn-at-point position parent-window)) (parent-frame (window-frame parent-window)) (parent-frame-width (frame-pixel-width parent-frame)) (parent-frame-height (frame-pixel-height parent-frame)) (font-width (default-font-width)) (font-height (posframe–get-font-height position)) (mode-line-height (window-mode-line-height)) (minibuffer-height (window-pixel-height (minibuffer-window))) (header-line-height (window-header-line-height parent-window)) (frame-resize-pixelwise t) posframe) (save-current-buffer (set-buffer posframe-buffer) (posframe–mouse-banish parent-frame) (setq posframe (posframe–create-posframe posframe-buffer :font font :parent-frame parent-frame :left-fringe left-fringe :right-fringe right-fringe :internal-border-width internal-border-width :foreground-color foreground-color :background-color background-color :keep-ratio keep-ratio :respect-header-line respect-header-line :respect-mode-line respect-mode-line :face-remap face-remap :override-parameters override-parameters)) (posframe–insert-string string no-properties) (posframe–set-frame-size posframe height min-height width min-width) (posframe–set-frame-position posframe (posframe-run-poshandler (list ':position position ':position-info position-info ':poshandler poshandler ':font-height font-height ':font-width font-width ':posframe posframe ':posframe-width (frame-pixel-width posframe) ':posframe-height (frame-pixel-height posframe) ':posframe-buffer posframe-buffer ':parent-frame parent-frame ':parent-frame-width parent-frame-width ':parent-frame-height parent-frame-height ':parent-window parent-window ':parent-window-top parent-window-top ':parent-window-left parent-window-left ':parent-window-width parent-window-width ':parent-window-height parent-window-height ':mode-line-height mode-line-height ':minibuffer-height minibuffer-height ':header-line-height header-line-height ':x-pixel-offset x-pixel-offset ':y-pixel-offset y-pixel-offset)) parent-frame-width parent-frame-height) (posframe–run-timeout-timer posframe timeout) (posframe–run-refresh-timer posframe refresh height min-height width min-width) nil)) (progn (let ((–cl-keys-- --cl-rest–)) (while --cl-keys-- (cond ((memq (car --cl-keys–) '(:string :position :poshandler :width :height :min-width :min-height :x-pixel-offset :y-pixel-offset :left-fringe :right-fringe :internal-border-width :font :foreground-color :background-color :respect-header-line :respect-mode-line :face-remap :no-properties :keep-ratio :override-parameters :timeout :refresh :allow-other-keys)) (setq --cl-keys-- (cdr (cdr --cl-keys–)))) ((car (cdr (memq ':allow-other-keys --cl-rest–))) (setq --cl-keys-- nil)) (t (error “Keyword argument %s not one of (:string :position :poshandler :width :height :min-width :min-height :x-pixel-offset :y-pixel-offset :left-fringe :right-fringe :internal-border-width :font :foreground-color :background-color :respect-header-line :respect-mode-line :face-remap :no-properties :keep-ratio :override-parameters :timeout :refresh)” (car --cl-keys–)))))) (let* ((position (or position (point))) (posframe-buffer (get-buffer-create posframe-buffer)) (x-pixel-offset (or x-pixel-offset 0)) (y-pixel-offset (or y-pixel-offset 0)) (min-width (or min-width 1)) (min-height (or min-height 1)) (parent-window (selected-window)) (parent-window-top (window-pixel-top parent-window)) (parent-window-left (window-pixel-left parent-window)) (parent-window-width (window-pixel-width parent-window)) (parent-window-height (window-pixel-height parent-window)) (position-info (posn-at-point position parent-window)) (parent-frame (window-frame parent-window)) (parent-frame-width (frame-pixel-width parent-frame)) (parent-frame-height (frame-pixel-height parent-frame)) (font-width (default-font-width)) (font-height (posframe–get-font-height position)) (mode-line-height (window-mode-line-height)) (minibuffer-height (window-pixel-height (minibuffer-window))) (header-line-height (window-header-line-height parent-window)) (frame-resize-pixelwise t) posframe) (save-current-buffer (set-buffer posframe-buffer) (posframe–mouse-banish parent-frame) (setq posframe (posframe–create-posframe posframe-buffer :font font :parent-frame parent-frame :left-fringe left-fringe :right-fringe right-fringe :internal-border-width internal-border-width :foreground-color foreground-color :background-color background-color :keep-ratio keep-ratio :respect-header-line respect-header-line :respect-mode-line respect-mode-line :face-remap face-remap :override-parameters override-parameters)) (posframe–insert-string string no-properties) (posframe–set-frame-size posframe height min-height width min-width) (posframe–set-frame-position posframe (posframe-run-poshandler (list ':position position ':position-info position-info ':poshandler poshandler ':font-height font-height ':font-width font-width ':posframe posframe ':posframe-width (frame-pixel-width posframe) ':posframe-height (frame-pixel-height posframe) ':posframe-buffer posframe-buffer ':parent-frame parent-frame ':parent-frame-width parent-frame-width ':parent-frame-height parent-frame-height ':parent-window parent-window ':parent-window-top parent-window-top ':parent-window-left parent-window-left ':parent-window-width parent-window-width ':parent-window-height parent-window-height ':mode-line-height mode-line-height ':minibuffer-height minibuffer-height ':header-line-height header-line-height ':x-pixel-offset x-pixel-offset ':y-pixel-offset y-pixel-offset)) parent-frame-width parent-frame-height) (posframe–run-timeout-timer posframe timeout) (posframe–run-refresh-timer posframe refresh height min-height width min-width) nil))) (let* ((string (car (cdr (plist-member --cl-rest-- ':string)))) (position (car (cdr (plist-member --cl-rest-- ':position)))) (poshandler (car (cdr (plist-member --cl-rest-- ':poshandler)))) (width (car (cdr (plist-member --cl-rest-- ':width)))) (height (car (cdr (plist-member --cl-rest-- ':height)))) (min-width (car (cdr (plist-member --cl-rest-- ':min-width)))) (min-height (car (cdr (plist-member --cl-rest-- ':min-height)))) (x-pixel-offset (car (cdr (plist-member --cl-rest-- ':x-pixel-offset)))) (y-pixel-offset (car (cdr (plist-member --cl-rest-- ':y-pixel-offset)))) (left-fringe (car (cdr (plist-member --cl-rest-- ':left-fringe)))) (right-fringe (car (cdr (plist-member --cl-rest-- ':right-fringe)))) (internal-border-width (car (cdr (plist-member --cl-rest-- ':internal-border-width)))) (font (car (cdr (plist-member --cl-rest-- ':font)))) (foreground-color (car (cdr (plist-member --cl-rest-- ':foreground-color)))) (background-color (car (cdr (plist-member --cl-rest-- ':background-color)))) (respect-header-line (car (cdr (plist-member --cl-rest-- ':respect-header-line)))) (respect-mode-line (car (cdr (plist-member --cl-rest-- ':respect-mode-line)))) (face-remap (car (cdr (plist-member --cl-rest-- ':face-remap)))) (no-properties (car (cdr (plist-member --cl-rest-- ':no-properties)))) (keep-ratio (car (cdr (plist-member --cl-rest-- ':keep-ratio)))) (override-parameters (car (cdr (plist-member --cl-rest-- ':override-parameters)))) (timeout (car (cdr (plist-member --cl-rest-- ':timeout)))) (refresh (car (cdr (plist-member --cl-rest-- ':refresh))))) (progn (let ((–cl-keys-- --cl-rest–)) (while --cl-keys-- (cond ((memq (car --cl-keys–) '(:string :position :poshandler :width :height :min-width :min-height :x-pixel-offset :y-pixel-offset :left-fringe :right-fringe :internal-border-width :font :foreground-color :background-color :respect-header-line :respect-mode-line :face-remap :no-properties :keep-ratio :override-parameters :timeout :refresh :allow-other-keys)) (setq --cl-keys-- (cdr (cdr --cl-keys–)))) ((car (cdr (memq ':allow-other-keys --cl-rest–))) (setq --cl-keys-- nil)) (t (error “Keyword argument %s not one of (:string :position :poshandler :width :height :min-width :min-height :x-pixel-offset :y-pixel-offset :left-fringe :right-fringe :internal-border-width :font :foreground-color :background-color :respect-header-line :respect-mode-line :face-remap :no-properties :keep-ratio :override-parameters :timeout :refresh)” (car --cl-keys–)))))) (let* ((position (or position (point))) (posframe-buffer (get-buffer-create posframe-buffer)) (x-pixel-offset (or x-pixel-offset 0)) (y-pixel-offset (or y-pixel-offset 0)) (min-width (or min-width 1)) (min-height (or min-height 1)) (parent-window (selected-window)) (parent-window-top (window-pixel-top parent-window)) (parent-window-left (window-pixel-left parent-window)) (parent-window-width (window-pixel-width parent-window)) (parent-window-height (window-pixel-height parent-window)) (position-info (posn-at-point position parent-window)) (parent-frame (window-frame parent-window)) (parent-frame-width (frame-pixel-width parent-frame)) (parent-frame-height (frame-pixel-height parent-frame)) (font-width (default-font-width)) (font-height (posframe–get-font-height position)) (mode-line-height (window-mode-line-height)) (minibuffer-height (window-pixel-height (minibuffer-window))) (header-line-height (window-header-line-height parent-window)) (frame-resize-pixelwise t) posframe) (save-current-buffer (set-buffer posframe-buffer) (posframe–mouse-banish parent-frame) (setq posframe (posframe–create-posframe posframe-buffer :font font :parent-frame parent-frame :left-fringe left-fringe :right-fringe right-fringe :internal-border-width internal-border-width :foreground-color foreground-color :background-color background-color :keep-ratio keep-ratio :respect-header-line respect-header-line :respect-mode-line respect-mode-line :face-remap face-remap :override-parameters override-parameters)) (posframe–insert-string string no-properties) (posframe–set-frame-size posframe height min-height width min-width) (posframe–set-frame-position posframe (posframe-run-poshandler (list ':position position ‘:position-info position-info ‘:poshandler poshandler ‘:font-height font-height ‘:font-width font-width ‘:posframe posframe ‘:posframe-width (frame-pixel-width posframe) ‘:posframe-height (frame-pixel-height posframe) ‘:posframe-buffer posframe-buffer ‘:parent-frame parent-frame ‘:parent-frame-width parent-frame-width ‘:parent-frame-height parent-frame-height ‘:parent-window parent-window ‘:parent-window-top parent-window-top ‘:parent-window-left parent-window-left ‘:parent-window-width parent-window-width ‘:parent-window-height parent-window-height ‘:mode-line-height mode-line-height ‘:minibuffer-height minibuffer-height ‘:header-line-height header-line-height ‘:x-pixel-offset x-pixel-offset ‘:y-pixel-offset y-pixel-offset)) parent-frame-width parent-frame-height) (posframe–run-timeout-timer posframe timeout) (posframe–run-refresh-timer posframe refresh height min-height width min-width) nil)))) posframe-show(#<buffer company-posframe-buffer> :string #(" json \n json-rpc " 0 1 (face (company-tooltip-selection company-tooltip)) 1 2 (face (company-tooltip-common-selection company-tooltip-selection company-tooltip) struct [“json” “module” "JSON (JavaScript Object Notation) http://json.org is a subset of\nJavaScript syntax (ECMA-262 3rd edition) used as a lightweight data\ninterchange format.\n\n:mod:json exposes an API familiar to users of the standard library\n:mod:marshal and :mod:pickle modules. It is the externally maintained\nversion of the :mod:json library contained in Python 2.6, but maintains\ncompatibility with Python 2.4 and Python 2.5 and (currently) has\nsignificant performance advantages, even without using the optional C\nextension for speedups.\n\nEncoding basic Python object hierarchies::\n\n >>> import json\n >>> json.dumps([‘foo’, {‘bar’: (‘baz’, None, 1.0, 2)}])\n ‘["foo", {"bar": ["baz", null, 1.0, 2]}]’\n >>> print json.dumps("\"foo\bar")\n "\"foo\bar"\n >>> print json.dumps(u’\u1234’)\n "\u1234"\n >>> print json.dumps(’\\’)\n "\\"\n >>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)\n {"a": 0, "b": 0, "c": 0}\n >>> from StringIO import StringIO\n >>> io = StringIO()\n >>> json.dump([‘streaming API’], io)\n >>> io.getvalue()\n ‘["streaming API"]’\n\nCompact encoding::\n\n >>> import json\n >>> json.dumps([1,2,3,{‘4’: 5, ‘6’: 7}], sort_keys=True, separators=(’,’,’:’))\n ‘[1,2,3,{"4":5,"6":7}]’\n\nPretty printing::\n\n >>> import json\n >>> print json.dumps({‘4’: 5, ‘6’: 7}, sort_keys=True,\n … indent=4, separators=(’,’, ‘: ‘))\n {\n "4": 5,\n "6": 7\n }\n\nDecoding JSON::\n\n >>> import json\n >>> obj = [u’foo’, {u’bar’: [u’baz’, None, 1.0, 2]}]\n >>> json.loads(’["foo", {"bar":["baz", null, 1.0, 2]}]’) == obj\n True\n >>> json.loads(’"\\"foo\\bar"’) == u’"foo\x08ar’\n True\n >>> from StringIO import StringIO\n >>> io = StringIO(’["streaming API"]’)\n >>> json.load(io)[0] == ‘streaming API’\n True\n\nSpecializing JSON object decoding::\n\n >>> import json\n >>> def as_complex(dct):\n … if ‘complex’ in dct:\n … return complex(dct[‘real’], dct[‘imag’])\n … return dct\n …\n >>> json.loads(’{"complex": true, "real": 1, "imag": 2}’,\n … object_hook=as_complex)\n (1+2j)\n >>> from decimal import Decimal\n >>> json.loads(‘1.1’, parse_float=Decimal) == Decimal(‘1.1’)\n True\n\nSpecializing JSON object encoding::\n\n >>> import json\n >>> def encode_complex(obj):\n … if isinstance(obj, complex):\n … return [obj.real, obj.imag]\n … raise TypeError(repr(o) + " is not JSON serializable")\n …\n >>> json.dumps(2 + 1j, default=encode_complex)\n ‘[2.0, 1.0]’\n >>> json.JSONEncoder(default=encode_complex).encode(2 + 1j)\n ‘[2.0, 1.0]’\n >>> ‘’.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j))\n ‘[2.0, 1.0]’\n\n\nUsing json.tool from the shell to validate and pretty-print::\n\n echo '{\"json\":\"obj\"}' | python -m json.tool\n {\n \"json\": \"obj\"\n }\n echo ‘{ 1.2:3.4}’ | python -m json.tool\n Expecting property name enclosed in double quotes: line 1 column 3 (char 2)" “/Users/piccolo/workspace/netease/test/tt.py” 1]) 2 5 (face (company-tooltip-common-selection company-tooltip-selection company-tooltip)) 5 6 (face (company-tooltip-selection company-tooltip)) 6 14 (face (company-tooltip-annotation-selection company-tooltip-selection company-tooltip)) 14 15 (face (company-tooltip-selection company-tooltip)) 16 17 (face (company-tooltip)) 17 21 (face (company-tooltip-common company-tooltip) company-backend company-dabbrev) 21 25 (face (company-tooltip) company-backend company-dabbrev) 25 31 (face (company-tooltip))) :position 8 :x-pixel-offset -1 :font nil :min-width 0 :background-color “dim gray”) (let* ((height (min company-tooltip-limit company-candidates-length)) (lines (company–create-lines company-selection height)) (contents (mapconcat (function identity) lines “\n”)) (buffer (get-buffer-create company-posframe-buffer))) (setq contents (copy-sequence contents)) (remove-text-properties 0 (length contents) '(mouse-face nil) contents) (save-current-buffer (set-buffer buffer) (set (make-local-variable 'overriding-local-map) company-posframe-active-map)) (posframe-show buffer :string contents :position (- (point) (length company-prefix)) :x-pixel-offset (* -1 company-tooltip-margin (default-font-width)) :font company-posframe-font :min-width company-tooltip-minimum-width :background-color (face-attribute 'company-tooltip :background))) company-posframe-show() (cond ((eql command 'pre-command) nil) ((eql command 'show) (company-posframe-show)) ((eql command 'hide) (company-posframe-hide)) ((eql command 'update) (company-posframe-show)) ((eql command 'post-command) (company-posframe-show))) company-posframe-frontend(show) (if (company–show-inline-p) (company-posframe-hide) (company-posframe-frontend command)) company-posframe-unless-just-one-frontend(show) apply(company-posframe-unless-just-one-frontend show) company-pseudo-tooltip-unless-just-one-frontend(show) company-call-frontends(show) company–begin-new() company–perform() company-auto-begin() company-idle-begin(# #<window 1 on tt.py> 56 11) apply(company-idle-begin (# #<window 1 on tt.py> 56 11)) timer-event-handler([t 23583 19367 781408 nil company-idle-begin (# #<window 1 on tt.py> 56 11) nil 0]) 在gui下就没有问题;在windows下也没有问题 有哪位大佬知道原因吗

posframe用的是26.1的childframe特性, GUI特供, 终端吃瘪.

没事还是别用terminal.

嗯嗯,刚才已经发现是在terminal不能使用啦。我直接在terminal下关闭这个功能了。我觉得terminal还蛮好用的,开–daemon比较爽

普通的terminal里:

  1. 没有24位真彩, 只能用256色. 导致一些配色看起来特别鲜艳刺眼, 不太舒服.
  2. 某些键位无法区分, C-m === RET, C-i === TAB, C-[ === Esc, Alt-* === ESC *, 个人觉得无法忍受.
  3. 不能看图, 对于我这种用emacs生活的人无法忍受.

当然, 也有硬核终端战士用framebuffer来完成上述任务. But what’s the point?开个vte占内存40m, 开个xorg内存也是40m. 殊途同归也.

除非要上服务器用, 自己用我看不出用terminal的优势.

键位没问题的;mac下用item2就可以把那些序列转换过去了,例如把ctrl-tab转换成esc+[+a (define-key key-translation-map (kbd “M-[ a”) (kbd “”)) ;ctrl+tab terminal是为了–daemon方便,在任何地方快速打开emacs

gui版不是也能用daemon吗

配置里(server-start)
.bashrc/.zshrcalias e="emacsclient -n"就行了。

两种我daemon我都用了,还是更习惯终端的随用随关哦

老哥,谢了,这个我是知道的