texts: How to open image files with an external application in Dired?

texts:
Linux Mint 19, Emacs 26.1
I has different app to show image.Like  Drawing, Image Viewer, XnView.
And from Nemo file manager I success open any images by this app. Nice.
But I want to open image in Dired mode. So in my init.el I has this:
(when (require 'openwith nil 'noerror)
  (setq openwith-associations
        (list
     (list (openwith-make-extension-regexp '("doc" "docx" "rtf")) "word" '(file))
     (list (openwith-make-extension-regexp '("mpg" "mpeg" "mp3" "mp4" "avi" "wmv" "wav" "mov" "mkv")) "vlc" '(file))
     (list (openwith-make-extension-regexp '("pdf")) "FoxitReader" '(file))
     (list (openwith-make-extension-regexp '("bmp" "gif" "jpeg" "jpg" "png" "tif")) "xnview" '(file))
     (list (openwith-make-extension-regexp '("rdp")) "Remote Desctop Connection" '(file))
     (list (openwith-make-extension-regexp '("xls" "xlsx")) "excel" '(file))
         ))
  (openwith-mode 1))

So when I'm in dired mode and press Enter over image file I get the next message and nothing happend:
openwith-file-handler: Opened DEEPSP_little.JPG in external program

I want to open image by external app when I'm in dired mode.


texts: Source file ‘c:/Users/.../AppData/Local/emacs-26.1-x86_64/share/emacs/26.1/lisp/progmodes/python.el’ newer than byte-compiled file

texts:
this message shows up on Emacs startup. what does it mean and how to get rid of it?

Source file ‘c:/Users/jcao/AppData/Local/emacs-26.1-x86_64/share/emacs/26.1/lisp/progmodes/python.el’ newer than byte-compiled file

btw, my setting folder is C:\Users\...\AppData\Roaming\.emacs.d and I recently made some changes there.


texts: How can I get "this->" by inputting "this."?

texts:
I want to input this. and get this-> in c++-mode.

I tried abbrev-mode and yasnippet, but failed.

In abbrev-mode, I defined an abbrev this to get this using . as a trigger key, but soon as I typed this. I got this->..

In yasnippet, I defined a snippet

# -*- mode: snippet -*-
# name: this
# key: this
# binding: .
# condition: (eq 0 (string-match "this" (buffer-substring (- (point) 4) (point))))
# --
this->

but got thisthis-> after input this..

If I remove the this in the last line of the snippet

# -*- mode: snippet -*-
# name: this
# key: this
# binding: .
# condition: (eq 0 (string-match "this" (buffer-substring (- (point) 4) (point))))
# --
->

everything seems fine but why we don't need this here ? Also, under this situation, the expansion broke the completion of company-irony even I've added yas-expand to irony-completion-trigger-commands.

What is the simplest way to achieve this ? Thanks !


texts:
When I start the emacs and try to customize variable org-id-locations-file it can't find it.
But I can describe variable org-id-locations-file. After describing the variable, if I run customize variable again on the same variable, now it finds it.
So my issue is, any variable with prefix org-id- is not found when trying to customize variable until I first describe it.
Customizing org-id group works.
Thinking back to what I have changed, I set org-id-extra-files to nil from a variable.
PS. By describing variable I mean: M-x describe-variable and by customize variable I mean M-x customize-variable.
PS I fixed this problem by adding (require 'org-id). Now I need to see if linking by id works as expected.


texts: Number of lines the cursor is from the top of the screen when using hideshow.el

texts:
It's simple to find the number of lines from the cursor to top of the screen, eg:

(- (line-number-at-pos (point)) (line-number-at-pos (window-start))))

However when the hideshow library is used to hide certain text, this is no longer valid in that my cursor may have an on-screen offset of N lines from the top of the screen, which is a much larger number if the hidden text is not taken into account.

Is there a way to calculate the number of lines the cursor is from the top of the screen that takes hidden text into account?

n.b. This question initially referred to "narrowing", which is why so many of the comments are about that.


texts: remote tramp eshell session changes to localhost

texts:
I start a tramp dired session to a remote host with C-x d /ssh:user@host:/ and then start eshell with M-x eshell.

This places me at the dired path on the remote host, however as soon as I try to cd or get path autocompletion my session then changes to my localhost.

Is this the intended functionality? How can I make eshell remain on the remote host?


texts: Terminfo database in Emacs shell not updated after (text-scale-adjust)

texts:
The following sequence of commands shows that the number of columns in terminfo's database inside an Emacs shell buffer is not updated when the user decreases the size of the font with "C-x C--" (text-scale-adjust).  It takes changing to anoter buffer and back for that to happen.

1. M-x shell                                   ;; Invoke a shell buffer
2. Issue shell command "tput cols"             ;; Query terminfo database for number of columns
3. Output: 168                                 ;; You may get something different depending on your setup
4. Press "C-x C--"                             ;; Decrease the default face height by one step
5. Issue shell command "tput cols" again
6. Output: 168                                 ;; Did not change but should have increased since text face has decreased
7. Press "C-x b RET"                           ;; Change to some other buffer
8. Press "C-x b RET" again                     ;; Change back to original *shell* buffer
9. Issue shell command "tput cols" for the 3rd time
10. Output: 192                                ;; The correct number of columns is finally shown

Thus, terminfo database was not updated when text face decreased, but it took a couple of buffer changes for that to happen.

GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23) of 2017-12-09


texts: Init using org-babel-tangle with Emacs Prelude

texts:
Trying to convert my personal configuration for Emacs Prelude to use an org-based config. Looked around for a couple of days on this site, github and elsewhere but have not found a way to get org-babel-tangle working correctly to prouduce a working my-init.el file in my personal Prelude directory. What I've tried (at the top of the org file):
+BEGIN_SRC emacs-lisp :tangle yes
"Tangles my-init.org and byte compiles ~/.emacs.d/personal"
(interactive)
(when (equal (buffer-name)
            (concat ~/.emacs.d/personal/my-init.org"))

 (org-babel-tangle)

 (byte-recompile-directory (expand-file-name user-emacs-directory) 0)))

(add-hook 'after-save-hook #'my--tangle-byte-compile-org)
(add-hook 'kill-emacs-hook #'my--tangle-byte-compile-org)
+END_SRC
However M-x eval-region on the code block yields the following. "End of file during parsing". The .el file was created from the org file but with the error listed above. So nothing would load.
Near the end of the file I had the following elisp (right above the require my-init for Prelude which were the very last lines):
+BEGIN_SRC emacs-lisp :tangle yes
(defun my/tangle-dotfiles ()
"If the current file is this file, the code blocks are tangled"
(org-babel-tangle nil "~/.emacs.d/personal/my-init.el")
(byte-compile-file "~/.emacs.d/personal/my-init.el"))
(add-hook 'after-save-hook #'my/tangle-dotfiles)
+END_SRC
But here again the .el file was created but the config failed to load. No other warnings. So I removed each of these blocks one by one, ran org-babel-tangle on the org file but now get the following message:
Compiling file /path/to/.emacs.d/personal/my-init.el at Wed Aug 23 00:35:10 2017
my-init.el:207:8:Error: Invalid lambda variable 92
Compiling no file at Wed Aug 23 00:39:31 2017
Any thoughts or suggestions for getting org-babel-tangle to work nicely with Prelude would be greatly appreciated.
Edit: using the default version of Emacs (25.2) on Fedora including the version of org-mode. Prelude is up to date.


texts:
I want to set a key binding for outline-next-visible-heading but I fail to do so.
I believe using hooks is a solution for this so I added this to my .emacs

(defun outline-mode-test-hook()
  (define-key outline-mode-prefix-map "j" 'outline-next-visible-heading))
(add-hook 'outline-mode-hook 'outline-mode-test-hook)

The key binding has no effect.

P.S. Who actually runs outline-mode-hook ? I didn't see any invocation within file outline.el.


texts:
If there a way to read the output of a subprocess line by line, or at least to get it in small batches?

I have a subprocess doing work in the background, and printing a line every time it completes a task. There are many such small tasks, so I would like to show a progress indicator; unfortunately, my filter function receives output in batches of 10 to 20 lines, which makes the progress display much more jittery than it really is.

When I run that same process as a compile process, the output is displayed smoothly; I can't figure the trick that compilation-mode uses to achieve this.


texts: How to get C++ function descriptions using Company?

texts:
Forgive me if this isn't a feature which is easily available through some emacs package. I'm using Emacs for C++ development with Company, RTags, and Irony. When choosing a company completion candidate, I would like a description of what the candidate (presumably function) actually does; either in pos-tip or in a new buffer, it doesn't really matter.

For example, if I were to write:

    std::string my_string;
    my_string.push_back

I would expect a buffer or pos-tip to display a description of what the member function push_back actually does, e.g., the description which can be found at http://www.cplusplus.com/reference/string/string/push_back/. Currently, the best I can get is a description of the argument types that push_back expects.

Thanks for taking the time to help.


texts:
I am planning to (re)organize my ahk code as code blocks into an org file and tangle this file to obtain the source file.
This is my ahk-guivho.org input file, with two code blocks, empty for the sake of this post:
#+TITLE:      AHK config file
+AUTHOR:      Guido Van Hoecke
+EMAIL:       (concat "guivho" at-sign "gmail.com")

#+PROPERTY:  header-args   :tangle ahk-guivho.ahk
#+PROPERTY:  header-args+  :padline yes
#+PROPERTY:  header-args+  :eval never
#+PROPERTY:  header-args+  :eval no
#+PROPERTY:  header-args+  :exports code

* HideWindow - hides the active window
#+BEGIN_SRC ahk
  HideWindow(title="", x=0, y=0) { ;hides the active window
  }

#+END_SRC
* ActivateWindow
#+BEGIN_SRC ahk
  ActivateWindow(title="") {
  }

#+END_SRC

I expect org-babel-tangle to produce a file called ahk-guivho.ahk with two empty subs (HideWindow and ActivateWindow) but it does not.
It simply complains: Tangled 0 code blocks from ahk-guivho.org
I am pretty sure that my org and babel setup is ok: I tangle my .emacs from an org file without any problems.
I do realize that ahk is not among the officially supported languages.
But when I edit a code block from the org file, I get a buffer with ahk-mode as expected.
Do I need to initialize something somewhere to be able to tangle ahk code from an org file?


texts:
I am using an indirect buffer of a pdf from a pdf-tools PDFView buffer. This works except the indirect buffer is in DocView mode, and therefore I can't use any of the pdf-tools features in that buffer.

Is there a way to clone the PDFView buffer into another PDFView buffer?


texts: Is there a good reference org-mode template for output of learning content to markdown (online), as well as TeX (print) formats?

texts:
I'm working on converting a 200 page book (currently in TeX) to org-mode. Ideally I should be able to push the new org-mode variant of content to both markdown (for online learners) as well as to more sophisticated formats for print (read: LaTeX).
Is there a good best practice guide, or template for this?
What are the pitfalls of switching to org-mode as the primary format for content?


texts: How can you configure magit for duet-commit?

texts:
The following code used to work with earlier versions of emacs, adding a ‘d’ option to magit's commit popup for ‘git duet’.

(require 'dash)

(defvar magit-duet--default-commit-popup-actions nil
  "Store the magit-commit-popup here for
     de-initializing. magit-duet-commit")

(defun magit-duet-commit (&optional args)
  "Create a new duet commit"
  (interactive (if current-prefix-arg
                   (list (cons "--amend" (magit-commit-arguments)))
                 (list (magit-commit-arguments))))
  (when (setq args (magit-commit-assert args))
    (magit-run-git-with-editor "duet-commit" args)))

(defun magit-duet-commit-init ()
  "Add duet-commit to magit commit popup.."
  (interactive)
  (when (eq magit-duet--default-commit-popup-actions nil)
    (setq magit-duet--default-commit-popup-actions
          (plist-get magit-commit-popup :actions))
    (plist-put
     magit-commit-popup
     :actions
     (-remove-at 5 (-insert-at 4
                               '(100 "Duet commit" magit-duet-commit)
                               (plist-get magit-commit-popup :actions))))))

(defun magit-duet-commit-deinit ()
  "Remove duet-commit from magit commit popup.."
  (interactive)
  (unless (eq magit-duet--default-commit-popup-actions nil)
    (plist-put magit-commit-popup
               :actions
               magit-duet--default-commit-popup-actions)))

Credit to jasonm23: https://gist.github.com/jasonm23/6326d278d99fe82f252a90d9b9ad61db

This no longer works with more recent versions of emacs.

How might this snippet be fixed for the latest emacs?
Similarly what would be the best solution for git duet’s integration with magit overall?

Update

As per @tarsius suggestion, the following works perfectly:

(require 'dash)
(require 'magit)

(defvar magit-duet--default-commit-popup-actions nil
  "Store the magit-commit-popup here for
 de-initializing. magit-duet-commit")

(defun magit-duet-commit (&optional args)
  "Create a new duet commit"
  (interactive (if current-prefix-arg
                   (list (cons "--amend" (magit-commit-arguments)))
                 (list (magit-commit-arguments))))
  (when (setq args (magit-commit-assert args))
    (magit-run-git-with-editor "duet-commit" args)))

(defun magit-duet-commit-init ()
  "Add duet-commit to magit commit popup.."
  (interactive)
  (when (eq magit-duet--default-commit-popup-actions nil)
    (transient-append-suffix 'magit-commit "c"
      '("d" "Duet commit" magit-duet-commit))))

(add-hook 'magit-mode-hook 'magit-duet-commit-init)


texts: How can I make emacsclient use an existing window in the current frame?

texts:
I'm on MS Windows, if that makes a difference.

My desired behavior:

There is only one frame visible at any time.
Visiting a file should use an existing window in that frame.

(This is the default behavior for Notepad++ as well as most browsers, though with tabs instead of buffers.)

To accomplish this using Emacs' client-server mode, I have this in my .emacs:

(require 'server)
(unless (server-running-p) (server-start))

And I have an Edit with Emacs context menu item that uses a registry key with this value:

"C:\Users\FriendOfFred\emacs-26.2-x86_64\bin\emacsclientw.exe" "%1"

That worked fine yesterday. Today, after a system restart, emacsclientw opens a new frame whenever I open a file from Windows Explorer or the command line, along with a message about the desktop file already being in use.

Last time I had an issue like this, as I recall, it was because the desktop file was too old, and restarting Emacs refreshed it. That doesn't seem to be the issue now.

What are some other possible causes of this issue? How can I figure out what's going on?


texts:
I'm trying to get tramp to use my ProxyCommand from my ~/.ssh/config (pasted below), specifically for AWS SSM. Should I expect this ProxyCommand to work, maybe something is wrong with my environment or how I'm invoking tramp? Or would tramp need changes to its source to support AWS SSM?

I try C-x C-f /ssh:i-8746484eadb75:/var/log and it asks me if I want to create the directory or file y/n - never seems to even try connecting to the remote host or looking at my ~/.ssh/config and ProxyCommand.

Any pointers or direction would be most welcome, TIA!

Host i-* mi-*
     ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
     User ec2-user

I'm using emacs 26.3 (9.0) on osx catalina 10.15.3.


texts:
The dropdown menus in my installation of Emacs 24.3.1 are not working anymore. Pressing F10 or M-x menu-bar-open opens the menu in a text buffer. I really miss the graphical dropdown menu in text mode.

The issue seems related to this, but that thread reports a bug on OS X Emacs while I'm using Ubuntu.

As for my .emacs file: it only had a couple of commands from emacs-for-python

(load-file "/home/erickrf/.emacs.d/emacs-for-python/epy-init.el")
(epy-setup-ipython)

I deleted everything from the file, but to no help. The dropdown doesn't appear.


texts: debugging some elisp -- "end of file during parsing error" in init.el

texts:
After a long debugging of my init.el file, it looks like the first line of the following elisp-code, i.e (custom-set-variablesis provoking an 'End of file during parsing' error) which I absolutely don't understand. If I comment this line, all is fine. I did not even enter this code myself, as it has been automatically added in init.el from the customize menu.

(custom-set-variables
'(global-hl-line-mode t)
'(ido-mode (quote buffer) nil (ido))
'(menu-bar-mode nil)
 (when (display-graphic-p)
 (tool-bar-mode -1)
 (scroll-bar-mode -1))

Here is the complete error message:

  Warning (initialization): An error occurred while loading `/Users/me/.emacs.d/init.el':

  End of file during parsing: /Users/me/.emacs.d/init.el

Any help would be appreciated ! Thanks


texts: Cutting selection with CUA-mode bindings after searching

texts:
I want to cut/copy some code with this method:

setting a mark with C-SPC,
searching with C-s,
then cutting/copying the selection.

Check the following image:

I can copy selected code with M-w or cut (kill) it with S-Del.

But since I am using CUA-mode, I would prefer to use its keybindings.
Copying with C-c works but cutting with C-x fails.
Is it possible to tweak C-x to make it work in this situation?


texts: Docstrings are invalid after upgrading packages

texts:
When I upgrade packages in the M-x list-packages menu, the docstrings and locations of the function definitions are invalid so that describe-function gives an error and find-function does not jump to the correct file.  For example, running M-x describe-function on slime yields a help buffer that shows the following:

slime is an interactive compiled Lisp function.

(slime &optional ARG1 ARG2)

Cannot open doc string file "/home/user/.emacs.d/elpa/slime-20150501.137/slime.elc"

[back]

Running M-x find-function on slime yields the following (I have debug-on-error set to t):

Debugger entered--Lisp error: (error "Can't find library /home/user/.emacs.d/elpa/slime-20150501.137/slime.el")
  signal(error ("Can't find library /home/user/.emacs.d/elpa/slime-20150501.137/slime.el"))
  error("Can't find library %s" "/home/user/.emacs.d/elpa/slime-20150501.137/slime.el")
  find-library-name("/home/user/.emacs.d/elpa/slime-20150501.137/slime.el")
  find-function-search-for-symbol(slime nil "/home/user/.emacs.d/elpa/slime-20150501.137/slime.elc")
  find-function-noselect(slime)
  find-definition-noselect(slime nil)
  find-function-do-it(slime nil switch-to-buffer)
  find-function(slime)
  call-interactively(find-function nil nil)
  command-execute(find-function)

Is there a way to fix this that doesn't require restarting Emacs?


texts: emacs shell: remove all non-printable characters

texts:
When I call gcalcli from the bash shell, I get the output described in the documentation. But when I run M-x shell on emacs (24.3) and call gcalcli from there, I get a lot of ^[ characters. Compare screenshots from the shell and from emacs.

My init.el already contains the following lines, which are supposed to help with this.

(add-hook 'comint-output-filter-functions
          'comint-output-ctrl-m)

I don't really have a problem with calling gcalcli from the shell whenever I need it. I just want to understand why emacs uses non-printing characters here and how to suppress them if I want to.


texts: Where are org-publish-project-alist variables and properties documented?

texts:
I am learning orgmode publishing.
There are some org-publish-project-alist variables and properties I am not finding in the documentation.
Maybe I am looking in the wrong places.
Where else are the following org-publish-project-alist variables and properties documented?
(I tested them in the org-publish-project-alist file listed at the end)

This is used in https://orgmode.org/manual/Simple-example.html#Simple-example:

:table-of-contents nil

A TOC was generated.

This is listed in https://orgmode.org/manual/Publishing-options.html:

:with-toc nil

TOC was not generated.

This is used in https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html:

:publishing-function org-html-publish-to-html

How is it different than org-publish-org-to-html described in https://orgmode.org/manual/Publishing-action.html ?

Why are these two JavaScript functions generated and not called?

function CodeHighlightOn(elem, id)
function CodeHighlightOff(elem, id)

This is used in https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html:

:style "<link rel=\"stylesheet\"
  href=\"../other/mystyle.css\"
  type=\"text/css\"/>"

Stylesheet link was not in the generated html file.  How to link to a style sheet?

This is used in https://orgmode.org/manual/HTML-preamble-and-postamble.html#HTML-preamble-and-postamble

:org-html-postamble nil

Postamble was generated.  How to prevent generating postamble?

Here is the file I used to test org-publish-project-alist:

(require 'ox-publish)    ;C-x C-e to load org-publish
(setq org-publish-project-alist
      '(
("org-source"                         ;org-source files to be transformed into html files
 :base-directory "~/Documents/developer/editors/emacs/publish_html/org/"
 :base-extension "org"
 :publishing-directory "~/Documents/developer/editors/emacs/publish_html/public_html/"
 :recursive t
 :publishing-function org-html-publish-to-html
 :table-of-contents nil               ;nil fail, generated TOC
 :style "<link rel=\"stylesheet\"
      href=\"../other/mystyle.css\"
      type=\"text/css\"/>"            ;style fail, no style link was generated

;properties listed in left column of https://orgmode.org/manual/Publishing-options.html
 :with-toc nil                        ;nil pass, did not generate TOC
 :headline-levels 4
 :section-numbers nil                 ;nil pass, generated headings without sections numbers
 :html-head-include-default-style nil ;nil pass, did not generate 160-lines of commented style
 :org-html-postamble nil              ;nil fail, postamble was generated
 )

("org-static"
 :base-directory "~/Documents/developer/editors/emacs/publish_html/org/"
 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
 :publishing-directory "~/Documents/developer/editors/emacs/publish_html/public_html/"
 :recursive t
 :publishing-function org-publish-attachment
 )

("org" :components ("org-source" "org-static"))
      ))                 ;C-x C-e and repeat after every change to org-publish-project-alist
;to publish: SPC u SPC SPC org-publish-project


texts: org agenda: show todo entries & todo entries scheduled for today

texts:
Is there a way to make agenda show todos that have no timestamp & those that have, but are scheduled for today?
It seems like i can do one or the other, but not both.


texts: Gradually learning the keybindings provided by AUCTeX

texts:
If I do M-x forward-char, Emacs gives a very useful message

You can run the command "forward-char" with C-f.

Considering the fact that Emacs can find all LaTeX keybindings in the file latex.el under LaTeX-math-default provided by AUCTeX,
is it possible that in LaTeX mode (AUCTeX) Emacs recalls me the Keybindings?
For example after typing \sigma Emacs shows a message that

You can insert "\sigma" by `s .

This would be very useful as it permits to gradually learn the keybindings in LaTeX mode.


texts:
I am trying to open a remote file in spacemacs in evil mode on windows using SPC f f. This pops up helm and entering /ssh:myuser@myhost/folder/file.txt produces

Wrong type argument: stringp, nil

In the message area. How do I fix this?

(Note: When used with putty the correct command is /plink:myuser@myhost/folder/file.txt.)


texts: Org agenda should show all todos of the current week (not separated by days)

texts:
Problem
The default agenda-list-view separates the todo items of the current week by days and sort them by time within each day if there are timestamps. Instead, I want to combine all the todo items without any timestamps.
Motivation
The power of weekly plan is well known. The default agenda view agenda-list-view however does not allow one to easily see what has been achieved and what has to be done in the current week, as what a Kanban board would be able to do. There is org-kanban, but it is not as powerful as what org-agenda can offer and cannot pick items from the current week.
Example
Given the following Org file stored as file_name.org
* TODO No Timestamp
* TODO Deadline last Sunday
SCHEDULED: <2020-07-04 Sat> DEADLINE: <2020-07-05 Sun>
* NEXT Scheduled for last Sunday
SCHEDULED: <2020-07-05 Sun>
* DONE Scheduled for this Monday
SCHEDULED: <2020-07-06 Mon>
* TODO Scheduled for this Tuesday
SCHEDULED: <2020-07-07 Tue>
* TODO Scheduled for next Monday
SCHEDULED: <2020-07-13 Mon>

Assuming today is <2020-07-08 Wed> I'd like to have an agenda view that only shows the DONE/NEXT/TODO items from the current week, sorted by todo state:
file_name:   DONE Scheduled for this Monday
file_name:   NEXT Scheduled for last Sunday
file_name:   TODO Scheduled for this Tuesday

Details
Note that only items satisfying one of the two conditions are included in the desired agenda view:

TODO items that are scheduled for previous weeks or for the current week.
DONE items scheduled for current week.

This implies the following items are excluded:

DONE items scheduled for a day before the current week.
Items whose deadlines are before the current week.
Items scheduled for a day after the current week.

What would be the best way to achieve this? I played around with the custom agenda view using tags-todo, but couldn't find a way to pick only the todo items from the current week. The closest command I can find for picking the todo items from the current week is something like tags-todo "SCHEDULED>=\"<-7d>\"SCHEDULED<=\"<+7d>\"" but this is not exactly what I want.


texts:
There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations:

baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it.
bar and baz being only partially related, meaning that their changes should not be in the same commit.
bar is large and baz is small, making it a lot easier to split the hunk rather than select bar
Similar to the last point, say a 20 line commit contains a single line the middle that should not be staged. It'd be easier to split & stage the top and bottom two hunks ignoring the middle one than use the region.
The above can arise sometimes when the diff presentation will separate the before and after of something that's been modified, and have something unhelpful in the middle. e.g.

@@ line
- old_foo
+ random stuff
+ new foo


texts: Wrong encoding in eshell when closing Emacs

texts:
I have a lot of filenames in Russian in my file system. Every time I close Emacs if I had eshell opened, it shows a *temp* buffer with a list of directories. And asks 2 questions:

Select coding system (default utf-8):

I click enter
Selected encoding utf-8 disagrees with latin-2  specified by file contents. Really save (else edit coding cookies and try again)? (y or n)

I click "y", enter

What file cookies is he talking about? Where can I set it to utf-8, so this question is never asked again?

Update

I found the wrong file: ~/.emacs.d/eshell/lastdir. I saved this: "яОяНяОяННяОуВяНЕяОяОяННяОяНОяОяНВяОяНА" instead of normal Russian name. Then it tries to save it again.


texts: org-sort expands all subtrees and drawers

texts:
When I use org-sort (Ctrl-^) all the to be sorted subtrees are expanded including their properties. I kind of loose orientation. I have to collapse them manually again or use overview (Shift-Tab) and expand manually from there.

Is this a standard behavior?
I tried a fresh emacs install on a new machine and this behaves the same. So I asume the anser here is "yes".
Can I change this behavior somehow? The focus on a subtree should not change when sorting or archiving.


texts: Setting class attribute for html table in orgmode export

texts:
I would like to set the class for a table in html export, e.g.:
<table class="table table-striped">

While it seems that setting some attributes for export of tables to HTML are possible:
#+ATTR_HTML: :border 2 :rules all :frame border I could not find any documentation on setting the class. Is  this possible?


texts: Is it possible to use the mouse wheel for company mode?

texts:
I'm using the Cocoa version of Emacs. When company mode presents a list of completions you can use the mouse to select one. It would seem natural to be able to use the mouse wheel to scroll through the selections as well, but it just scrolls the page.

Is it possible to configure the mouse wheel to scroll through company mode completions when the completions are visible?


texts: Highlight current line without changing colours

texts:
I use (global-hl-line-mode 1) in order to highlight the current line.
This changes the text colours of the highlighted line. Is it possible to highlight while keeping the current syntax highlighting colours (so changing only the background)?


texts: I'd like to browse the history of a specific file version by version. Ideally, as I step through history I should compare it with the closest previous version.


texts: #+include in source block not working in org export

texts:
For example, the master file is named test.org with the following content:

#+title: test

* test
#+BEGIN_SRC python :exports results :results output raw
#! /usr/bin/env python
# -*- coding: utf-8 -*-
print('#+include: "hello.org"')
#+END_SRC

hello.org is in the current folder with the following content:

* hello world

run org-export-to-odt in the buffer of test.org doesn't include hello.org.


texts: Can't Install org Through Package Manager

texts:
I'm trying to upgrade org in my setup by following the instructions here but I don't see org listed as an option.  The instructions say to report it as a discrepancy but I'm thinking it's more likely something on my end since I haven't seen it there for a while and figure someone else would have reported by now.

I'm on Windows with Emacs 25.1.1.  I've tried emacs -q then package-refresh-contents and can see the other packages listed at http://elpa.gnu.org/packages/ but not org.


texts:
I am trying to set up a RSS feed using org-feed following this guide and facing some trouble. At the moment, my org-feed-alist variable value is
(setq org-feed-alist
      '(("Teste"
         "https://math.stackexchange.com/feeds/"
         "~/feed.org" "Math StackExchange"
         :title t
         :pubDate t
         :item-full-text t
         :guid-permalink t)
        ("Reddit News"
         "http://www.reddit.com/r/news/.rss/"
         "~/feed.org" "Reddit News Feed")))

and when I run the org-feed-update-all function, the headlines are created for each feed in the correct file but I receive the message "No new entries from 2 feeds" and every headline is empty. I also tried out the function org-feed-show-raw-feed and it seems to be working fine, so I assume the problem is that the feed is not being parsed as it should.
Just in case this somehow comes into play, I'm currently using emacs 28 with spacemacs v0.200.8 on top of it.
Does anyone use org-feed and have a working configuration which I can use as a reference?
Thanks for your attention


texts:
How can I tell emacs init el to tell/warn me if the emacs version behind the latest cutting edge version published on the internet.

I forgot to mention: I'm a mostly up to date MacOS user


texts: Completing read a directory or an element from a list

texts:
I'm making some functions to interact with Mercurial.  Many Mercurial commands take a repository as an argument, and that argument can be specified either by a path to the root of the repository or by a repo name.  These repo names can be configured in the user's .hgrc file, and it is easy to get a list of the names that are defined.

I'd like to make a completing read function that dynamically completes a path to a directory or an item from a list.  I'd like it to work just like ido-read-directory-name, but with the items from a list also offered as options.

I've been digging through the documentation, and also through mini_buffer.el and ido.el.  The only hint I have so far is that I can override the variable read-file-name-function, but it seems like I'd end up reimplementing a lot of functionality for dynamically completing directory names.

Does anyone have any guidance for me?  Or perhaps an example?


texts:
I'm running Emacs 27.1(9.0) on OSX 11.2.2 and have failed at installing and configuring the package s.el from https://github.com/magnars/s.el/ Here's a list of things that I tried:

Copied s.el into ~/.emacs.d/elisp/
Added (add-to-list 'load-path "/Users/username/.emacs.d/lisp") # replace username with actual username
Verified that emacs does not complain when loading. Running M-x s-trim-<TAB> does not show any of the functions in s.el.
From the mini-buffer, loaded the file using M-x load-file and then typing /Users/username/.emacs.d/lisp/s.el - no errors observed here. However, M-x s-trim<TAB> does not display any functions in s.el
Opened up s.el in emacs, selected the first function s-trim-right and evaluated it with C-x C-e. Even though it evaluated without errors, M-x s-trim<TAB> does not list this function.
Repeat steps 1-5 from terminal by launching emacs with emacs --debug-init

I'm totally lost on how to get this working. The github page https://github.com/magnars/s.el/ says that the package can be installed by running M-x package-install s. However, M-x package-install does not list s as a valid package name. I only see a list of packages that have the letter s in their names.


texts: How to get tilde and plus working with the eshell's directory stack

texts:
In zsh, when one creates a directory stack with pushd, one is able to reference directories in the stack using a tilde followed by the numerical index of the respective directory in the stack.  One can also rotate the stack by calling pushd with a plus followed by the same kind of numerical index.
Here is a series of commands which illustrates how this works:
> cd /tmp
> dirs -v
0       /tmp
> pushd /home
> dirs -v
0       /home
1       /tmp
> pushd /var/tmp
> dirs -v
0       /var/tmp
1       /home
2       /tmp
> touch foo
> pushd +2
> dirs -v
0       /tmp
1       /var/tmp
2       /home
> mv ~1/foo .
> ls
foo
> pwd
/tmp

Is there any way to get the same features in eshell?


texts: `use-package` errors with "failed to define function" message when loading a local copy of a package

texts:
I'm trying to modify the package ediprolog, which was installed and working before, with use-package, from ELPA. I copied the file from the elpa folder to a folder called ediprolog.el and used:

(use-package ediprolog
    :load-path "./extern/")

The problem is now I'm getting an error saying

  File mode specification error: (error Autoloading file ~/.emacs.d/extern/ediprolog.el failed to define function ediprolog)

(even with the original code for ediprolog.el). Further, even if I remove the :load-path and try to load the package from ELPA, I still get the same error. Also, even though it fails, it seems to find functions like ediprolog-dwim which has an autoload cookie and is defined in that file, but they don't work.

(I have tried deleting the elpa folder and redownloading all the packages, removing only the ediprolog folder and removing ediprolog from the list of selected packages, but still the same results)

How can I make use-package load the package properly again?

Adding

;;;###autoload
(defun ediprolog ())

in the file makes the error go away, but this doesn't seem like the correct thing to do.


texts: deactivate active region after `eval-region`

texts:
I do the following to activate the region and evaluate it

M-x spc  to begin mark
C-n
C-n
C-n
M-x eval-region

The region is still active (highlighted) after the eval-region is performed.

I would prefer if eval-region evaluated the region and then deactivated the region, leaving the cursor after the code that was just evaluated.

I have this to start:

(defun e-eval-region (START END)
  "Execute region from START to END using `eval-region and unhighlight result."
  (interactive)
  (eval-region START END)
  (keyboard-quit))

How do I properly pass START and END of region to interactive?


texts: Prevent helm from temporarily unsplitting windows

texts:
If I have a frame split vertically with a dedicated buffer in the top window and the lower window selected I would like to be able to invoke a helm command without helm temporarily unsplitting the frame / hiding the upper window.

Desired behavior:

 +----------------------+    +----------------------+
 |  Dedicated window    |    |  Dedicated window    |
 +----------------------+    +----------------------+
 |                      |    |                      |
 |                      |    |  "Selected" window   |
 |  Selected window     |    |                      |
 |                      | => |                      |
 |                      |    +----------------------+
 |                      |    |                      |
 |                      |    |  Helm completions    |
 |                      |    |                      |
 |                      |    |                      |
 |                      |    |                      |
 +----------------------+    +----------------------+


texts: How to add Beamer `\frametitle` to `imenu`?

texts: I know that there is RefTeX with its TOC, and I know how to include \frametitle there (see here). Nevertheless, I would like to see \frametitle also appear in imenu. What would be the minimal way to get to this?


texts: make company-backends work in lisp files

texts:
I have a running Emacs on my gentoo, with doom configuration (with evil mode disabled).
It works great.
One issue i want to solve...

Some company-backends - for example like company-files in Lisp files, do not work.

When I run Emacs and try to enter a path to a load function - nothing happens.
If I do eval-buffer on the file that I have the company-backends settings - it starts to work.
So it seems that that piece of code runs too late.

Here's what i do:
On my .doom.d/config.el file I load my custom el file.
in that file I do

(after! company (setq company-backend '(company-files company-capf)) )

I also tried to add (setq company-backends '(company-files)) to the config.el file.

None of the above worked.


texts: Equivalent of EIEIO's make-instance for cl-lib structs?

texts:
What equivalents exist for EIEIO's make-instance in cl-lib?

(make-instance 'my/class :slot-a "value" :slot-b "value")

I would like to create an instance of an arbitrary struct identified by a supplied symbol without reliance on knowledge of the constructor or requiring some constructor convention (ex: assuming that make-[struct-name] exists).

It isn't essential that the method allow for initialization of the object with supplied values.  It could be equivalent to the make-instance in accepting values for all slots with defined keywords or it could be equivalent to the default struct constructor (make-[struct-name]) and only create, tag, and initialize default values in the prescribed list/vector format.


texts: how to unbind a mode hook without restarting

texts:
I had set up a custom hook for a mode, but I now realize that I want to use the mode without my changes and without my hook. So, I want the mode to behave as if I never set the hook in the first place, and I want to do this without restarting emacs. Is this reasonably doable?

For example, if I was using the following hook:

(add-hook 'my-mode-hook
          (lambda ()
           ;; Do a bunch of stuff...ie:
           (local-set-key (kbd "C-c l")
                          'some-fancy-function)
           )
)

I can achieve my goal by deleting the hook for my-mode from my init.el, restarting emacs, and then using my-mode as a default setup. But can I do this without restarting emacs?


texts: Spacemacs: How do I set a key in anaconda-mode?

texts:
I'm using the python-layer and am trying to set M-r to run replace-string while editing Python files. I've tried all of the options below from inside the function dotspacemacs/user-config. Help?

;; NONE OF THESE WORK!
(define-key evil-insert-state-map (kbd "M-r") 'replace-string)
(define-key evil-insert-state-map "\M-r" 'replace-string)
(spacemacs/set-leader-keys "M-r" 'replace-string)
(spacemacs/set-leader-keys-for-major-mode 'python-mode "M-r" 'replace-string)
(spacemacs/set-leader-keys-for-major-mode 'anaconda-mode "M-r" 'replace-string)
(defun my-python-mode-config ()
  "For use in `mode-hooks'."
  (local-set-key (kbd "M-r") `replace-string)
)
(add-hook 'python-mode-hook 'my-python-mode-config)
(add-hook 'anaconda-mode-hook 'my-python-mode-config)
(global-set-key "\M-r"  'replace-string)


texts: installing spacemacs without disturbing existing emacs

texts:
I have been using emacs for a while, and i recently installed zsh and i wanted to give a try with spacemacs. I want to try spacemacs without disturbing existing emacs.

I followed the instruction as mentioned here.

created a dir ~/spacemacs
git clone https://github.com/syl20bnr/spacemacs.git ~/spacemacs/.emacs.d
HOME=~/spacemacs emacs

I did the first two steps. But im not sure to do the last step HOME=~/spacemacs emacs, because i want things to be as follows. when i give emacs, my default emacs should open, and when i give semacs i want to open spacemacs.

So far, i have modified my .zshrc file in such a way that, when i give the command emacs it fires up emacs, so i have an alias like such alias emacs='emacs -nw'.

And i want to give semacs(alias for spacemacs) open spacemacs, so that i can open emacs any time i wanted to, if im not comfortable with spacemacs. Now what should be the 3rd step as and what should be my alias look like.


texts:
It seems that ^c ^c applies table formatting only when
point is on the formatting line (the one beginning
in #+tblfm:).  Is it possible to have ^c ^c apply formatting
even when point is in the table itself?
Or is one supposed to do something else from within the table?
It's a bit laborious every time to have to place point at the formatting
line before pressing ^c ^c.


texts: Can I make the projectile chosen project sticky and not follow the current buffer

texts:
Is it possible to make projectile only switch projects when calling projectile-switch-project, and not follow the buffers?

When I switch buffers in emacs, projectile will switch project to the project that the current buffer belong to (if any).

I usually work on a project but have files open from other projects as well. I have an org file with my workitems and notes open (which belongs to my org project) and some test scripts (from my scripts project) and then the source of the project I am working on.

This makes opening files using (helm)-projectile-find-file almost meaningless since I usually have to switch to a buffer from that project first, or do (helm)-projectile-switch-project. And then I can (almost) just as well use helm-find-files.

I still want projectile global mode active though so I can always do C-c p f to open a project file.


texts:
So I've decided to try emacs, and I find it really good. However, I'm mostly writing Python, so the indentation is a crucial thing for me. After couple of failures in configuring I've finally reached to the point when I press ENTER, it goes to new line and automatically indents it (with TAB - size 4). Okay. But lets say I've got a function and a loop inside it. If I want emacs to indent a for loop it does it not in a proper way (for me):

int main()
{
    for (int i=0; i<=10; i++)
        {
            printf("lol\n");
        }
}

cuz I want it to be:

int main()
{
    for (int i=0; i<=10; i++)
    {
        printf("lol\n");
    }
}

My .emacs file looks like this:

(load-theme `wombat)
(setq-default standard-indent 4)
(mouse-wheel-mode t)
(setq make-backup-files nil)
(line-number-mode 1)
(setq indent-size 4)
(setq-default tab-width 4)
(setq-default indent-tabs-mode t)
(setq-default indent-line-function 'insert-tab)
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
(require 'package)
(add-to-list 'package-archives
  '("melpa" . "http://melpa.milkbox.net/packages/") t)

Is there a way I can configure this, to make it like I want it to be?


texts: How do I get a TOC sidebar of my current buffer?

texts: I would like to write in markdown mode for example and then have a sidebar that shows me a table of contents of the buffer I am currently in.


texts: Why is the result of evaluating this function not being displayed in minibuffer?

texts:
I wrote an interactive function to get the contents of a line from the current position of point to the last non-blank character on a line.

However, when after evaluating the function with C-x C-e,  going to a buffer with random-text and then typing M-x get-substring-till-end-of-line I would have expected the answer to be printed in the minibuffer.

But nothing prints in the mini-buffer.

Here is the code.

(defun get-substring-till-end-of-line ()
  "Get as a subtring all the characters from the
   current-position of point upto the last
   non-white space character of the current line."
  (interactive)
  (save-excursion
      (let ((start (point)) end)
    (forward-line 1)
    (re-search-backward "[^[:space:]]")
    (setq end (point))
    (buffer-substring-no-properties start end))))


texts: Figures with multiline captions in Org-Mode

texts:
I would like to include figures with long comments in an org-mode file. The problem is that the #+CAPTION directive only recognizes the text on its same line. If you write many sentences in a very long line it becomes cumbersome to work with. Take a look at this example:

#+CAPTION: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
#+NAME: fig01
[[file:./figs/fig01.png]]

Is there any work around to have multi-lines captions?


texts: How to insert a new heading from a collapsed heading?

texts:
Here, two headings are collapsed, but they do have some content represented by org's s...
* Heading 1...
* Heading 2...

How can I insert a heading right below Heading 2, including below all its content? My cursor is at caret when I do M-RET: Heading 2^.... As example:
* Heading 1...
* Heading 2...
* Heading 3...

Right now, it seems the behaviour is kind of buggy, where pressing M-RET on the previous heading's ... will lead move all the content below the heading? Unfortunately this isn't the behaviour that I want..
* Heading 1...
* Heading 2
* ...


texts:
It is from yesterday that emacs behaves in an unexpected way, as I will now explain.
If I open emacs and I open the minibuffer with C-x C-f and the I press M-0 C-k, emacs deletes the line, this is the normal behaviour.
If now I exit from the minibuffer, pressing for instance C-g and the I reenter with C-x C-f and I press again M-0 C-k, this error appears!

Has anybody any idea of what it may be?

For the moment I delete the line using C-a C-k, but I would like to understand why the second time that I try M-0 C-k it gives me an error and not the first, also this behaviour appeared recently (I am installing a lot of packages, it may be that, I do not know).
What about your emacs? How does it behave?


texts: M-x compile --> emacs doesn't automatically open files

texts:
I have recently switched from an older version of emacs to version 24.3.1. And I have run into the following problem: I have a base folder "/base" and a folder with source files "base/src"; my makefile is in "/base".

When I run "M-x compile" in the /base/src folder with the compilation option "-C ../" and get some compilation error such as

src/XXX.f90(578): error #6457: This derived type name has not been declared.   [my_type]

emacs conveniently lets me click on the file name to track down the error. Now, it used to be that I would click on "src/XXX.f90(578):" and emacs would automatically open the corresponding file in "/base/src/XXX.f90".

However, with the new version I get an additional message

Find this error in (default src/XXX.f90): /base/src

Where I apparently need to complete the file path and hit enter for emacs to open the file.

It seems to work as usual, when I first switch to /base and then hit "M-x compile" without the "-C ../" option. So my guess would be that emacs somehow no longer treats the relative paths correctly?

Does someone maybe know how to help emacs along and find the files the way it used to when compile with "-C ../" command in folder '/base/src'?

Thanks a lot in advance for your suggestions.


texts:
I want to programmatically check whether the current buffer is in org mode. I know that major modes should usually define the variable <modename>-mode, i.e., org-mode should be a defined variable.

However, if I execute describe-variable in an org buffer, I don't see any org-mode. Now, I'm not sure whether describe-variable works for buffer-local variables, so I typed (message org-mode) into my org buffer and ran eval-last-sexp. This gives me the error (void-variable org-mode), so I guess that org mode does not define any org-mode variable.

What is the correct way to check whether a buffer is in org mode?


texts:
I want to add advice to an alias to a function in an internal elisp package at work, gating the logic on a variable.

Both the function and the alias is marked autoload.

Conceptually:

;;;###autoload
(defun something-get ()
  ....)

;;;###autoload
(defalias 'something 'something-get)

What I want is:

(defvar enable-something-advice-p nil)

(and enable-something-advice-p
     (defadvice something (before fix-something enable)
       ;;; do stuff
       )

Questions:

How do I make sure the advice takes effect?    Just mark autoload?
How do I make the advice conditional?


texts:
Is it possible with whitespace-mode (or another mode) to only show mix spaces an tabs (in python mode) ?

Only highlight if:

there is space before tab or tab before space
there is space and indent-tabs-mode is t
there is tabs and indent-tabs-mode is nil

obviously I don't want to see any character like >> or . for unmixed spaces or tabs.

Thanks for any helps


texts: I can toggle org-indent-mode with M-x org-indent-mode, however I don't want it on by default. I tried, on my config file, (org-indent-mode -1), but I get a "undefined symbol" error. I also tried using setq instead, despite Emacs' wiki saying to use the function not the variable. I also tried (setq auto-indent-start-org-indent nil) because a website said this was the way, but it also didn't work. I am using Emacs 24.4.1 on Debian.


texts: How to display a help buffer/window full frame size (not full screen)

texts:
I sometimes want to display information in Help buffer style, so I have been using code like this:

(with-help-window (help-buffer)
  (princ "Type q to exit this help buffer.\n\n")
  (princ result))

This works fine, but the help window only uses half of my frame. I normally split my frame horizontally, to give two tall windows. The displayed help buffer uses one of the two windows.

I would rather use the whole frame in some cases, to display more information and to reduce the number of times I need to page down through the displayed information. The problem to solve is how to temporarily use the whole frame for the with-help-window call, and to automatically restore the original buffers/window sizes when I type "q" in the help window.

How can I best achieve this goal?  I think I'm looking for something like this:

(with-FULL-FRAME-help-window (help-buffer)
   ...)

I've looked at winner-mode, bookmarks, saving layouts to registers, the various (and powerful, but complex) (display-buffer ...) methods. Most of them seem slightly off-target to my desired intent because they tend to correct/restore a layout after a full frame display operation. And it seems to me that many of them require me to manually restore my window layout (which I would prefer not to do).

I'm wondering if anyone has heard of a way to solve this simply. I'm hoping for something simple like these possible approaches, where I can override something with a let frame...

(let ((help-window-width-display-option fullwidth))
  (with-help-window (help-buffer)
    ...))

Or this kind of approach, which I don't know how to do yet, and which looks somewhat difficult/tricky for my current skill level.

(let ((save original configuration somehow)
  (delete-other-windows)
  (with-help-window (help-buffer)
     ...)
  ;; somehow, when I type "q" in the help buffer
  ;; - catch that action in code after the buffer is killed
  ;; - and restore the original window configuration
  )

It seems to me the key problem for me to solve is how to automatically restore the original window configuration when I type "q" in the temporary help-mode buffer. Thanks


texts: How do I clear a global variable that also is buffer-local?

texts:
I called add-hook multiple times because I had a few typos in the hook function, and now there are a bunch of broken copies of it in the hook.

I want to do (setq after-save-hook nil), but after doing describe-variable on after-save-hook, I see this:

Original value was nil
Local in buffer driver.z80; global value is
((lambda nil
   (if
       (string=
        (buffer-name)
        "driver.z80")
       (compile "build.bat")))
 (lambda nil
   (if
       (string=
        (buffer-name "driver.z80"))
       (compile "build.bat")))
 (lambda nil
   (if
       (string=\?
        (buffer-name "driver.z80"))
       (compile "build.bat")))
 (lambda nil
   (if
       (string=\?
        (buffer-name "driver.z80")
        (compile "build.bat"))))
 rmail-after-save-hook)

And no matter what I do I can't seem to clear this out. Any suggestions?


texts: (delete-backward-char) needs an argument?

texts:
I have written a function to yank a selected region n times. I get a warning however because of the (delete-backward-char) although it seems to work. Does the (delete-backward-char) need an argument?

(defun yank-n-times ()
  "yanks the region n times"
  (interactive)
  (let ((n (string-to-number (read-string "Yank n times: "))))
    (dotimes (x n) (yank))
    (delete-backward-char)))

the updated function

(defun yank-n-times ()
  "yanks the region n times"
  (interactive)
  (let ((n (read-number "Yank n times: "))
    (txt (car kill-ring-yank-pointer)))
    (dotimes (x n) (yank))
    (when
    (or (string-suffix-p "\s" txt)
        (string-suffix-p "\n" txt)
        (string-suffix-p "\t" txt))
      (delete-char -1))))

(global-set-key (kbd "C-c C-n y") 'yank-n-times)


texts:
I want to copy text from one buffer to another. With point in the source buffer, I want to insert text in the target buffer. In the target, the text should insert at point, a new line be opened, and the point should move to the beginning of the new line. When I later switch to the target buffer, the point should be at the start of the new line.
I'm able to do all that except the last bit; when I eventually switch to the target buffer, the point is still on the first line, rather than on the newline.
Here's a reduced example.  Open two buffers, a *scratch* buffer (target) and something else (source).  When I run the following in the source buffer,
 (with-current-buffer "*scratch*"
          (insert "first")
          (end-of-line)
          (newline-and-indent))

 (with-current-buffer "*scratch*"
          (insert "second")
          (end-of-line)
          (newline-and-indent))

 (with-current-buffer "*scratch*"
          (insert "third")
          (end-of-line)
          (newline-and-indent))

I expect point to be here when I switch to *scratch* (target),
first
second
third
| <-- point

Instead, I get,
|first
second
third

When I execute insert, end-of-line and newline-and-indent with M-:, the behavior is as expected.  Why does it work as expected with eval-expression but not when run programmatically?
Because there is (legitimate) concern of an X-Y problem, here's everything I'm working with. The problem, so far as I can tell, is in the with-current-buffer section, as demonstrated above.  Maybe there's another way to insert text and step?
(defvar my-on-demand-window nil
  "Target on-demand window.

An on-demand window is one which you wish to return to within the
current Emacs session but whose importance doesn't warrant a
permanent binding.")

(defun my-set-on-demand-window ()
  "Set the value of the on-demand window to current window."
  (interactive)
  (setq my-on-demand-window (selected-window))
  (message "Set on-demand window to: %s" my-on-demand-window))

(defun my-send-line-or-region (&optional beg end buff)
  "Send region defined by BEG and END to BUFF.

Use current region if BEG and END not provided.  If no region
provided, send entire line.  Default BUFF is the buffer displayed
in `my-on-demand-window'."
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end) nil)
                 (list nil nil nil)))
  (let* ((beg (or beg (if (use-region-p) (region-beginning)) nil))
         (end (or end (if (use-region-p) (region-end)) nil))
         (substr (or (and beg end (buffer-substring-no-properties beg end))
                     (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
         (buff (or buff (window-buffer my-on-demand-window))))
    (if substr
        (with-current-buffer buff
          (insert substr)
          (end-of-line)
          (newline-and-indent))
      (error "Invalid selection"))))

I am using GNU Emacs 27.1 (build 1, x86_64-w64-mingw32) of 2020-08-21.


texts: Ranger: toggle [i]nspect file to hide previews shows file details all of a sudden

texts:
When I (setq ranger-preview-file nil) to not show the preview by default, the file list looks very clean:

When I [i] to inspect/toggle preview, the file list stays the same + the preview is shown.
But once I close the preview with another hit of [i], I get a ls -l like or dired-like output:

When I refresh with C-R the listing is cleaned up again.
How can I toggle preview and keep the directory listing as small as possible inside ranger?
I'm on macOS, so maybe the (setq dired-use-ls-dired nil) is producing this?
My config to debug this is very bare-bones. FYI, here it is:
(require 'package)
(add-to-list 'load-path "~/.emacs.d/src")

;; Configure MELPA package repo
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(require 'use-package)

;; I don't need the Welcome screen
(setq inhibit-splash-screen t)

(require 'use-package-ensure)
(setq use-package-always-ensure t)

(use-package emacs
  :if (memq window-system '(mac ns))
  :config
  (setq dired-use-ls-dired nil))
(use-package ranger
  :ensure)

(Screenshots taken with doom modeline)


texts: Accessing google drive with tramp in emacs 25

texts:
I'm trying to access my google drive from within emacs. According to this, that's possible with emacs 26. Based on the tramp 2.4.3 manual I think that's because emacs 26 comes with version 2.4.3 of Tramp. True?

If so, does that mean that an alternative route to achive google drive access in emacs 25 is to update from Tramp 2.2.13 to Tramp 2.4.3?

If so, how do I do that? My tramp-version is 2.2.13.25.2. I tried installing tramp 2.4 via elpa, but still tramp-version returns 2.2.13.25.2. When I try C-x C-f ~//gdrive:john.doe@gmail.com:/ I get the error

  Symbol’s function definition is void: tramp-compat-tramp-file-name-slots

This is a different error message than before I melpa-ed tramp; before it was "Unknown method "gdrive".

Note that I have successfully added my google drive to my GNOME desktop.

EDIT tramp-version is now showing 2.4.3.3. Now when I try C-x C-f ~//gdrive:john.doe@gmail.com:/ I get the error

  Symbol’s function definition is void: "(setf
  tramp-file-name-localname)"


texts: How to get the default input value in minibuffer and edit it?

texts:
For example, I am using M-x occur, and want to edit the default regexp (which is shown in the prompt), and then enter your edited regexp.
can we edit the default value ^ *[[:digit:]]\.[[:digit:]]\.[[:digit:]] + to create a new input e.g. deleting + at the end to get ^ *[[:digit:]]\.[[:digit:]]\.[[:digit:]] ?
The problem is how to move the default value into the editable region.

Thanks.


texts:
Is it possible to show the absolute number of the current line, instead of "0", when in relative line number mode?  This is sometimes referred to as "hybrid line number mode".

Like this:

 7
  6          this.oscs[i].oscillator.start();
  5        }
  4
  3        this.bindController();
  2      };
  1
252      factory.stop = function () {  <- current line number shows
  1        console.log('theremin: now in stop 2');
  2        this.leapController.disconnect();
  3        //this.leapController.removeListener('frame', factory.ctrlFrameHandler);
  4        //this.leapController.removeListener('frame', this.ctrlFrameHandler);
  5        this.leapController.removeListener('frame', this.leapController.listeners('frame')[0]);

Here's how you do it in vim.

I am running evil, and activate relative line number mode in my .emacs like so:

(linum-mode)
(linum-relative-global-mode)

I don't see any packages for this, or any customization available for it in the existing packages.  I'm somewhat familiar with elisp, so it might be possible to figure out how to hook the existing code e.g with advice, but I'd rather avoid going that route if possible.

Many Thanks.


texts: How to duplicate text but increment a numeric part of a name?

texts:
Say that I have rect1 one and I'll multiply it 3 times by yanking.
let rect1 = Rectangle {
    width: 10,
    height: 40,
    }

    let rect1 = Rectangle {
    width: 10,
    height: 40,
    }

    let rect1 = Rectangle {
    width: 10,
    height: 40,

How can I obtain rect1, rect2, rect3 etc. instead of just repeating rect1?


texts: Why ivy-immediate-done is not shown in counsel-M-x

texts: I realize that ivy-immediate-done is not shown in counsel-M-x. Since it's an interactive command, I'm assuming counsel-M-x somehow filters it from its result. But a quick search of the function name in its code directory fails to find the relevant logic. I'm wondering what I am missing here. Thx!


texts: Disambiguating org-refile in case of duplicate buffer names?

texts:
I have several project directories with the same structure. As a result, I am often annoyed when I have to refile (C-c C-w) some sections because several buffers have the same names.

For instance, the list of targets Emacs shows me is something like:

workInProgess.org/Tasks
workInProgess.org/Tasks
...

How can I configure Emacs to disambiguate these refile targets name?


texts: How to add a key-chord escape in Evil for input in other languages?

texts:
How do I get key-chords to work with evil and alternate input-methods?

I enabled Korean input by M-x set-input-method and chose korean-hangul, which I found from following the first few instructions from this Emacs Wiki.

I am using evil-mode, which I really enjoy, but my custom "smash escape" function does not work. The function allows me to exit insert state by quickly pressing jk or kj. Here are the functions:

;; Set 'kj' to exit insert mode
(define-key evil-insert-state-map "k" #'cofi/maybe-exit-kj)
(evil-define-command cofi/maybe-exit-kj ()
  :repeat change
  (interactive)
  (let ((modified (buffer-modified-p)))
    (insert "k")
    (let ((evt (read-event (format "Insert %c to exit insert state" ?j)
               nil 0.5)))
      (cond
       ((null evt) (message ""))
       ((and (integerp evt) (char-equal evt ?j))
    (delete-char -1)
    (set-buffer-modified-p modified)
    (push 'escape unread-command-events))
       (t (setq unread-command-events (append unread-command-events
                          (list evt))))))))

(define-key evil-insert-state-map "j" #'cofi/maybe-exit-jk)
(evil-define-command cofi/maybe-exit-jk ()
  :repeat change
  (interactive)
  (let ((modified (buffer-modified-p)))
    (insert "j")
    (let ((evt (read-event (format "Insert %c to exit insert state" ?k)
               nil 0.5)))
      (cond
       ((null evt) (message ""))
       ((and (integerp evt) (char-equal evt ?k))
    (delete-char -1)
    (set-buffer-modified-p modified)
    (push 'escape unread-command-events))
       (t (setq unread-command-events (append unread-command-events
                          (list evt))))))))

My attempt was to substitute j and k with the corresponding Korean characters. Here is my attempt at re-implementing the kj smash escape, where the character ㅏ is bound to k and the character ㅓ is bound to j:

(define-key evil-insert-state-map "ㅏ" #'cofi/maybe-exit-ㅏㅓ)
;; Set 'ㅏㅓ' to exit insert mode
(evil-define-command cofi/maybe-exit-ㅏㅓ ()
  :repeat change
  (interactive)
  (let ((modified (buffer-modified-p)))
    (insert "ㅏ")
    (let ((evt (read-event (format "Insert %c to exit insert state" ?ㅓ)
               nil 0.5)))
      (cond
       ((null evt) (message ""))
       ((and (integerp evt) (char-equal evt ?ㅓ))
    (delete-char -1)
    (set-buffer-modified-p modified)
    (push 'escape unread-command-events))
       (t (setq unread-command-events (append unread-command-events
                          (list evt))))))))

All I did was substitute j and k with ㅓ and ㅏ, respectively. Unfortunately, it does not work. Any suggestions on how to proceed?


texts: How to make mouse-1 behave the same as RET in dired?

texts:
When I click with mouse-1 in dired it will open a new frame with the selected file. When I press return on the same file it will open the file in the same frame. How can I synchronize this behavior? I.e. I want mouse-1 to behave the same as return.

Furthermore I have the following problem. The mouse-1 down event seems to work fine, but the up event seems to be registered as mouse-2:

<down-mouse-1> at that spot runs the command mouse-drag-region, which is an interactive compiled Lisp function
in `mouse.el'.

It is bound to <down-mouse-1>.

(mouse-drag-region START-EVENT)

Set the region to the text that the mouse is dragged over.
Highlight the drag area as you move the mouse.
This must be bound to a button-down mouse event.
In Transient Mark mode, the highlighting remains as long as the mark
remains active.  Otherwise, it remains until the next input event.

If the click is in the echo area, display the `*Messages*' buffer.

----------------- up-event ----------------

<mouse-2> at that spot runs the command dired-mouse-find-file-other-window, which is an interactive compiled
Lisp function in `dired.el'.

It is bound to <mouse-2>.

(dired-mouse-find-file-other-window EVENT)

In Dired, visit the file or directory name you click on.

[back]


texts: use a function to get file in compilation-error-regexp-alist

texts:
I have used compilation-error-regexp-alist a lot so I am familiar with the syntax. However for this particular error I need to use a function to get the file because I need wildcards. Here is the function I want to use:

(defun find-generic-log (file)
  (car (file-expand-wildcards (format "results/log/*.%s.log" file))))

the documentation for compilation-error-regexp-alist says:

Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK
HIGHLIGHT...]).  If REGEXP matches, the FILE'th subexpression
gives the file name, and the LINE'th subexpression gives the line
number.  The COLUMN'th subexpression gives the column number on
that line.

If FILE, LINE or COLUMN are nil or that index didn't match, that
information is not present on the matched line.  In that case the
file name is assumed to be the same as the previous one in the
buffer, line number defaults to 1 and column defaults to
beginning of line's indentation.

FILE can also have the form (FILE FORMAT...), where the FORMATs
(e.g. "%s.c") will be applied in turn to the recognized file
name, until a file of that name is found.  Or FILE can also be a
function that returns (FILENAME) or (RELATIVE-FILENAME . DIRNAME).
In the former case, FILENAME may be relative or absolute.

I am trying to use the section that says Or FILE can also be a
function that returns (FILENAME). However every way I have tried to format the alist has failed. For example I have tried:

'("<regexp>" find-generic-log)

'("<regexp>" 1 find-generic-log)

'("<regexp>" 'find-generic-log)

'("<regexp>" . find-generic-log)

'("<regexp>" (find-generic-log))

'("<regexp>" (1 find-generic-log))

If I just use '("<regexp>" 1) it will match the error, but the file path is not correct.

So my question is, how do I use a function to get the filename as it says I can in the documentation?


texts: Why does inserting a newline break highlighting with syntax-propertize-function?

texts:
I'm trying to write a major-mode that highlights triple-quoted strings. Here's a minimal reproducible example:

(defconst demo-triple-quoted-string-regex
  (rx "\"\"\""
      ;; After the delimiter, we're a sequence of
      ;; non-backslashes or blackslashes paired with something.
      (*? (or (not (any "\\"))
              (seq "\\" anything)))
      "\"\"\""))

(defun demo-stringify-triple-quote ()
  "Put `syntax-table' property on triple-quoted strings."
  (let* ((string-literal (match-string 0))
         (string-start-pos (- (point) (length string-literal)))
         (string-end-pos (point)))
    (unless (nth 4 (syntax-ppss)) ;; not inside comment
      (put-text-property string-start-pos string-end-pos
                         'syntax-table (string-to-syntax "|")))))

(defconst demo-syntax-propertize-function
  (syntax-propertize-rules
   (demo-triple-quoted-string-regex
    (0 (ignore (demo-stringify-triple-quote))))))

(define-derived-mode demo-mode prog-mode "Demo"
  "Major mode showing stack overflow question."
  (set (make-local-variable 'font-lock-defaults) '(()))
  (set (make-local-variable 'syntax-propertize-function)
       demo-syntax-propertize-function))

However, this leads to really bizarre behaviour when modifying the buffer. Here's my buffer contents:

dodgy when we put a newline after babel

"""
a
"
babel

"""

x = 1

M-x demo-mode gives correct highlighting:

but pressing enter suddenly gives this:

What am I doing wrong?


texts:
I have been noticing two rather "strange" text elements in Emacs which occur when I copy text. I am certain they signify something/have a special formatting purpose, but I am unable to find anything on the web. The first one is a blue dash and the second one a purple box. Since images are more illuminating here, I have created a screenshot:

Please forgive me my terrible editing skills.

Does anyone know whether it is possible to find all of these elements (they are recurring) by way of search/replace-string to eliminate them effectively? Otherwiese I cannot include them in LaTeX documents.

Best


texts: Matching Org Headlines against a Property Function?

texts:
How can I use elisp to search for headlines that return true against a predicate function? In particular, I already have an elisp function within-intervalp which checks whether a number num is within the range specified by property :INTERVAL: (at point). So for example if I have

* Parent
** Child1
:PROPERTIES:
:INTERVAL: [2,3]
:END:
*** Subchild1
:PROPERTIES:
:INTERVAL: [2,4]
:END:
** Child2
:PROPERTIES:
:INTERVAL: [5,7]
:END:
** Child3
:PROPERTIES:
:INTERVAL: [7,9]
:END:

and I run (within-intervalp 2.5), I'd like to see Child1 and Subchild1 pop up in a search. Is this possible?


texts: Select to the sentence of line in a shortcut

texts:
C-k and M-k could delete forward to the end of line and sentence respectively.

How could only select to the end in a shortcut?

Usually select a sentence and append it to a file for further reference with the following code:

;; Captrue words
(require 'thingatpt)

(defun my-append-word ()
  (interactive)
  (let ((word (if (not (region-active-p))
                  (word-at-point)
                (buffer-substring (region-beginning) (region-end)))))
    (with-current-buffer (find-file-noselect "~/Documents/OrgMode/ORG/src/build-vocabulary.org")
      (goto-char (point-max))
      (insert word "\n")
      (save-buffer))))


texts: How can I open dired with reversed sorting of name, and with the cursor on the first line?

texts:
I use the following initial code to open one om my frequently used folders:

(global-set-key (kbd "C-6") (lambda()
    (interactive)
    (find-file (format "C:/Users/%s/notes" user-login-name) )))

If I left point at line 16 last time I killed the dired buffer for the folder, dired will open my folder with point at line 16.

How can I always open this folder with point at line 1 (..) ?

How can I alway open this folder with reversed name sorting ?

EDIT (2019-07-17--08-55-47):
my questions were not complete. I need this:

1) keep the two links "." and ".." on the first and second line, as normal

2) then place all my folders below the two first lines

3) then sort all files below the folders, sorted in reverse order

Adding an "r" to (setq dired-listing-switches "-alr") sorts 1) and 2) to the very bottom, not very practical for me.


texts: How do I show the filename instead of the file I drag into an Emacs buffer?

texts: I would like to drag and drop an image file into an emacs buffer and make the filename appear instead of the image. Is this possible?


texts: Possible to modify 'whitespace-display-mappings' at runtime?

texts:
Making changes to whitespace-display-mappings while emacs runs doesn't seem to do anything.

(setq
 whitespace-display-mappings
 '(
   (space-mark 32 [183] [46]) ; middle-dot
   (tab-mark 9 [9654 9] [92 9]) ; arrow
  )
 )

Then later on:

(setq whitespace-display-mappings '())

Is there a way to refresh the display mapping so key bindings can be used to change which whitespace is displayed?


texts:
While the command below returns filenames in the commandline, I somehow can't get the same result using org-babel:

#+BEGIN_SRC python :results output
import os
os.listdir(path='.')
#+END_SRC

#+RESULTS:
None

Altering the command e.g. using scandir nor the :results property (value,raw) helped


texts: Kill buffers - how to make *scratch* and *Messages* last

texts:
Any setting I can use to get back the old behavior where killing a buffer I get to the next buffer for the files I have given on the command line?
I have been using Emacs like this for years

Open many files in emacs buffers: emacs $(find . -name "Makefile")
Start recording macro: C-x (
Do a small safe change to one of the files
Kill buffer: C-x k <ret>
Stop recording: C-x )
Try it out once or twice: C-x e
Run the macro on all the files: C-u C-u C-u C-x e
Exit Emacs: C-x C-c
Redo from 1 until all have the intended changes

I work in Release Engineering and use to call this "working more horizontally vs dev work", changing things like updating copyright headers in many files. Emacs and macros has helped me a lot and is in general more flexible vs using sed/awk/perl one-liners!
Problem is, with more recent Emacs versions the first time I do step 5 Emacs will go to the *scratch* buffer. Fine, I do C-x k <ret> and then hit C-x e again. Only to end up in the *Messages* buffer.
After this Emacs seems to go to buffers for the files I gave on the command line and end with *Buffer List* where I exit Emacs.
This might sound like a small thing, but I do this many times a day and constantly be thrown into *scratch* and *Messages* instead of the intended file buffers is annoying. Especially since I want to hit a few C-u and when entering those buffers my macro will fail and everything stop.


texts: Turn C Electric Indentation off only for specific characters

texts:
Extending Customizing c-mode indentation behavior in emacs-24.4

How can electric indentation be disabled for other specific keys without disabling the entire mode?

Specifically, how can electric indentation be turned off for /* */ comments? Apparently disabling it for * does not do the job.

The following works only under some conditions.

(add-hook 'c-mode-hook
          (lambda ()
            (set-key (kbd "*") 'self-insert-command)))

Similarly, the following works only under some conditions

(add-hook 'c-mode-hook
         (lambda ()
           (setq electric-indent-chars
                       (remq "*" electric-indent-chars))))

(add-hook 'c-mode-hook
         (lambda ()
           (setq electric-indent-chars
                       (remq "*" electric-indent-chars))))

(?* and ?/ also do not work)

"some conditions": comment lines following another commented line keep their non-electric indentation after typing *, but a comment line immediately following a closing brace has its indentation reset upon typing the * in /*


texts: install multiple packages from my .emacs file

texts: I share my .emacs file between machines, which works great but I use a lot of packages and when emacs starts on a new machine with the .emacs it complains about the missing package.  I can ignore it until I install that package, but it's laborious having to manually install packages.  Is there a way to install all the packages needed by my .emacs file?


texts: How to get TRAMP to respect group sticky bit?

texts:
In using TRAMP to create a new file in a remote (Unix) directory, I discovered that TRAMP is not respecting the group sticky bit in that directory.

As is standard on a Unix system, the group sticky bit says that any new file created in that directory shall have the same group ownership as the directory itself.  My own userid is nr, and my default group is also called nr.  Because of the sticky bit, new files created on the remote host are owned by nr but have group ownership ta105.  But new files created using TRAMP have group ownership nr.

How can I modify or configure TRAMP so that it respects the group sticky bit in the remote directory?


texts: How to change Emacs' word movement behaviour?

texts:
I want to do this on forward-word: (| shows the cursor position)
Normal Behaviour:
int main(int argc, char *args[])
{
    int a = 45|;
    printf|("%i", a);
}

What I want to do:
//forward-word first
int main(int argc, char *args[])
{
    int a = 45|;|
    printf("%i", a);
}

//forward-word second
int main(int argc, char *args[])
{
    int a = 45;|
    printf|("%i", a);
}


texts: Cannot get Magit to show the commit signatures in the log

texts:
In order to prove that I had a signature on a commit I needed to use a this command line command:
   $ git log --show-signature -1

I could not get Magit to display the signature
I tried to use the Magit Key (l) and the -S switch.
But could not see the signature details.

Addressing questions to the answer from the magit author
I ran out of space in my comment so I edited my question to reply.
So I validated that each commit was signed using git log --show-signature| cat in my shell in Emacs.  Then I redid the command above and looked at individual rows to see the signature - but even when I hit RET as you say above, the signature still did not show up.  I could also not see any evidence when all of the signatures were applied that any of them were signed.
How do I configure the expanded view of the signature so that the RET key will cause the details of the signature as the --show-signature flag requires?  I most want to be able to drill in with RET and see exactly the text that is needed.  I am concerned that I am missing details in magit that the shell shows properly.
Update 2020-06-29
magit-20200617.2306 is installed in the ~/.emacs.d/elpa/. directory
The signature now shows up in magit as a bright green color on the subject line of the commit message text
What remains is to add the details of the signature when a long form of the log message is used.
@tarsius I am fine with the signature details being omitted in the normal case when just one line is shown.
The bright green color is very useful to show that the commit is signed.


texts: Spacemacs move cursor using word wrap, not line breaks

texts:
I would like to be able to move the cursor around using the visual buffer, but I don't want to add line breaks to the source file. I'm not sure a better way to describe it, so I got some gif examples.
Here is vscode:

Here is emacs:

Both have the same file open and I am moving around the same line of text, vscode treats the wrapped line as multiple while emacs treats it as a single. I would like to make emacs behave like vscode. I have spacemacs installed with the base setup and vim mode.


texts: How to add some space to the left of the line numbers in linum-mode?

texts:
When I enable linum-mode in the scratch buffer (and most other buffers I tried) there is no space to the left of the line numbers. Although when enable linum-mode in the .emacs configuration file, I get space to the left of the line numbers. Here is a picture:

How can I control the format of the line numbers? I'd like at least one space to the left of the numbers (like in the .emacs file) in all files.


texts: Use result of ob-shell block in subsequent ob-shell block

texts:
#+BEGIN_SRC sh
aws ec2 describe-instances
#+END_SRC

#+RESULTS:
i-0154b911d1f4e0871

#+BEGIN_SRC sh
aws ec2 terminate-instances "param1"
#+END_SRC

How can I use the result of the first block as the parameter (param1) of the aws ec2 terminate-instances statement?


texts:
Windows 10 (64 bit), Emacs 25.1, package dired+.

In dired mode files size show in bytes. But I want to show in KB.


texts: How do you change the text cursor height and thickness?

texts:
I would like to change the shape of the cursor to something like the following image:

It's a bit taller and thicker than the default one.  How do I do that?


texts: Ignoring specific remotes when running `magit-log-popup` to log all branches

texts:
I would like to add an option in magit-log-popup to ignore a list of remotes  when using "Log all branches" (l b). What I'm trying to do is something like this git log HEAD --branches --remotes --not --remotes=remote1 --remotes=remote2. All my attempts to add this have failed and I wondered if anybody have a suggestion on how it could be done?

Tried variations of things like this (magit-define-popup-option 'magit-log-popup ?i "Ignore remotes" "--not --remotes=" #'read-from-minibuffer). Though I might expanded it later with a function, but it caused the log come up empty.


texts:
I have the following in my init.el,
(setq-default display-line-numbers 'visual)
(global-display-line-numbers-mode 1)

which should give me relative line numbering. On starting emacs, it does on the startup page, but as soon as I switch to another file, the display-line-numbers variable is overriden to t, which removes relative line numbering. I am confused, as I thought that setting setq-default would ensure that new buffers would default to visual. Or is there something else going on that I am missing?


texts: Beamer PDF export: title, subtile, content show one by one

texts:
Say, in a slide I have

* title
** subtitle
   content

They will appear in the same slide with default beamer export.

What I want to achieve is exporting it to three slides with first page only title, second page title and subtitle, finally third page with all these three elements.

I know this can be achieved within list items.

- <1-> first item
- <2-> second item
- <3-> third item

But how can I achieve this with title and subtitle, and even subsubtitle and content?


texts: completion of a sentence rather than word

texts:
I use emacs-org for my "non-programming" work. I need a completion framework. Present completion framework like completion.el, dabbreav, pabbrev and company provide single word completion.

I need something to complete a sentence like
-- Generalised painless progressive distention of abdomen
-- Generalised painless progressively increasing jaundice.
On typing Generalised , I should get these options.
Is it possible

Regards


texts:
I am starting to build up a .emacs file to be used as a development environment within Docker containers. I get this error when starting emacs-nox in a Docker container.
Error (use-package): Failed to install magit: Package `magit-' is unavailable
Error (use-package): Cannot load magit

Here is the contents of my .emacs:
;; require package
(require 'package)

;; add melpa stable
(add-to-list 'package-archives
        '("melpa-stable" . "https://stable.melpa.org/packages/"))

;; add melpa
(add-to-list 'package-archives
        '("melpa" . "http://melpa.milkbox.net/packages/"))

;; Initialise packages
(package-initialize)

;; get latest package information
(package-refresh-contents)

;; add use package
;; so packages can automatically be installed
;; required for reuse across computer or docker containers
(package-install 'use-package)

;; add magit for git
(use-package magit
  :ensure t
    :pin melpa-stable)


texts:
new user here.

I am wondering- can somebody walk me through how to do the following:

In a given directory I have files that look like this

fluc_sk2_556.png
even_sk2_922.png

I would like, with minimal effort, to move the 3 digits to the front of the filename e.g.

556_fluc_sk2_.png
922_even_sk2_.png

How to do this? Thank you so much!


texts:
We have a new manager at work and he wants us to timesheet. No problem, I have org-mode. Except, he wants time reported like this:

0900-1000 Customer  Project  xMinutes
0900-1000 Customer2 Project2 yMinutes
1000-1100 Customer  Project3 zMinutes

So, in other words, if I clock time on three things in an hour he wants three lines for that hour which show the three sets of minutes that I spent, against the task. Naturally, my Org file has tasks for different customers as subheadings under those customers, so in theory those two columns should be easy.

I'm not very experienced with org hacking and I can't work out how to break the time down this way. So I thought I'd ask someone else to do it for me :)

Hopefully the answer isn't staring  me in the face in the Org manual.

** Greenwich Consultancy
   :LOGBOOK:
   CLOCK: [2016-02-18 Thu 10:40]--[2016-02-18 Thu 11:10] =>  0:30
   CLOCK: [2016-01-13 Wed 14:48]--[2016-01-13 Wed 15:29] =>  0:41
   CLOCK: [2016-01-12 Tue 11:00]--[2016-01-12 Tue 16:53] =>  5:53
   :END:
** PU [2/2]
*** DONE Identify PU Open equella block
    CLOSED: [2015-10-26 Mon 09:09]
    :LOGBOOK:
    CLOCK: [2015-10-09 Fri 14:10]--[2015-10-09 Fri 16:06] =>  1:56
    :END:
*** Update UAT
    :LOGBOOK:
    CLOCK: [2016-02-17 Wed 10:03]--[2016-02-17 Wed 10:16] =>  0:13
    CLOCK: [2015-11-17 Tue 09:12]--[2015-11-17 Tue 09:18] =>  0:06
    CLOCK: [2015-11-16 Mon 14:49]--[2015-11-16 Mon 15:00] =>  0:11
    :END:
*** PSMD Block
    :LOGBOOK:
    CLOCK: [2016-02-26 Fri 16:26]--[2016-02-26 Fri 16:53] =>  0:27
    CLOCK: [2016-02-11 Thu 14:27]--[2016-02-11 Thu 14:47] =>  0:20
    CLOCK: [2016-02-09 Tue 16:17]--[2016-02-09 Tue 16:31] =>  0:14
    CLOCK: [2016-02-09 Tue 14:24]--[2016-02-09 Tue 15:02] =>  0:38
    CLOCK: [2016-02-09 Tue 12:13]--[2016-02-09 Tue 13:01] =>  0:48
    CLOCK: [2016-02-09 Tue 10:15]--[2016-02-09 Tue 10:58] =>  0:43
    CLOCK: [2016-02-05 Fri 14:27]--[2016-02-05 Fri 16:36] =>  2:09
    CLOCK: [2016-02-05 Fri 11:11]--[2016-02-05 Fri 12:02] =>  0:51
    CLOCK: [2016-02-05 Fri 10:36]--[2016-02-05 Fri 10:53] =>  0:17
    CLOCK: [2016-02-03 Wed 09:39]--[2016-02-03 Wed 10:24] =>  0:45
    CLOCK: [2016-02-02 Tue 16:39]--[2016-02-02 Tue 17:00] =>  0:21
    CLOCK: [2016-01-29 Fri 12:27]--[2016-01-29 Fri 12:33] =>  0:06
    :END:
*** Server tidy
**** STARTED Check TII code on UAT
     :LOGBOOK:
     CLOCK: [2016-02-25 Thu 16:59]--[2016-02-26 Fri 09:22] => 16:23
     :END:
**** DONE Update Coursework M26 branch
     CLOSED: [2016-02-25 Thu 16:59]
     - State "DONE"       from "STARTED"    [2016-02-25 Thu 16:59]
     :LOGBOOK:
     CLOCK: [2016-02-25 Thu 16:56]--[2016-02-25 Thu 16:59] =>  0:03
     :END:
*** UAT PSMD Roamers problem
    :LOGBOOK:
    CLOCK: [2016-02-25 Thu 11:19]--[2016-02-25 Thu 11:33] =>  0:14
    :END:
*** Gradebook problem
    :LOGBOOK:
    CLOCK: [2016-02-26 Fri 15:35]--[2016-02-26 Fri 16:26] =>  0:51
    :END:

So for example, the line

CLOCK: [2016-02-05 Fri 11:11]--[2016-02-05 Fri 12:02] =>  0:51

Should produce two output lines (with tabs or comma separators):

1000-1100 PU PSMD Block 49
1100-1200 PU PSMD Block  2


texts: How to detect Windows XP vs Windows 7 in startup file?

texts:
Presently, I'm testing for windows like this in my startup for Emacs v23.1.1:

(if (eq system-type 'windows-nt)
    (load-library "visual-basic-mode"))

However, this is true for both Windows 7 and Windows XP and I do not have visual-basic-mode on my windows XP machine.

Is there a way to add a condition to detect that it is XP and not load the file?  Alternatively, can I pass arguments to load-library so that it is not an error if not found?

Update: I tried adding t as the second argument to load-library and get this error:

byte-code: Wrong number of arguments:
  #[(library) "Á!" [library load] 2 729706
        (list (completing-read "Load library: "
                               (apply-partially (quote locate-file-completion-table)
                                                load-path (get-load-suffixes))))], 2

Update: Trying to use the system version does not eval:

Debugger entered--Lisp error: (void-function pcase)
  (pcase (and (eq system-type ...) (w32-version))
     (\` (5 0 \,_) (quote windows-2k))
     (\` (5 \, ... \,_) (quote windows-xp))
     (\` (6 0 \,_) (quote windows-vista))
     (\` (6 1 \,_) (load-library "visual-basic-mode") (quote windows-7))
     (\` (6 2 \,_) (quote windows-8))
     (\` (6 3 \,_) (quote windows-8\.1)))
  eval-region(42066 42335 t (lambda (ignore) (goto-char 42335)
                              (quote (pcase ... ... ... ... ... ...
                                            ...))))  ; Reading at buffer position 42223
  apply(eval-region (42066 42335 t (lambda (ignore) (goto-char 42335) (quote ...))))
  eval-defun-2()
  eval-defun(nil)
  call-interactively(eval-defun t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)
  recursive-edit()
  byte-code("Æ  @Ç=!

Nor compile:

Error: Wrong number of arguments: #[(structure) "\301!A\207"
            [structure backquote-process] 2 1716431], 2

I note that the value of (w32-version) on Windows XP for me is: (5 1 2600)


texts:
I have been working with GNU emacs on a Linux server but my keyboard is for mac.
I have a problem with defining the alt key as meta.
tried (setq mac-command-modifier 'meta) in ~/.emacs.el and then eval-buffer but still esc key worked as meta.


texts: How can I make inline images bigger by default?

texts: I'm a new emacs user (spacemacs, really, switched from Vim), and I'm having difficulty configuring emacs on my HiDPI display. Basically, I'm suffering from this bug. The problem is that, while I can scale the font size on emacs fine, graphics and images don't scale. That's most apparent in inline images, say, in org mode, EIN, or anything that displays an image. Is there a way to just make all images twice as big, by default?


texts: Magit how to use ssh key rather than being prompted for password

texts:
I've seen the question here but I'm not sure if the same solution would apply to me
Magit, how to use system's ssh agent and don't ask for password
I'm on Emacs 25.1 / Ubuntu 16.04. I've just set up SSH-keys according to https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/ and I've added the public key to my GitHub account.
When I try to push though, Magit prompts me for my password to my account foobar@github.com (as always) rather than seeing that I've set an SSH-key into ssh-agent.
M-x getenv SSH_AGENT_PID doesn't exist and M-x getenv SSH_AUTH_SOCK is  /run/user/1000/keyring/ssh. echo $SSH_AGENT_PID is 18145. What is the next step from here?


texts: Is there any SMIE documentation that is clear?

texts:
I've spent many, many hours now trying to get any sort of SMIE indentation rule/grammar/thing working.

Are there any examples of a small, toy or skeleton SMIE-based mode with documentation on how it actually works, or any discussion anywhere about how to use it? Something that, say, defines an expression as a string of tokens ending in semi-colon and a block as some expressions between brackets and nothing else. Really, really simple?

Specific questions: when using smie-config-show-indent 90% of the time I get the response ':list-intro "" -> nil'.  What is list-intro basing its definition of an expression or a list of expressions on? Why does it say nil and still indent the following lines? How do I change it?

Secondly: is there any relationship between my grammar and my smie-rules? I assume there is because they are both passed into smie-setup, but I can't find any way of saying, "when you see a 'block', indent the contents", for example, based on a grammar that identifies a block.

Thirdly, SMIE seems to have lots of rules "baked in". Just kicking it off gives a general handling of brackets, braces, and parenthesis for instance. Is there any way of seeing these rules or modifying them? Or is it that the syntax table is doing all this and SMIE is literally doing nothing at all (which I'm starting to suspect).

Finally, when trying to debug SMIE I try to do an "edit, eval mode buffer, go to example code in other buffer, M-X <my mode>, test" cycle but it seems that each trip around does not clear out the rules from the previous cycle. How can I be sure that define-derived-mode starts from a clean sheet? I have (kill-all-local-variables) in there but it doesn't seem to be enough and I end up having to close emacs.

I'm not posting any examples of what I have because I have nothing that even vaguely works, aside from highlighting (using font-lock-defaults, so it's not even really SMIE I guess). I need some real baby steps.


texts: org-mode spreadsheet multiply 2 columns element-wise using GNU Emacs Calc formula

texts:
I am looking for a way to multiply 2 columns element by element and then sum the resulting vector. I have the following example:

|   |       | col1 | enable |
|---+-------+------+--------|
|   |       |    1 |      1 |
|   |       |    3 |      0 |
|   |       |      |      0 |
|   |       |    7 |      1 |
|---+-------+------+--------|
| # | sum   |   11 |      2 |
| # | value |      |        |
#+TBLFM: @6$3=vsum(@I$3..@II$3);N::@6$4=vsum(@I$4..@II$4);N

Now I want to add up all values of column col1, where there is a 1 in the enable column. The enable column determins, whether the value in column col1 is mathematically considered, because multiplied by 0, it will become an addend of 0 in the sum.

Mathematically speaking I want to:

result = sum_{i=0}^i=2 (col1_i * enable_i)

How can I achieve this?

I found inner on https://www.gnu.org/software/emacs/manual/html_node/calc/Generalized-Products.html#Generalized-Products and https://www.gnu.org/software/emacs/manual/html_node/calc/Function-Index.html#Function-Index, but do no understand how to make use of it or whether it is what I am looking for (not so firm in the terminology).

If the answer is, that this is not possible with a GNU Emacs Calc formula, that's also fine and good to know, but I think it should be possible, as it seems rather basic.

I would like to avoid having to add an extra column for the products and then summing that. The more clutter I can avoid, the better, as this table might get much wider in the future.


texts: How to fill same data to selected rectangle cells in org-mode?

texts:
Is it there a easy way to fill the same data in the rectangle area from cell a to cell b (4x4 cells) in the org-mode table as shown below in one go?

|   |   |   |   |   |   |   |   |
|---+---+---+---+---+---+---+---|
|   |   |   |   |   |   |   |   |
|   |   | a |   |   |   |   |   |
|   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |
|   |   |   |   |   | b |   |   |
|   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |


texts:
Wondering how would one go about applying a face to the agenda header. I tried it with the below code, but it does not apply the face. It does not generate errors, but it won't apply a face. I am quite new to spacemacs and org-mode.

To be precise, this is within a configuration for custom agenda. The relevant line looks like this:

(org-agenda-overriding-header (propertize "Purchases" 'face '(:foreground "yellow")))

I have spent a lot of time searching for an answer online and tried a lot of different things to no avail. As a last resort I am asking for help here.

Thanks a bunch!


texts: "cannot set terminal process group" error when running bash script

texts:
I have the following two lines of code in my init.el file:

(setq shell-file-name "bash")
(setq shell-command-switch "-ic")

I tried executing the following script to get a list of executables using the shell script dmenu_path.

(defun dmenu-path-out ()
  (shell-command-to-string "dmenu_path"))

I see the following error:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
[
0ad
...

How can I prevent bash from returning that error when using shell-command?